Skip to content

Commit

Permalink
[FIX] sale_mrp: ensure do not fail in case no bom is found
Browse files Browse the repository at this point in the history
  • Loading branch information
AaronHForgeFlow committed Aug 1, 2023
1 parent d655c80 commit ca9c4f6
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions addons/sale_mrp/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ def _stock_account_get_anglo_saxon_price_unit(self):
# is not found).
# The fix is giving preference to the bom of the sale line
boms = so_line.move_ids.filtered(lambda m: m.state != 'cancel').mapped('bom_line_id.bom_id').filtered(lambda b: b.type == 'phantom')
bom = (boms or self.env['mrp.bom']._bom_find(product=so_line.product_id, company_id=so_line.company_id.id, bom_type='phantom'))[:1]
if bom:
boms2 = (boms or self.env['mrp.bom']._bom_find(product=so_line.product_id, company_id=so_line.company_id.id, bom_type='phantom'))
if boms2:
bom = boms2[:1]
is_line_reversing = bool(self.move_id.reversed_entry_id)
qty_to_invoice = self.product_uom_id._compute_quantity(self.quantity, self.product_id.uom_id)
posted_invoice_lines = so_line.invoice_lines.filtered(lambda l: l.move_id.state == 'posted' and bool(l.move_id.reversed_entry_id) == is_line_reversing)
Expand Down

0 comments on commit ca9c4f6

Please sign in to comment.