This question has been flagged

Hey! i was able to achieve this in 11 and 12 version but in 13 version they have made a big change of combining the model of invoice and journal entry. Because of which all you have is account.move and code has changed quite alot. This is what i have tried so far to get multiple asset based on quantity . In the log it shows multiple lines but m unable to create it.  Here is the code

for move_line in move.invoice_line_ids:
if move_line.account_id and (move_line.account_id.can_create_asset) and move_line.account_id.create_asset != 'no' and not move.reversed_entry_id:
if not move_line.name:
raise UserError(_('Journal Items of {account} should have a label in order to generate an asset').format(account=move_line.account_id.display_name))
for x in numpy.arange(move_line.quantity):
print(move_line.quantity)
print(move_line.name)
print(move_line.price_subtotal / move_line.quantity)
vals = {
'name': move_line.name,
'original_value': move_line.price_subtotal / move_line.quantity,
'company_id': move_line.company_id.id,
'currency_id': move_line.company_currency_id.id,
'original_move_line_ids': [(6, False, move_line.ids)],
'state': 'draft',
}
model_id = move_line.account_id.asset_model
if model_id:
vals.update({
'model_id': model_id.id,
})
auto_validate.append(move_line.account_id.create_asset == 'validate')
invoice_list.append(move)
create_list.append(vals)

assets = self.env['account.asset'].with_context(mail_create_nosubscribe=True).create(create_list)

Kindly have a look.

Avatar
Discard