From 47e67b8c1028073904bd91bab97c2f4cb612b79e Mon Sep 17 00:00:00 2001 From: Suherdy Yacob Date: Tue, 5 May 2026 14:39:57 +0700 Subject: [PATCH] refactor: update asset code generation logic to iterate over all stock move lines instead of only those without packages --- models/stock_picking.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/models/stock_picking.py b/models/stock_picking.py index ab696c4..a5a0e16 100644 --- a/models/stock_picking.py +++ b/models/stock_picking.py @@ -7,7 +7,7 @@ class StockPicking(models.Model): def action_generate_asset_codes(self): self.ensure_one() - for move in self.move_ids_without_package: + for move in self.move_ids: # Only generate if product creates asset (optional check, but good practice) # However, user wants to manually decide, so we generate for all lines that look like assets? # Let's assume user triggers this button for asset receipts. @@ -32,7 +32,7 @@ class StockPicking(models.Model): for pick in self: has_asset = False if pick.picking_type_code == 'incoming': - for move in pick.move_ids_without_package: + for move in pick.move_ids: # Check if product is configured to create assets # Logic: Check Product's Expense Account or Category's Expense Account account = move.product_id.property_account_expense_id or move.product_id.categ_id.property_account_expense_categ_id @@ -45,7 +45,7 @@ class StockPicking(models.Model): # Validation Check for pick in self: if pick.has_asset_moves: - for move in pick.move_ids_without_package: + for move in pick.move_ids: account = move.product_id.property_account_expense_id or move.product_id.categ_id.property_account_expense_categ_id if account and account.create_asset != 'no' and not move.asset_code: raise UserError(_( @@ -60,7 +60,7 @@ class StockPicking(models.Model): # After validation, create assets for moves with asset_code for pick in self: - for move in pick.move_ids_without_package: + for move in pick.move_ids: if move.asset_code and not move.asset_id: # Get Account to check configuration account = move.product_id.property_account_expense_id or move.product_id.categ_id.property_account_expense_categ_id