Skip to content

Commit

Permalink
Merge pull request #244 from agaldona/8.0-mrp_production_real_cost
Browse files Browse the repository at this point in the history
[8.0][FIX] mrp_production_real_cost: calculate of unit cost taking into account real produced quantity
  • Loading branch information
StefanRijnhart authored Jan 31, 2018
2 parents b8dd201 + 3443879 commit ac9d5c3
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions mrp_production_real_cost/models/mrp_production.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,12 @@ def _compute_real_cost(self):
cost_lines = production.analytic_line_ids.filtered(
lambda l: l.amount < 0)
production.real_cost = -sum(cost_lines.mapped('amount'))
production.unit_real_cost = (
production.real_cost / production.product_qty)
something_done = production.move_created_ids2.filtered(
lambda x: x.state == 'done')
qty = (something_done and
sum(something_done.mapped('product_uom_qty')) or
production.product_qty)
production.unit_real_cost = (production.real_cost / qty)

analytic_line_ids = fields.One2many(
comodel_name="account.analytic.line", inverse_name="mrp_production_id",
Expand Down

0 comments on commit ac9d5c3

Please sign in to comment.