[FIX] stock_account: _get_anglo_saxon_price_unit

Backport of ab279d9cea

When getting the price from a account.move.line, the uom set
on the line must be taken into account.

Before the fix:

-Set anglo-saxon accounting
-Create two units of measure Box and Mot where 1Mot = 10Box
-Create a stockable product with Box as unit of reference and set with
real price and perpetual
-Create a SO with a Mot of this product
-Confirm the SO and create the invoice
-Validate the invoice

Bug:
In the journal of entries, only one box was counted for the debit and the credit
instead of 10.

NB: The function _get_anglo_saxon_price_unit must return the price unit of the
product in the unit of measure of the account.invoice.line.

opw:693075
This commit is contained in:
Goffin Simon
2016-11-28 10:20:38 +01:00
parent d2b4f0e786
commit 043aa0b158
3 changed files with 7 additions and 3 deletions
+1 -1
View File
@@ -143,5 +143,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 = uom_obj._compute_qty_obj(self.uom_id, price_unit, self.product_id.uom_id, round=False)
price_unit = self.product_id.uom_id._compute_price(self.product_id.uom_id.id, price_unit, to_uom_id=self.uom_id.id)
return price_unit
+1 -1
View File
@@ -336,7 +336,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 = uom_obj._compute_qty_obj(self.uom_id, price_unit, self.product_id.uom_id, round=False)
price_unit = self.product_id.uom_id._compute_price(self.product_id.uom_id.id, price_unit, to_uom_id=self.uom_id.id)
return price_unit
def _compute_average_price(self, qty_done, quantity, moves):
+5 -1
View File
@@ -30,7 +30,11 @@ class account_invoice_line(osv.osv):
def _get_anglo_saxon_price_unit(self):
self.ensure_one()
return self.product_id.standard_price
price = self.product_id.standard_price
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)
def _get_price(self, cr, uid, inv, company_currency, i_line, price_unit):
cur_obj = self.pool.get('res.currency')