将自定义字段添加到现有树视图Odoo 8

时间:2016-10-27 06:54:02

标签: odoo-8

我想在客户发票(account_invoice)中添加一个字段调用验证器。 openerp.py:

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

我的模特:

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

    validator = fields.Char()

我的观点:

<?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>

验证器列已添加到数据库,但我无法在树视图(列表)中显示它。我错过了什么?

2 个答案:

答案 0 :(得分:2)

你能这样试试吗?

<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>

答案 1 :(得分:1)

试试这个:

<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>