In Odoo first, we create existing modules and then we inherits the views in modules. Like first, we install the accounting modules in database and then inherits the account modules. Object is the account.invoice in existing modules and if user wants to replace any fields after inheriting the views then he can do this by using xpath in modules. Xpath is very useful for views.
Exmaple:-
In your .py file use this code show below:
class account_invoice(osv.Model):
_inherit = 'account.invoice'
_columns = {
'yourfields': fields.char('yourfields', readonly="True"),
}
account_invoice()
In your .xml file use this code show below:
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="invoice_form" model="ir.ui.view">
<field name="name">account.invoice.form.inherit</field>
<field name="model">account.invoice</field>
<field name="inherit_id" ref="account.invoice_form" />
<field name="arch" type="xml">
<data>
<!--replace fields like as team_id in your account invoice form-->
<xpath expr="//field[@name='team_id']" position="replace">
</xpath>
<field name="quantity" position="after">
<field name="yourfields"/>
</field>
</data>
</field>
</record>
</data>
</openerp>
0 Comment(s)