mrp_average_cost: improve code perf
This commit is contained in:
@@ -252,9 +252,9 @@ class MrpProduction(models.Model):
|
|||||||
for order in self:
|
for order in self:
|
||||||
if order.product_id.cost_method == 'average':
|
if order.product_id.cost_method == 'average':
|
||||||
unit_cost = order.compute_order_unit_cost()
|
unit_cost = order.compute_order_unit_cost()
|
||||||
order.unit_cost = unit_cost
|
order.write({'unit_cost': unit_cost})
|
||||||
logger.info('MO %s: unit_cost=%s', order.name, unit_cost)
|
logger.info('MO %s: unit_cost=%s', order.name, unit_cost)
|
||||||
for finished_move in order.move_finished_ids.filtered(
|
order.move_finished_ids.filtered(
|
||||||
lambda x: x.product_id == order.product_id):
|
lambda x: x.product_id == order.product_id).write({
|
||||||
finished_move.price_unit = unit_cost
|
'price_unit': unit_cost})
|
||||||
return super(MrpProduction, self).post_inventory()
|
return super(MrpProduction, self).post_inventory()
|
||||||
|
|||||||
Reference in New Issue
Block a user