Raise warning when trying to validate bulk payments not in the required state
This commit is contained in:
parent
3b5ad7087d
commit
9b5672d9de
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<data noupdate="1">
|
||||
<data noupdate="0">
|
||||
<!-- Server Action for Department Manager -->
|
||||
<record id="action_account_multi_depart_manager" model="ir.actions.server">
|
||||
<field name="name">Set to Department Manager (Multi)</field>
|
||||
|
|
@ -11,14 +11,8 @@
|
|||
<field name="binding_model_id" ref="account.model_account_payment"/>
|
||||
<field name="binding_view_types">list</field>
|
||||
<field name="code">
|
||||
# Filter records that meet the criteria
|
||||
valid_records = records.filtered(
|
||||
lambda r: r.payment_type == 'outbound' and r.state == 'draft'
|
||||
)
|
||||
|
||||
# Perform the action only on valid records
|
||||
for record in valid_records:
|
||||
record.action_depart_manager()
|
||||
if records:
|
||||
action = records.action_multi_depart_manager()
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
|
@ -32,14 +26,8 @@ for record in valid_records:
|
|||
<field name="binding_model_id" ref="account.model_account_payment"/>
|
||||
<field name="binding_view_types">list</field>
|
||||
<field name="code">
|
||||
# Filter records that meet the criteria
|
||||
valid_records = records.filtered(
|
||||
lambda r: r.payment_type == 'outbound' and r.state == 'depart_manager'
|
||||
)
|
||||
|
||||
# Perform the action only on valid records
|
||||
for record in valid_records:
|
||||
record.action_accounting_manager()
|
||||
if records:
|
||||
action = records.action_multi_accounting_manager()
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
|
@ -53,14 +41,8 @@ for record in valid_records:
|
|||
<field name="binding_model_id" ref="account.model_account_payment"/>
|
||||
<field name="binding_view_types">list</field>
|
||||
<field name="code">
|
||||
# Filter records that meet the criteria
|
||||
valid_records = records.filtered(
|
||||
lambda r: r.payment_type == 'outbound' and r.state == 'accounting_manager'
|
||||
)
|
||||
|
||||
# Perform the action only on valid records
|
||||
for record in valid_records:
|
||||
record.action_general_manager()
|
||||
if records:
|
||||
action = records.action_multi_general_manager()
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
|
@ -74,14 +56,8 @@ for record in valid_records:
|
|||
<field name="binding_model_id" ref="account.model_account_payment"/>
|
||||
<field name="binding_view_types">list</field>
|
||||
<field name="code">
|
||||
# Filter records that meet the criteria
|
||||
valid_records = records.filtered(
|
||||
lambda r: r.payment_type == 'outbound' and r.state == 'general_manager'
|
||||
)
|
||||
|
||||
# Perform the action only on valid records
|
||||
for record in valid_records:
|
||||
record.action_post()
|
||||
if records:
|
||||
action = records.action_multi_post_payments()
|
||||
</field>
|
||||
</record>
|
||||
</data>
|
||||
|
|
|
|||
|
|
@ -125,6 +125,46 @@ msgstr "الحالة السابقة"
|
|||
msgid "Status"
|
||||
msgstr "الحالة"
|
||||
|
||||
#. module: odex25_account_payment_fix
|
||||
#: code:addons/odex25_account_payment_fix/models/account_payment.py:0
|
||||
#, python-format
|
||||
msgid ""
|
||||
"Action skipped: one or more selected outbound payments are not in the "
|
||||
"'Draft' state."
|
||||
msgstr ""
|
||||
"تم تخطي العملية: واحد أو أكثر من الدفعات الصادرة المحددة ليست في حالة "
|
||||
"مسودة."
|
||||
|
||||
#. module: odex25_account_payment_fix
|
||||
#: code:addons/odex25_account_payment_fix/models/account_payment.py:0
|
||||
#, python-format
|
||||
msgid ""
|
||||
"Action skipped: one or more selected outbound payments are not in the "
|
||||
"'General Manager' state."
|
||||
msgstr ""
|
||||
"تم تخطي العملية: واحد أو أكثر من الدفعات الصادرة المحددة ليست في حالة "
|
||||
"المدير العام."
|
||||
|
||||
#. module: odex25_account_payment_fix
|
||||
#: code:addons/odex25_account_payment_fix/models/account_payment.py:0
|
||||
#, python-format
|
||||
msgid ""
|
||||
"Action skipped: one or more selected outbound payments are not in the "
|
||||
"'Depart Manager' state."
|
||||
msgstr ""
|
||||
"تم تخطي العملية: واحد أو أكثر من الدفعات الصادرة المحددة ليست في حالة "
|
||||
"رئيس القسم."
|
||||
|
||||
#. module: odex25_account_payment_fix
|
||||
#: code:addons/odex25_account_payment_fix/models/account_payment.py:0
|
||||
#, python-format
|
||||
msgid ""
|
||||
"Action skipped: one or more selected outbound payments are not in the "
|
||||
"'Accounting Manager' state."
|
||||
msgstr ""
|
||||
"تم تخطي العملية: واحد أو أكثر من الدفعات الصادرة المحددة ليست في حالة "
|
||||
"المدير المالي."
|
||||
|
||||
#. module: odex25_account_payment_fix
|
||||
#: code:addons/odex25_account_payment_fix/models/account_payment.py:0
|
||||
#, python-format
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from odoo import models, fields, api, _
|
||||
from odoo.exceptions import AccessError, ValidationError
|
||||
from odoo.exceptions import AccessError, ValidationError, Warning, UserError
|
||||
|
||||
|
||||
class AccountMove(models.Model):
|
||||
|
|
@ -104,3 +104,34 @@ class AccountPayment(models.Model):
|
|||
self._check_permission('odex25_account_payment_fix.group_general_manager')
|
||||
self.state_history = self.state
|
||||
self.state = 'general_manager'
|
||||
|
||||
def action_multi_depart_manager(self):
|
||||
if any(rec.payment_type == 'outbound' and rec.state != 'draft' for rec in self):
|
||||
raise UserError(_("Action skipped: one or more selected outbound payments are not in the 'Draft' state."))
|
||||
|
||||
for rec in self.filtered(lambda r: r.payment_type == 'outbound' and r.state == 'draft'):
|
||||
rec.action_depart_manager()
|
||||
|
||||
def action_multi_accounting_manager(self):
|
||||
if any(rec.payment_type == 'outbound' and rec.state != 'depart_manager' for rec in self):
|
||||
raise UserError(
|
||||
_("Action skipped: one or more selected outbound payments are not in the 'Depart Manager' state."))
|
||||
|
||||
for rec in self.filtered(lambda r: r.payment_type == 'outbound' and r.state == 'depart_manager'):
|
||||
rec.action_accounting_manager()
|
||||
|
||||
def action_multi_general_manager(self):
|
||||
if any(rec.payment_type == 'outbound' and rec.state != 'accounting_manager' for rec in self):
|
||||
raise UserError(
|
||||
_("Action skipped: one or more selected outbound payments are not in the 'Accounting Manager' state."))
|
||||
|
||||
for rec in self.filtered(lambda r: r.payment_type == 'outbound' and r.state == 'accounting_manager'):
|
||||
rec.action_general_manager()
|
||||
|
||||
def action_multi_post_payments(self):
|
||||
if any(rec.payment_type == 'outbound' and rec.state != 'general_manager' for rec in self):
|
||||
raise UserError(
|
||||
_("Action skipped: one or more selected outbound payments are not in the 'General Manager' state."))
|
||||
|
||||
for rec in self.filtered(lambda r: r.payment_type == 'outbound' and r.state == 'general_manager'):
|
||||
rec.action_post()
|
||||
|
|
|
|||
Loading…
Reference in New Issue