diff --git a/addons/purchase_stock/models/purchase.py b/addons/purchase_stock/models/purchase.py index b4d63b36c65..557d32f3fa3 100644 --- a/addons/purchase_stock/models/purchase.py +++ b/addons/purchase_stock/models/purchase.py @@ -413,18 +413,17 @@ class PurchaseOrderLine(models.Model): def _get_stock_move_price_unit(self): self.ensure_one() - line = self[0] - order = line.order_id - price_unit = line.price_unit + order = self.order_id + price_unit = self.price_unit price_unit_prec = self.env['decimal.precision'].precision_get('Product Price') - if line.taxes_id: - qty = line.product_qty or 1 - price_unit = line.taxes_id.with_context(round=False).compute_all( - price_unit, currency=line.order_id.currency_id, quantity=qty, product=line.product_id, partner=line.order_id.partner_id + if self.taxes_id: + qty = self.product_qty or 1 + price_unit = self.taxes_id.with_context(round=False).compute_all( + price_unit, currency=self.order_id.currency_id, quantity=qty, product=self.product_id, partner=self.order_id.partner_id )['total_void'] price_unit = float_round(price_unit / qty, precision_digits=price_unit_prec) - if line.product_uom.id != line.product_id.uom_id.id: - price_unit *= line.product_uom.factor / line.product_id.uom_id.factor + if self.product_uom.id != self.product_id.uom_id.id: + price_unit *= self.product_uom.factor / self.product_id.uom_id.factor if order.currency_id != order.company_id.currency_id: price_unit = order.currency_id._convert( price_unit, order.company_id.currency_id, self.company_id, self.date_order or fields.Date.today(), round=False)