Hi.
This is a very strange behaviour. Let me explain.
I need to add a fied to invoice form. To do that
1) I've created custom module to inherit account.invoice and added the field
2) I've created a view and inherited account.form_view
3) I've inserted the new field in the new view.
Stange behaviour:
If I put the field in the main body (not into a notebook element) of th invoice, all works fine. If I insert the field after invoice's secodary field (in my case this secondary field is "name" inside "Other info" notebook), a "field does not exist" error arises.
My model:
class InvoiceInherit (models.Model):
_inherit = 'account.invoice'
ref2 = fields.Char(string='Reference2',readonly=True, states={'draft': [('readonly', False)]}, copy=False, help='It will appear in invoice doc under "Client order''s date')
My view ("invoice_form_ref2"):
<?xml version="1.0" encoding="UTF-8"?> <odoo> <record id="view_partner_form_id" model="ir.ui.view"> <field name="model">res.partner</field> <field name="inherit_id" ref="base.view_partner_form"/> <field name="arch" type="xml"> <field name="ref" position="after"> <field name="provider_id" placeholder="Provider ID"/> </field> </field> </record> <record id="invoice_form_ref2" model="ir.ui.view"> <field name="model">account.invoice</field> <field name="inherit_id" ref="account.invoice_form"/> <field name="arch" type="xml"> <field name="name" position="after"> <-- with this, raise an "field ref2 does not exist" error on update module <field name="ref2"/> </field> </field> </record> </odoo>
if I use
<field name="payment_term_id" position="after">
All things work fine.
Please, note that both fields "name" and "payment_term_id" exists into account.invoce but are rendered in different positions:
"payment_term_id" is redered in the "main" invoice body, but
"name" is rendered inside "other info" notebook.
Thank yu for your help