From ae37c87cc28d9eb063d34a9234485c215cc46e6f Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Thu, 5 Nov 2015 10:00:07 +0100 Subject: [PATCH] [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 --- addons/purchase/purchase.py | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py index b748193e44f..c10bb62aab4 100644 --- a/addons/purchase/purchase.py +++ b/addons/purchase/purchase.py @@ -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):