diff --git a/issue9146.diff b/issue9146.diff new file mode 100644 index 0000000..43dfaf1 --- /dev/null +++ b/issue9146.diff @@ -0,0 +1,45 @@ +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 diff --git a/series b/series index bc8ea64..669abbc 100644 --- a/series +++ b/series @@ -95,3 +95,4 @@ account_asset_update_asset.diff # [account_asset] convert float to decimal [#044 issue10382.diff # [stock_split] Decimals of quantity move exceed the total digits when split move issue10338.diff # [bank] Search on rec_name of other model in search_rec_name +issue9146.diff # [account_stock_landed_cost] Use field digits on secondary unit