46 lines
2.1 KiB
Diff
46 lines
2.1 KiB
Diff
|
diff --git a/trytond/trytond/modules/account_stock_landed_cost/account.py b/trytond/trytond/modules/account_stock_landed_cost/account.py
|
||
|
index 3815326..93478b1 100644
|
||
|
--- a/trytond/trytond/modules/account_stock_landed_cost/account.py
|
||
|
+++ b/trytond/trytond/modules/account_stock_landed_cost/account.py
|
||
|
@@ -10,11 +10,18 @@ from trytond.transaction import Transaction
|
||
|
from trytond import backend
|
||
|
from trytond.tools.multivalue import migrate_property
|
||
|
from trytond.modules.company.model import CompanyValueMixin
|
||
|
+from trytond.modules.product import price_digits
|
||
|
|
||
|
__all__ = ['Configuration', 'ConfigurationLandedCostSequence',
|
||
|
'LandedCost', 'LandedCost_Shipment', 'InvoiceLine']
|
||
|
|
||
|
|
||
|
+def round_price(value, rounding=None):
|
||
|
+ "Round price using the price digits"
|
||
|
+ return value.quantize(
|
||
|
+ Decimal(1) / 10 ** price_digits[1], rounding=rounding)
|
||
|
+
|
||
|
+
|
||
|
class Configuration(metaclass=PoolMeta):
|
||
|
__name__ = 'account.configuration'
|
||
|
landed_cost_sequence = fields.MultiValue(fields.Many2One(
|
||
|
@@ -244,8 +251,8 @@ class LandedCost(Workflow, ModelSQL, ModelView):
|
||
|
for move in moves:
|
||
|
quantity = Decimal(str(move.quantity))
|
||
|
move_cost = cost * factors[move.id]
|
||
|
- unit_landed_cost = (move_cost / quantity).quantize(exp,
|
||
|
- rounding=ROUND_DOWN)
|
||
|
+ unit_landed_cost = round_price(
|
||
|
+ move_cost / quantity, rounding=ROUND_DOWN)
|
||
|
costs.append({
|
||
|
'unit_landed_cost': unit_landed_cost,
|
||
|
'difference': move_cost - (unit_landed_cost * quantity),
|
||
|
@@ -267,8 +274,8 @@ class LandedCost(Workflow, ModelSQL, ModelView):
|
||
|
unit_landed_cost = Currency.compute(
|
||
|
currency, cost['unit_landed_cost'],
|
||
|
move.currency, round=False)
|
||
|
- unit_landed_cost = unit_landed_cost.quantize(
|
||
|
- exp, rounding=ROUND_HALF_EVEN)
|
||
|
+ unit_landed_cost = round_price(
|
||
|
+ unit_landed_cost, rounding=ROUND_HALF_EVEN)
|
||
|
if move.unit_landed_cost is None:
|
||
|
move.unit_landed_cost = 0
|
||
|
move.unit_price += unit_landed_cost
|