[FIX] purchase: don't break the prefetch

Avoid breaking prefetch for `_get_stock_move_price_unit`

task-2558097
This commit is contained in:
Rémy Voet (ryv)
2021-07-13 06:57:17 +00:00
parent 8f23404ad3
commit 3d35d2ecc0
+8 -9
View File
@@ -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)