From bb438a29354048be36fe973cd4eba11cee03ed26 Mon Sep 17 00:00:00 2001 From: Goffin Simon Date: Wed, 31 May 2017 13:40:45 +0200 Subject: [PATCH] [FIX] account, purchase: payment term in vendor bill When creating a vendor bill from a PO, the payment term configured in the PO was lost due to function _onchange_partner_id. When creating a vendor bill, the field payment term was invisibile if there was no payment term set on the vendor. opw:744714 --- addons/account/views/account_invoice_view.xml | 2 +- addons/purchase/models/account_invoice.py | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/addons/account/views/account_invoice_view.xml b/addons/account/views/account_invoice_view.xml index 7e9387bf7a3..a691f9cc660 100644 --- a/addons/account/views/account_invoice_view.xml +++ b/addons/account/views/account_invoice_view.xml @@ -321,7 +321,7 @@ - + diff --git a/addons/purchase/models/account_invoice.py b/addons/purchase/models/account_invoice.py index 9c1cf48312c..787e1b174ea 100644 --- a/addons/purchase/models/account_invoice.py +++ b/addons/purchase/models/account_invoice.py @@ -75,6 +75,8 @@ class AccountInvoice(models.Model): new_lines += new_line self.invoice_line_ids += new_lines + self.payment_term_id = self.purchase_id.payment_term_id + self.env.context = dict(self.env.context, from_purchase_order_change=True) self.purchase_id = False return {} @@ -92,7 +94,10 @@ class AccountInvoice(models.Model): @api.onchange('partner_id', 'company_id') def _onchange_partner_id(self): + payment_term_id = self.env.context.get('from_purchase_order_change') and self.payment_term_id or False res = super(AccountInvoice, self)._onchange_partner_id() + if payment_term_id: + self.payment_term_id = payment_term_id if not self.env.context.get('default_journal_id') and self.partner_id and self.currency_id and\ self.type in ['in_invoice', 'in_refund'] and\ self.currency_id != self.partner_id.property_purchase_currency_id: