From fdba641a07779489fae213fd262b24b47c6a0ce5 Mon Sep 17 00:00:00 2001 From: tranngocson1996 Date: Tue, 16 Nov 2021 04:43:53 +0000 Subject: [PATCH] [IMP] account_payment: add hook method MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I create a method `_prepare_payment_display_name` for inherit. When you want to set a new name for payment, you can extend this method. Exp: I create a new partner type is `employee` in payment for payment with employee, but with your old code i can't add the key `outbound-employee` or `inbound-employee`. So, the system will give an error message. I think if you add this hook method, it will be good for customizers. closes odoo/odoo#85251 X-original-commit: 6d129783b53115927f664499207c8c800d40bca2 Signed-off-by: Quentin De Paoli Signed-off-by: William André (wan) --- addons/account/models/account_payment.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/addons/account/models/account_payment.py b/addons/account/models/account_payment.py index a4021010b98..e0f0f35733c 100644 --- a/addons/account/models/account_payment.py +++ b/addons/account/models/account_payment.py @@ -202,6 +202,18 @@ class AccountPayment(models.Model): self.journal_id.outbound_payment_method_line_ids.payment_account_id, ) + def _prepare_payment_display_name(self): + ''' + Hook method for inherit + When you want to set a new name for payment, you can extend this method + ''' + return { + 'outbound-customer': _("Customer Reimbursement"), + 'inbound-customer': _("Customer Payment"), + 'outbound-supplier': _("Vendor Payment"), + 'inbound-supplier': _("Vendor Reimbursement"), + } + def _prepare_move_line_default_vals(self, write_off_line_vals=None): ''' Prepare the dictionary to create the default account.move.lines for the current payment. :param write_off_line_vals: Optional dictionary to create a write-off account.move.line easily containing: @@ -257,12 +269,7 @@ class AccountPayment(models.Model): # Compute a default label to set on the journal items. - payment_display_name = { - 'outbound-customer': _("Customer Reimbursement"), - 'inbound-customer': _("Customer Payment"), - 'outbound-supplier': _("Vendor Payment"), - 'inbound-supplier': _("Vendor Reimbursement"), - } + payment_display_name = self._prepare_payment_display_name() default_line_name = self.env['account.move.line']._get_default_line_name( _("Internal Transfer") if self.is_internal_transfer else payment_display_name['%s-%s' % (self.payment_type, self.partner_type)],