如何在odoo 9中覆盖/替换base中的相​​关字段

时间:2017-03-18 13:20:35

标签: override odoo-9 account

现有字段(基本插件):

journal_id = fields.Many2one('account.journal', related='statement_id.journal_id', string='Journal', store=True, readonly=True)

New Field(custom addons):

journal_id = fields.Many2one('account.journal',string='Journal')

我想将现有字段更改为新字段,如上例所示。

2 个答案:

答案 0 :(得分:0)

您需要使用从要覆盖的模型继承的模型创建新的插件。然后根据需要定义字段。

class YourModel(models.Model):
    _inherit = 'other.model'

    journal_id = fields.Many2one('account.journal',string='Journal')

答案 1 :(得分:0)

试试这段代码......

journal_id = fields.Many2one('account.journal', 

related='statement_id.journal_id', string='Journal', store=True, readonly=True)

New Field(custom addons):

journal_id = fields.Many2one('account.journal',string='Journal',related=False,store=False, readonly=False)