From c30fb23f7b3286ec62c1ed0fd8bd0feb9eab9bb9 Mon Sep 17 00:00:00 2001 From: "Andrea Grazioso (agr-odoo)" Date: Tue, 10 Dec 2019 10:20:47 +0000 Subject: [PATCH] [FIX] sale: add bank information on down payment On a Sale order having customer with bank information available create an invoice (down payment). Bank information will not be available. This append because the company_id is not provided to the create and bank information will not be available https://github.com/odoo/odoo/blob/12.0/addons/account/models/account_invoice.py#L549 opw-2153810 closes odoo/odoo#41902 X-original-commit: 097db42b0302c769a6584004d7a9cbbc03856de7 Signed-off-by: Nicolas Martinelli (nim) --- addons/sale/models/sale.py | 7 +++++++ addons/sale/wizard/sale_make_invoice_advance.py | 1 + 2 files changed, 8 insertions(+) diff --git a/addons/sale/models/sale.py b/addons/sale/models/sale.py index 724650b71aa..889bf98dc44 100644 --- a/addons/sale/models/sale.py +++ b/addons/sale/models/sale.py @@ -651,6 +651,13 @@ class SaleOrder(models.Model): else: out_invoice_vals_list = invoice_vals_list + if invoice_vals['type'] in self.env['account.move'].get_outbound_types(): + invoice_bank_id = self.partner_id.bank_ids[:1] + else: + invoice_bank_id = self.company_id.partner_id.bank_ids[:1] + + invoice_vals['invoice_partner_bank_id'] = invoice_bank_id + # Create invoices. moves = self.env['account.move'].with_context(default_type='out_invoice').create(out_invoice_vals_list) moves += self.env['account.move'].with_context(default_type='out_refund').create(refund_invoice_vals_list) diff --git a/addons/sale/wizard/sale_make_invoice_advance.py b/addons/sale/wizard/sale_make_invoice_advance.py index ab1a74703c7..516c9f01b29 100644 --- a/addons/sale/wizard/sale_make_invoice_advance.py +++ b/addons/sale/wizard/sale_make_invoice_advance.py @@ -90,6 +90,7 @@ class SaleAdvancePaymentInv(models.TransientModel): 'currency_id': order.pricelist_id.currency_id.id, 'invoice_payment_ref': order.client_order_ref, 'invoice_payment_term_id': order.payment_term_id.id, + 'invoice_partner_bank_id': order.company_id.partner_id.bank_ids[:1], 'team_id': order.team_id.id, 'campaign_id': order.campaign_id.id, 'medium_id': order.medium_id.id,