From aedf8be34d93bf4836844c57229a562efcfe326e Mon Sep 17 00:00:00 2001 From: Florian Vranckx Date: Wed, 1 Jun 2022 14:10:33 +0000 Subject: [PATCH] [FIX] purchase: fix bank info on vendor bill based on po Steps to reproduce: - Install puchases, accounting, contact - Create a new company with a bank account - Create a new person contact linked to the previous company - Make a purchase order from that person - Make a vendor bill using the auto-complete as the previous PO Issue: The bank account field is not filled Cause: The _prepare_invoice function tries to grab the bank information from the contact on the PO. But in the case of a person of a company, this information is stored in the parent company. Resulting in an empty value Solution: Use the field "comercial_partner_id" to get the bank id. As this field will use the parent company if the current partner is a person. opw-2849706 closes odoo/odoo#93487 X-original-commit: c5f94e84dd5d6ec108484425d348053961bd13ff Signed-off-by: Grazioso Andrea (agr) Signed-off-by: Vranckx Florian (flvr) --- addons/purchase/models/purchase.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/purchase/models/purchase.py b/addons/purchase/models/purchase.py index f29e7913489..7618a6b1389 100644 --- a/addons/purchase/models/purchase.py +++ b/addons/purchase/models/purchase.py @@ -607,7 +607,8 @@ class PurchaseOrder(models.Model): raise UserError(_('Please define an accounting purchase journal for the company %s (%s).') % (self.company_id.name, self.company_id.id)) partner_invoice = self.env['res.partner'].browse(self.partner_id.address_get(['invoice'])['invoice']) - partner_bank_id = self.partner_id.bank_ids.filtered_domain(['|', ('company_id', '=', False), ('company_id', '=', self.company_id.id)])[:1] + partner_bank_id = self.partner_id.commercial_partner_id.bank_ids.filtered_domain(['|', ('company_id', '=', False), ('company_id', '=', self.company_id.id)])[:1] + invoice_vals = { 'ref': self.partner_ref or '', 'move_type': move_type,