跳至內容
選單
此問題已被標幟

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
頭像
捨棄
作者

move_id* not mode id

相關帖文 回覆 瀏覽次數 活動
1
8月 20
3365
2
9月 25
4918
0
10月 23
1651
1
7月 23
5215
1
2月 22
5737