This question has been flagged
2 Replies
7932 Views

Hello, I want to add a field (position_id) on supplier invoice form but I have a error. I paste my code bellow.

<?xml version="1.0" encoding="utf-8"?>
    <openerp>
        <data>
            <record id="account_supplier_invoice_extended" model="ir.ui.view">
                <field name="name">Supplier invoice extended</field>
                <field name="model">account.invoice</field>
                <field name="inherit_id" ref="account.invoice.supplier.form"/>
                <field name="arch" type="xml">
                    <field name="jurnal_id" position="before">
                        <field name="position_id"/>
                    </field>        
                </field>
            </record>
        </data>
    </openerp>
Avatar
Discard
Best Answer

Hi,

There are total two mistakes I can see :

  1. When you inherit the view, you are suppose to pass parent view id not parent view name. Here parent view id is invoice_supplier_form not account.invoice.supplier.form.
  2. The field name you have specified is wrong. In parent view field name is journal_id not jurnal_id.

So the proper way of inheriting the view is as follow:

    <record id="account_supplier_invoice_extended" model="ir.ui.view">
        <field name="name">Supplier invoice extended</field>
        <field name="model">account.invoice</field>
        <field name="inherit_id" ref="account.invoice_supplier_form"/>
        <field name="arch" type="xml">
            <field name="journal_id" position="before">
                <field name="position_id"/>
            </field>        
        </field>
    </record>

Thanks,
www.acespritech.com

Avatar
Discard
Author

Not working. I put ref="account.invoice_supplier_form". but I have next error : except_orm: ('ValidateError', u'Error occurred while validating the field(s) arch: Invalid XML for View Architecture!')

and <field name="journal_id" position="before"> instead <field name="jurnal_id" position="before">

Best Answer

Try with this:

<record id="account_supplier_invoice_extended" model="ir.ui.view">
    <field name="name">Supplier invoice extended</field>
    <field name="model">account.invoice</field>
    <field name="inherit_id" ref="account.invoice_supplier_form"/>
    <field name="arch" type="xml">
         <xpath expr="//field[@name='journal_id']" position="before">
            <field name="position_id"/>
         </xpath> 
    </field>
</record>

And add account to your dependencies

Avatar
Discard