Skip to content

Commit

Permalink
[14.0][IMP] custom_mrp_line_cost: Resolve traceback. (#314)
Browse files Browse the repository at this point in the history
Co-authored-by: Tu Nombre <[email protected]>
  • Loading branch information
Berezi and Tu Nombre authored May 14, 2024
1 parent 571fe19 commit 8b62c76
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions custom_mrp_line_cost/models/stock_move_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,16 +150,19 @@ def _compute_base_price(self):
cost = line.move_id.byproduct_id.cost
if line.expense_kg:
entry_same_lots = (
line.production_id.move_line_ids.filtered(
lambda c: c.lot_id.name == line.lot_id.name
line.production_id.move_line_ids.filtered(
lambda c: c.lot_id.name == line.lot_id.name
)
)
)
entry_cost = sum(
entry_same_lots.mapped("amount")
)/sum(entry_same_lots.mapped("qty_done"))
cost = (
line.month_cost + entry_cost
) * (line.move_id.byproduct_id.coefficient)
if not entry_same_lots and sum(entry_same_lots.mapped("qty_done")) == 0:
cost = 0
else:
entry_cost = sum(
entry_same_lots.mapped("amount")
)/sum(entry_same_lots.mapped("qty_done"))
cost = (
line.month_cost + entry_cost
) * (line.move_id.byproduct_id.coefficient)
line.base_price = cost
if not line.applied_price:
line.applied_price = cost
Expand Down

0 comments on commit 8b62c76

Please sign in to comment.