Skip to Content
Menu
This question has been flagged
1 Reply
1408 Views

I created form view for bank account and i want to make record from bank account automated inserted in bank journal view (journal.account) when its created

class BankAccount(models.Model):
_name = 'bank.account'
_description = "Bank Account"

bank_id = fields.Many2one('res.bank', string="Bank")
company_id = fields.Many2one('res.company', string="Company", default=lambda self: self.env.user.company_id.id)

thanks

Avatar
Discard
Best Answer

Hello, 

For this you can use following way:

1. Use default_get method

2. Add default method into M2O filed

I hope you're issue will be resolved. 

Thanks

Avatar
Discard
Author

when i create new bank account so it also created record in journal
did you know what's wrong with my code below ?
def create(self, vals):
res = super(AccountJournal, self).create()
for rec in self:
vals = {
'acc_number': rec.acc_number.id,
'bank_id': rec.bank_id.id,
'bank_bic': rec.bank_bic.id,
'company_id': rec.company_id.id,
'branch_id': rec.branch_id.id,
}
self.env['bank.account.account'].create(vals)
return res

Hello Deny,

This method added into journal object?

Related Posts Replies Views Activity
1
May 24
1434
1
Apr 24
23277
2
Jul 22
1808
2
Jul 22
1832
0
Jan 22
1512