[FIX] account: make recipient bank account readonly

Currently: "register payment" wizard allows selecting different bank accounts or even creating one when registering a payment on customer invoice/vendor refund.

Should be: the field should be set to partner_bank_id and be set as readonly. When cash journal is selected, "Recipient Bank Account" field should be hidden

Task ID: 2710936

closes odoo/odoo#81319

Signed-off-by: Olivier Colson <oco@odoo.com>
This commit is contained in:
aliya
2022-02-01 09:54:13 +00:00
parent e34430c822
commit 9311b087e1
4 changed files with 13 additions and 7 deletions
+4 -1
View File
@@ -353,7 +353,10 @@ class AccountPayment(models.Model):
""" Computes if the destination bank account must be displayed in the payment form view. By default, it
won't be displayed but some modules might change that, depending on the payment type."""
for payment in self:
payment.show_partner_bank_account = payment.payment_method_code in self._get_method_codes_using_bank_account()
if payment.journal_id.type == 'cash':
payment.show_partner_bank_account = False
else:
payment.show_partner_bank_account = payment.payment_method_code in self._get_method_codes_using_bank_account()
payment.require_partner_bank_account = payment.state == 'draft' and payment.payment_method_code in self._get_method_codes_needing_bank_account()
@api.depends('amount_total_signed', 'payment_type')
@@ -267,18 +267,18 @@
<field name="payment_method_line_id" required="1" options="{'no_create': True, 'no_open': True}"
attrs="{'readonly': [('state', '!=', 'draft')]}"/>
<field name="partner_bank_id" context="{'default_partner_id': partner_id}" string="Customer Bank Account"
<field name="partner_bank_id" context="{'default_partner_id': partner_id}" string="Recipient Bank Account"
attrs="{
'invisible': ['|', '|', ('show_partner_bank_account', '=', False), ('partner_type','!=','customer'), ('is_internal_transfer', '=', True)],
'required': [('require_partner_bank_account', '=', True), ('is_internal_transfer', '=', False)],
'readonly': [('state', '!=', 'draft')]
'readonly': ['|', ('state', '!=', 'draft'), ('payment_type', '=', 'inbound')],
}"/>
<field name="partner_bank_id" context="{'default_partner_id': partner_id}" string="Vendor Bank Account"
<field name="partner_bank_id" context="{'default_partner_id': partner_id}" string="Recipient Bank Account"
attrs="{
'invisible': ['|', '|', ('show_partner_bank_account', '=', False), ('partner_type','!=','supplier'), ('is_internal_transfer', '=', True)],
'required': [('require_partner_bank_account', '=', True), ('is_internal_transfer', '=', False)],
'readonly': [('state', '!=', 'draft')]
'readonly': ['|', ('state', '!=', 'draft'), ('payment_type', '=', 'inbound')],
}"/>
<field name="destination_journal_id" context="{'default_partner_id': partner_id}"
attrs="{'invisible': [('is_internal_transfer', '=', False)],
@@ -408,7 +408,10 @@ class AccountPaymentRegister(models.TransientModel):
""" Computes if the destination bank account must be displayed in the payment form view. By default, it
won't be displayed but some modules might change that, depending on the payment type."""
for wizard in self:
wizard.show_partner_bank_account = wizard.payment_method_line_id.code in self.env['account.payment']._get_method_codes_using_bank_account()
if wizard.journal_id.type == 'cash':
wizard.show_partner_bank_account = False
else:
wizard.show_partner_bank_account = wizard.payment_method_line_id.code in self.env['account.payment']._get_method_codes_using_bank_account()
wizard.require_partner_bank_account = wizard.payment_method_line_id.code in self.env['account.payment']._get_method_codes_needing_bank_account()
@api.depends('source_amount', 'source_amount_currency', 'source_currency_id', 'company_id', 'currency_id', 'payment_date')
@@ -34,7 +34,7 @@
required="1" options="{'no_create': True, 'no_open': True}"/>
<field name="partner_bank_id"
attrs="{'invisible': ['|', ('show_partner_bank_account', '=', False), '|', ('can_edit_wizard', '=', False), '&amp;', ('can_group_payments', '=', True), ('group_payment', '=', False)],
'required': [('require_partner_bank_account', '=', True), ('can_edit_wizard', '=', True), '|', ('can_group_payments', '=', False), ('group_payment', '=', False)]}"/>
'required': [('require_partner_bank_account', '=', True), ('can_edit_wizard', '=', True), '|', ('can_group_payments', '=', False), ('group_payment', '=', False)], 'readonly': [('payment_type', '=', 'inbound')]}"/>
<field name="group_payment"
attrs="{'invisible': [('can_group_payments', '=', False)]}"/>
</group>