[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) <agr@odoo.com>
Signed-off-by: Vranckx Florian (flvr) <flvr@odoo.com>
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user