From 9890e9abc2d63687af1735804c0b540c9fdabf0e Mon Sep 17 00:00:00 2001 From: Juan Jose Scarafia Date: Mon, 11 Apr 2022 12:16:26 +0000 Subject: [PATCH] [FIX] account_payment: hide payment methods 1. _get_payment_method_codes_to_exclude was not considered on _compute_payment_method_line_id 2. to avoid duplicating code on _compute_payment_method_line_id we can directly call available_payment_method_line_ids 3. to avoid re-defining dependencies (and make inheritance easier) we can use 'available_payment_method_line_ids' on _compute_payment_method_line_id 4. fix docstring, _compute_payment_method_fields does not exists anymore, it's called _compute_payment_method_line_fields 5. fix using "self" instead of pay when calling _get_payment_method_codes_to_exclude closes odoo/odoo#88666 X-original-commit: 63d46ba547c3b0fbadd7c076451659734ad767ae Related: odoo/enterprise#26167 Signed-off-by: Florian Gilbert --- addons/account/models/account_payment.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/addons/account/models/account_payment.py b/addons/account/models/account_payment.py index 4f8dac824b9..6f634f342ac 100644 --- a/addons/account/models/account_payment.py +++ b/addons/account/models/account_payment.py @@ -404,13 +404,13 @@ class AccountPayment(models.Model): and payment.partner_id == payment.journal_id.company_id.partner_id \ and payment.destination_journal_id - @api.depends('payment_type', 'journal_id') + @api.depends('available_payment_method_line_ids') def _compute_payment_method_line_id(self): ''' Compute the 'payment_method_line_id' field. - This field is not computed in '_compute_payment_method_fields' because it's a stored editable one. + This field is not computed in '_compute_payment_method_line_fields' because it's a stored editable one. ''' for pay in self: - available_payment_method_lines = pay.journal_id._get_available_payment_method_lines(pay.payment_type) + available_payment_method_lines = pay.available_payment_method_line_ids # Select the first available one by default. if pay.payment_method_line_id in available_payment_method_lines: @@ -424,7 +424,7 @@ class AccountPayment(models.Model): def _compute_payment_method_line_fields(self): for pay in self: pay.available_payment_method_line_ids = pay.journal_id._get_available_payment_method_lines(pay.payment_type) - to_exclude = self._get_payment_method_codes_to_exclude() + to_exclude = pay._get_payment_method_codes_to_exclude() if to_exclude: pay.available_payment_method_line_ids = pay.available_payment_method_line_ids.filtered(lambda x: x.code not in to_exclude)