From 45b378f1f094add8717949f005ab66a5a9dbfa0c Mon Sep 17 00:00:00 2001 From: fw-bot Date: Mon, 28 Jun 2021 09:35:46 +0000 Subject: [PATCH] [FIX] account_check_printing: wizard use vendor payment method The payment method added by account_check_printing is meant as: > Preferred payment method when paying this vendor. This is used to > filter vendor bills by preferred payment method to register payments > in mass. Use cases: create bank files for batch wires, check runs. But it may also select the default payment method on an account.payment. With this changeset, we copy what is done in account.payment to account.payment.register so the behavior is the same for it. forward-port of #72655 opw-2508263 X-original-commit: a546e7e870987e882ab2c9a6fa2618476b76fcb8 --- .../account_check_printing/models/account_payment.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/addons/account_check_printing/models/account_payment.py b/addons/account_check_printing/models/account_payment.py index f349be9c621..fe85dc472f2 100644 --- a/addons/account_check_printing/models/account_payment.py +++ b/addons/account_check_printing/models/account_payment.py @@ -8,6 +8,18 @@ from odoo.tools.misc import formatLang, format_date INV_LINES_PER_STUB = 9 +class AccountPaymentRegister(models.TransientModel): + _inherit = "account.payment.register" + + @api.depends('payment_type', 'journal_id', 'partner_id') + def _compute_payment_method_id(self): + super()._compute_payment_method_id() + for record in self: + preferred = record.partner_id.with_company(record.company_id).property_payment_method_id + if (record.payment_type == 'outbound' + and preferred in record.journal_id.outbound_payment_method_line_ids.mapped('payment_method_id')): + record.payment_method_id = preferred + class AccountPayment(models.Model): _inherit = "account.payment"