Cédric Krier pushed to branch branch/default at Tryton / Tryton
Commits:
2a6561df by Òscar Queraltó Aguilera at 2023-02-24T12:09:39+00:00
Ignore cancelled moves to calculate productions cost
Closes #12093
- - - - -
1 changed file:
- modules/production/production.py
Changes:
=====================================
modules/production/production.py
=====================================
@@ -454,6 +454,8 @@
def get_cost(self, name):
cost = Decimal(0)
for input_ in self.inputs:
+ if input_.state == 'cancelled':
+ continue
if input_.cost_price is not None:
cost_price = input_.cost_price
else:
@@ -472,7 +474,8 @@
for input_ in self.inputs:
if (input_.product is None
or input_.uom is None
- or input_.quantity is None):
+ or input_.quantity is None
+ or input_.state == 'cancelled'):
continue
product = input_.product
quantity = Uom.compute_qty(input_.uom, input_.quantity,
@@ -551,6 +554,8 @@
input_quantities = defaultdict(Decimal)
input_costs = defaultdict(Decimal)
for input_ in production.inputs:
+ if input_.state == 'cancelled':
+ continue
if input_.cost_price is not None:
cost_price = input_.cost_price
else:
@@ -561,7 +566,8 @@
Decimal(str(input_.internal_quantity)) * cost_price)
outputs = []
for output in production.outputs:
- if output.to_location.type == 'lost_found':
+ if (output.to_location.type == 'lost_found'
+ or output.state == 'cancelled'):
continue
product = output.product
if input_quantities.get(output.product):
View it on Heptapod:
https://foss.heptapod.net/tryton/tryton/-/commit/2a6561df7ef67b695c947ee242e1af1960f12fa6
--
View it on Heptapod:
https://foss.heptapod.net/tryton/tryton/-/commit/2a6561df7ef67b695c947ee242e1af1960f12fa6
You're receiving this email because of your account on foss.heptapod.net.