[FIX] *: fix product.uom._compute_price method calls

During the conversion to the new api,
the method `product.uom`.`_compute_price` has had its signature
changed.

Formerly, it was:
`def _compute_price(self, cr, uid, from_uom_id, price, to_uom_id=False):`
Now, it is:
`def _compute_price(self, price, to_unit):`

Basically:
- the first argument `from_uom_id` is removed, and you now should
call this method from the model record directly
- the last argument is no longer a kwargs

Some calls to this method were still done the former way:
 - Some have been added during forward ports
 - Some are oversights when this method has been converted to the new api

This revision corrects the calls that were still done the former way
to the new way.

opw-694871
This commit is contained in:
Denis Ledoux
2016-11-24 11:33:38 +01:00
parent 46c5db095a
commit cf98d58f88
5 changed files with 6 additions and 6 deletions
@@ -268,8 +268,8 @@ class PurchaseOrderLine(models.Model):
for line in self.order_id.requisition_id.line_ids:
if line.product_id == self.product_id:
if line.product_uom_id != self.product_uom:
self.price_unit = self.env['product.uom']._compute_price(
line.product_uom_id.id, line.price_unit, to_uom_id=self.product_uom.id)
self.price_unit = line.product_uom_id._compute_price(
line.price_unit, self.product_uom)
else:
self.price_unit = line.price_unit
break
+1 -1
View File
@@ -28,7 +28,7 @@ class SaleOrderLine(models.Model):
to_cur = pricelist.currency_id
purchase_price = product.standard_price
if product_uom != product.uom_id:
purchase_price = self.env['product.uom']._compute_price(product.uom_id.id, purchase_price, to_uom_id=product_uom.id)
purchase_price = product.uom_id._compute_price(purchase_price, product_uom)
ctx = self.env.context.copy()
ctx['date'] = date
price = frm_cur.with_context(ctx).compute(purchase_price, to_cur, round=False)
+1 -1
View File
@@ -89,5 +89,5 @@ class AccountInvoiceLine(models.Model):
prod_quantity = factor * quantity
average_price_unit += self._compute_average_price(prod_qty_done, prod_quantity, prod_moves)
price_unit = average_price_unit or price_unit
price_unit = self.product_id.uom_id._compute_price(self.product_id.uom_id.id, price_unit, to_uom_id=self.uom_id.id)
price_unit = self.product_id.uom_id._compute_price(price_unit, self.uom_id)
return price_unit
+1 -1
View File
@@ -34,7 +34,7 @@ class AccountInvoiceLine(models.Model):
# on the moves we encounter.
average_price_unit = self._compute_average_price(qty_done, quantity, moves)
price_unit = average_price_unit or price_unit
price_unit = self.product_id.uom_id._compute_price(self.product_id.uom_id.id, price_unit, to_uom_id=self.uom_id.id)
price_unit = self.product_id.uom_id._compute_price(price_unit, self.uom_id)
return price_unit
def _compute_average_price(self, qty_done, quantity, moves):
@@ -77,7 +77,7 @@ class AccountInvoiceLine(models.Model):
if not self.uom_id or self.product_id.uom_id == self.uom_id:
return price
else:
return self.product_id.uom_id._compute_price(self.product_id.uom_id.id, price, to_uom_id=self.uom_id.id)
return self.product_id.uom_id._compute_price(price, self.uom_id)
def _get_price(self, company_currency, price_unit):
if self.invoice_id.currency_id.id != company_currency.id: