summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGoffin Simon <sig@odoo.com>2017-05-31 13:40:45 +0200
committerGoffin Simon <sig@odoo.com>2017-05-31 15:21:52 +0200
commitbb438a29354048be36fe973cd4eba11cee03ed26 (patch)
treebe473b059d358067b4df6434a1cdc95a18092ed6
parent3fd0bdbd40c594003a2c0a3c70af87a5fa0010e1 (diff)
[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
-rw-r--r--addons/account/views/account_invoice_view.xml2
-rw-r--r--addons/purchase/models/account_invoice.py5
2 files changed, 6 insertions, 1 deletions
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 @@
<field domain="[('company_id', '=', company_id), ('internal_type', '=', 'payable'), ('deprecated', '=', False)]"
name="account_id" groups="account.group_account_manager"/>
<field name="name" invisible="1"/>
- <field name="payment_term_id" options="{'no_create': True}" attrs="{'invisible': [('payment_term_id','=',False)]}"/>
+ <field name="payment_term_id" options="{'no_create': True}"/>
</group>
<group>
<field name="fiscal_position_id" options="{'no_create': True}" placeholder="Auto-detect"/>
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: