Skip to content
Snippets Groups Projects
Commit 2785b045 authored by Nicolas Martinelli's avatar Nicolas Martinelli
Browse files

[FIX] purchase_stock: tax included in multi-currency


- Set the company currency to USD, activate multi-currency
- Create a rate of 0.5 for EUR
- Create a purchase tax T:
  Percentage: 10 %
  Included in price
- Create a PO in EUR with the followind line
  Quantity: 10.0
  Price Unit: 1.0
  Tax: T
- Validate the PO, receive the product

The journal entry is composed of 2 lines:
- debit:  18.18; amount currency:  10.0
- credit: 18.18; amount currency: -10.0

This is not correct: the amount currency should not include the tax.

In order to prevent this, we use the subtotal, and divide by the
normalized quantity (yeah, because it was also failing in case of multi
UoM, as one could have expected).

opw-1958287

closes odoo/odoo#32797

Signed-off-by: default avatarNicolas Martinelli (nim) <nim@odoo.com>
parent 39c3abc5
Branches
Tags
No related merge requests found
......@@ -60,7 +60,13 @@ class StockMove(models.Model):
if self.purchase_line_id:
purchase_currency = self.purchase_line_id.currency_id
if purchase_currency != self.company_id.currency_id:
purchase_price_unit = self.purchase_line_id.price_unit
# Do not use price_unit since we want the price tax excluded. And by the way, qty
# is in the UOM of the product, not the UOM of the PO line.
purchase_price_unit = (
self.purchase_line_id.price_subtotal / self.purchase_line_id.product_uom_qty
if self.purchase_line_id.product_uom_qty
else self.purchase_line_id.price_unit
)
currency_move_valuation = purchase_currency.round(purchase_price_unit * abs(qty))
rslt['credit_line_vals']['amount_currency'] = rslt['credit_line_vals']['credit'] and -currency_move_valuation or currency_move_valuation
rslt['credit_line_vals']['currency_id'] = purchase_currency.id
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment