Skip to Content
Menu
This question has been flagged
1410 Views

how to make field become auto fill when i create new record from BankAccount field to AccountJournal field.

`

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

    acc_number = fields.Char(string="Account Number", required=True)
    bank_id = fields.Many2one('res.bank', string="Bank")
    bank_bic = fields.Char(string="Bank Identifier Code")
    company_id = fields.Many2one('res.company', string="Company", default=lambda self: self.env.user.company_id.id)
    branch_id = fields.Many2one('res.branch', string="Branch")

class AccountJournal(models.Model):
    _inherit = "account.journal"

    name = fields.Char(string='Journal Name', required=True,
        tracking=True)

    company_partner_id = fields.Many2one('res.partner', related='company_id.partner_id', string='Account Holder', readonly=True, store=False)
    bank_account_id = fields.Many2one('res.partner.bank',
        string="Bank Account",
        ondelete='restrict', copy=False,
        check_company=True,
        domain="[('partner_id','=', company_partner_id), '|', ('company_id', '=', False), ('company_id', '=', company_id)]",
        tracking=True)
    company_id = fields.Many2one('res.company', string='Company', required=True, readonly=True, index=True, default=lambda self: self.env.company,
        help="Company related to this journal",
        tracking=True)
    bank_statements_source = fields.Selection(selection=_get_bank_statements_available_sources, string='Bank Feeds', default='undefined', help="Defines how the bank statements will be registered",
        tracking=True)``
    bank_acc_number = fields.Char(related='bank_account_id.acc_number', readonly=False,
        tracking=True)
    bank_id = fields.Many2one('res.bank', related='bank_account_id.bank_id', readonly=False,
        tracking=True)

`

when created new account 'acc_number' record auto filled into name field and company_id to company id

Avatar
Discard
Related Posts Replies Views Activity
1
May 24
1433
1
Apr 24
23247
2
Jan 23
23768
1
Nov 22
1403
2
Jul 22
1801