RandomPerson
RandomPerson

Reputation: 790

How to make a custom field appear

The purpose is to show a checkbox in an Invoice (Customer Invoice) over at the "Other Info" tab. There's a field "Journal Entry" (move_id) and it has to appear below that field.

So I've made a custom field that looks like this:

    _columns = {"xx_lawyer": fields.boolean("Lawyer")}

And then I've set up the xml which (in theory) should let the field appear:

        <record id="view_invoice_form_xx_lawyer" model="ir.ui.view">
        <field name="name">account.invoice.form</field>
        <field name="model">account.invoice</field>
        <field name="inherit_id" ref="account.invoice_form"/>
        <field name="arch" type="xml">
            <xpath expr="//field[@name='move_id']" position="after">
                <field name="xx_lawyer"/>
            </xpath>
        </field>
    </record>

Yet it doesn't show the field, I'm clueless as to what I'm doing wrong. I've also included the xml file in the openerp.py" file.

Any help would be much appreciated.

Upvotes: 0

Views: 55

Answers (1)

Bhavesh Odedra
Bhavesh Odedra

Reputation: 11143

In your case, their is no require use xapth. You may use field attribute.

Try with this code

<record id="view_invoice_form_xx_lawyer" model="ir.ui.view">
    <field name="name">view.invoice.form.xx.lawyer</field>
    <field name="model">account.invoice</field>
    <field name="inherit_id" ref="account.invoice_form" />
    <field name="arch" type="xml">
        <field name="move_id" position="after">
            <field name="xx_lawyer" />
        </field>
    </field>
</record>

Upvotes: 1

Related Questions