[FIX] purchase: Only use purchase UOM on vendor bill

It was the purpose of this commit fea667a243
However it uses purchase uom in any cases and not
only vendor bill.

This commit correct it by using it only if a purchase
order is linked to the invoice.
This commit is contained in:
Arnold Moyaux
2017-12-11 11:24:33 +01:00
parent f3623f1513
commit 6d02f7d6bf
2 changed files with 7 additions and 3 deletions
-3
View File
@@ -1316,9 +1316,6 @@ class AccountInvoiceLine(models.Model):
self.price_unit = 0.0
domain['uom_id'] = []
else:
# Use the purchase uom by default
self.uom_id = self.product_id.uom_po_id
if part.lang:
product = self.product_id.with_context(lang=part.lang)
else:
@@ -59,6 +59,13 @@ class AccountInvoice(models.Model):
data['account_id'] = account.id
return data
def _onchange_product_id(self):
domain = super(AccountInvoice, self)._onchange_product_id()
if self.purchase_id:
# Use the purchase uom by default
self.uom_id = self.product_id.uom_po_id
return domain
# Load all unsold PO lines
@api.onchange('purchase_id')
def purchase_order_change(self):