1
votes

I want to add a field on odoo module.
I'm using odoo v8.

<openerp>
    <data>
        <record model="ir.ui.view" id="add_field_product_form">
            <field  name="name">add.field.product.form</field>
            # Name field (whatever)
            <field  name="model">product.template</field>
            # Parent object
            <field name="inherit_id" ref="product.product_template_only_form_view"/>
            # Parent View
            <field name="arch" type="xml">
                # Name field and Position (after)
                <xpath expr="//field[@name='type']"  position="after">
                    <field name="info"/>
                    # Your new Field
                </xpath>
            </field>
        </record>
    </data>
</openerp>

My class:

from openerp import models, fields

class AddFieldProduct(models.Model):  #  Name class
    _inherit = "product.template"  # Name parent object

    info = fields.Char('Info')

I have this error:

AssertionError: Did not expect text in element record content, line 3

1

1 Answers

0
votes

You have to comment with <!-- your comment --> in xml files instead of using python syntax:

<openerp>
    <data>
        <record model="ir.ui.view" id="add_field_product_form">
            <field  name="name">add.field.product.form</field>
            <!-- Name field (whatever) -->
            <field  name="model">product.template</field>
            <!-- Parent object -->
            <field name="inherit_id" ref="product.product_template_only_form_view"/>
            <!-- Parent View -->
            <field name="arch" type="xml">
                <!-- Name field and Position (after) -->
                <xpath expr="//field[@name='type']"  position="after">
                    <field name="info"/>
                    <!-- Your new Field -->
                </xpath>
            </field>
        </record>
    </data>
</openerp>