refactor: update asset code generation logic to iterate over all stock move lines instead of only those without packages
This commit is contained in:
parent
09e2125615
commit
47e67b8c10
@ -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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user