fix: partial receipt and refund of subcontracting purchases

This commit is contained in:
Christopher Ormaza
2023-03-23 11:24:14 -05:00
committed by BernatPForgeFlow
parent 493046c19e
commit f9e675f7fb
2 changed files with 16 additions and 1 deletions

View File

@@ -37,6 +37,19 @@ class StockMove(models.Model):
"is_subcontract": True,
}
)
# CHECK ME: Partial receipt of subcontracting process
# and refund change move_orig_ids adding all
# subcontracting origin moves, because
# that we try to restore and keep consistent data structure
# https://github.com/odoo/odoo/blob/b57c1332251b1553f98b9ad16b45a47d4101ffb2/addons/stock/wizard/stock_picking_return.py#L151-L153 # noqa: B950
if (
len(move.mapped("move_orig_ids.move_orig_ids.production_id")) > 1
and move.origin_returned_move_id
and move.origin_returned_move_id.id in move.move_orig_ids.ids
):
move.write(
{"move_orig_ids": [(6, 0, move.origin_returned_move_id.ids)]}
)
move_to_not_merge |= move
for picking, subcontract_details in subcontract_details_per_picking.items():
picking._subcontracted_produce_unbuild(subcontract_details)

View File

@@ -15,7 +15,9 @@ class StockPicking(models.Model):
def _prepare_subcontract_unbuild_vals(self, subcontract_move, bom):
subcontract_move.ensure_one()
product = subcontract_move.product_id
mos = subcontract_move.mapped("move_orig_ids.move_orig_ids.production_id")
mos = subcontract_move.mapped(
"origin_returned_move_id.move_orig_ids.production_id"
)
if len(mos) > 1:
raise UserError(
_(