diff options
Diffstat (limited to 'indoteknik_custom/models/approval_unreserve.py')
| -rw-r--r-- | indoteknik_custom/models/approval_unreserve.py | 42 |
1 files changed, 22 insertions, 20 deletions
diff --git a/indoteknik_custom/models/approval_unreserve.py b/indoteknik_custom/models/approval_unreserve.py index 72e3ff51..00fd1555 100644 --- a/indoteknik_custom/models/approval_unreserve.py +++ b/indoteknik_custom/models/approval_unreserve.py @@ -86,28 +86,30 @@ class ApprovalUnreserve(models.Model): move = stock_move_obj.browse(line.move_id.id) move._do_unreserve(product=line.product_id, quantity=line.unreserve_qty) + line.dest_picking_id.action_assign() + # Step 2: Update existing stock move in dest_picking_id - if line.dest_picking_id: - dest_move = stock_move_obj.search([ - ('picking_id', '=', line.dest_picking_id.id), - ('product_id', '=', line.product_id.id), - ('state', 'not in', ['cancel', 'done']) # Only draft or assigned moves can be updated - ], limit=1) - - if dest_move: - # Add the unreserved quantity to the existing stock move - dest_move.write({ - 'product_uom_qty': dest_move.product_uom_qty + line.unreserve_qty - }) + # if line.dest_picking_id: + # dest_move = stock_move_obj.search([ + # ('picking_id', '=', line.dest_picking_id.id), + # ('product_id', '=', line.product_id.id), + # ('state', 'not in', ['cancel', 'done']) # Only draft or assigned moves can be updated + # ], limit=1) + + # if dest_move: + # # Add the unreserved quantity to the existing stock move + # dest_move.write({ + # 'product_uom_qty': dest_move.product_uom_qty + line.unreserve_qty + # }) - # If the move is in draft state, confirm it and reserve the product - if dest_move.state == 'draft': - dest_move._action_confirm() - dest_move._action_assign() # Reserve the product - - else: - # If no move is found, raise an error or handle accordingly - raise UserError(f"No stock move found for product {line.product_id.display_name} in the destination picking.") + # # If the move is in draft state, confirm it and reserve the product + # if dest_move.state == 'draft': + # dest_move._action_confirm() + # dest_move._action_assign() # Reserve the product + + # else: + # # If no move is found, raise an error or handle accordingly + # raise UserError(f"No stock move found for product {line.product_id.display_name} in the destination picking.") class ApprovalUnreserveLine(models.Model): _name = 'approval.unreserve.line' |
