Search code examples
odoo-8

add a custom field to existing tree view Odoo 8


I want to add one field call validator to customer invoice (account_invoice). openerp.py:

'depends': ['base','account'],

my model:

class account_invoice_validator(models.Model):
    _inherit = "account.invoice"

    validator = fields.Char()

my view:

<?xml version="1.0" encoding="UTF-8"?>

<openerp>
    <data>

<!-- Model: account.invoice -->
        <record id="view_account_invoice_customer_validator" model="ir.ui.view">
            <field name="model">account.invoice</field>
            <field name="inherit_id" ref="account.invoice_tree"/>
            <field name="arch" type="xml">
                <xpath expr="//field[@name='user_id']" position="after">
                    <field name="validator"/>
                </xpath>
            </field>
        </record>

    </data>
</openerp>

the validator column was added to database but i couldn't show it on the tree view (list). What do i miss?


Solution

  • Can you try like this?

    <record id="view_account_invoice_customer_validator" model="ir.ui.view">
                <field name="model">account.invoice</field>
                <field name="inherit_id" ref="account.invoice_tree"/>
                <field name="arch" type="xml">
                    <xpath expr="//tree/field[@name='user_id']" position="after">
                        <field name="validator"/>
                    </xpath>
                </field>
            </record>