Reputation: 611
I have inherited 'account.bank.statement' module. I need to add an extra field inside 'Transactions' tab.
class account_bank_statement(models.Model):
_inherit = 'account.bank.statement'
extra_info = fields.Char(string="Extra info")
<record id="view_bank_statement_form" model="ir.ui.view">
<field name="name">account.bank.statement.form</field>
<field name="model">account.bank.statement</field>
<field name="inherit_id" ref="account.view_bank_statement_form"/>
<field name="mode">extension</field>
<field name="arch" type="xml">
<xpath expr="/form/sheet/notebook/page[1]/field[@name='line_ids']/tree/field[@name='date']" position="after">
<field name="extra_info"/>
</xpath>
</field>
</record>
But , I got this error :
"ValueError: Field `extra_info` does not exist
Error context:
View `account.bank.statement.form`
[view_id: 1043, xml_id: bank_statement_upload.view_bank_statement_form, model: account.bank.statement, parent_id: 639]
Can someone help me please?
Upvotes: 1
Views: 858
Reputation: 372
Please be informed that you need to add an extra field in transaction tab, which is account.bank.statement.line
model.
So please try to inherit account.bank.statement.line
model instead of account.bank.statement. This will rectify your error.
Upvotes: 1
Reputation: 2444
Added dependency in 'depends' : ['account'] in manifest file. And change your mode to _inherit = 'account.bank.statement.line'
And you reduce your XPath like,
<xpath expr="//field[@name='line_ids']//field[@name='date']" position="after">
<field name="extra_info"/>
<xpath>
Update your app.
Thanks
Upvotes: 1
Reputation: 2018
in file.py
class account_bank_statement_line(models.Model):
_inherit = 'account.bank.statement.line'
extra_info = fields.Char(string="Extra info")
Because you are adding info field in line_ids
Upvotes: 2