Skip to Content
Menu
This question has been flagged

Hey i am trying to create a move line based on analytic account distribution like if the first line added by me has an analytic tag with a check box of analytic distribution marked true. I am confused in write or new method. Kindly help me with this

@api.onchange('analytic_tag_ids')
def analytic_account(self):
for rec in self:
if rec.analytic_tag_ids:
for record in rec.analytic_tag_ids.analytic_distribution_ids:
self.analytic_account_id = record.account_id
self.price_subtotal = (rec.price_subtotal * record.percentage) / 100
create_method = self.env['account.move.line'].create or self.env['account.move.line'].new
inv_line = create_method({
'name': self.name,
'move_id': self.id,
'account_id': rec.account_id.id,
'analytic_tag_ids': rec.analytic_tag_ids,
'analytic_account_id': rec.analytic_account_id.id
})
return inv_line

else:
self.analytic_account_id = False

Right now i am getting mode id error but i dont think i am still doing right. Kindly help
Avatar
Discard
Author

move_id* not mode id

Related Posts Replies Views Activity
1
Aug 20
2280
0
Oct 23
300
1
Jul 23
2543
1
Mar 23
2240
1
Feb 22
4536