from odoo import models, api, fields class AccountMoveLine(models.Model): _inherit = "account.move.line" cost_centre_id = fields.Many2one('cost.centre', string='Cost Centre') is_required = fields.Boolean(string='Is Required', compute='_compute_is_required') @api.onchange('account_id') def _compute_is_required(self): for account in self: if account.account_id.code and account.account_id.code[0] in ['6', '7']: account.is_required = True else: account.is_required = False @api.onchange('account_id') def _onchange_cost_centre_id(self): for account in self: cost_centre = account.account_id.cost_centre_id account.cost_centre_id = cost_centre