[FIX] purchase: no unit price and tax update

If no seller is found, do not update unit price and taxes. Indeed, if the
user changes the quantity, it will reset the unit price and the taxes,
which is confusing.

opw-653094
This commit is contained in:
Nicolas Martinelli
2015-11-05 13:16:25 +01:00
parent 1439b9744d
commit ae37c87cc2
+14 -9
View File
@@ -562,6 +562,14 @@ class PurchaseOrderLine(models.Model):
self.product_uom = self.product_id.uom_po_id
result['domain'] = {'product_uom': [('category_id', '=', self.product_id.uom_id.category_id.id)]}
product_lang = self.product_id.with_context({
'lang': self.partner_id.lang,
'partner_id': self.partner_id.id,
})
self.name = product_lang.display_name
if product_lang.description_purchase:
self.name += '\n' + product_lang.description_purchase
seller = self.product_id._select_seller(
self.product_id,
partner_id=self.partner_id,
@@ -569,6 +577,12 @@ class PurchaseOrderLine(models.Model):
date=self.order_id.date_order and self.order_id.date_order[:10],
uom_id=self.product_uom)
if seller or not self.date_planned:
self.date_planned = self._get_date_planned(seller).strftime(DEFAULT_SERVER_DATETIME_FORMAT)
if not seller:
return result
fpos = self.order_id.fiscal_position_id
self.taxes_id = fpos.map_tax(self.product_id.supplier_taxes_id)
@@ -576,16 +590,7 @@ class PurchaseOrderLine(models.Model):
if price_unit and seller and self.order_id.currency_id and seller.currency_id != self.order_id.currency_id:
price_unit = seller.currency_id.compute(price_unit, self.order_id.currency_id)
self.price_unit = price_unit
if seller or not self.date_planned:
self.date_planned = self._get_date_planned(seller).strftime(DEFAULT_SERVER_DATETIME_FORMAT)
product_lang = self.product_id.with_context({
'lang': self.partner_id.lang,
'partner_id': self.partner_id.id,
})
self.name = product_lang.display_name
if product_lang.description_purchase:
self.name += '\n' + product_lang.description_purchase
class ProcurementRule(models.Model):