in the following code i make a journal entry and the debit many2many
field when i add in many2many field one record it insert journal entry
when more than one field in many2many i get error
ValueError: Expected singleton: employee.rsomconf(1, 2, 3, 4)
the insert code is:
for rec in self:
debit = credit = rec.currency_id.compute(rec.rosom_id.mokabel_maly, rec.currency_id)
move = {
'name': '/',
'journal_id': rec.journal_id.id,
'date': rec.year,
'line_ids': [(0,0, {
'name': rec.name or '/',
'debit': debit,
'account_id': rec.rosom_id.journal.id,
'partner_id': rec.employee.user_id.partner_id.id,
}), (0,0 , {
'name': rec.name or '/',
'credit': credit,
'account_id': rec.recieve_account.id,
'partner_id': rec.employee.user_id.partner_id.id,
})]
}
move_id = self.env['account.move'].create(move)
move_id.post()
body =_("Rosom Paid")
subject = _("Rosom - %s") % (rec.name,)
rec.message_post(body=body, subject=subject,message_type="notification", subtype="mail.mt_comment",)
return rec.write({ 'state': 'paid','move_id': move_id.id})
Hello Ali,
Yes I was right;
rosom_id is a many2many type field;
You need to replace this line
rec.rosom_id.journal.id
With
rec.rosom_id[0].journal.id ;Make sure this line should be wrapped inside
if rec. rosom_id Condition; in order to avoid none type exception
or need to find the other way to set account_id in debit line
Thanks