Odoo Help

1

hi i want to add a field on sale order could you help thanks

By
odoouser
on 1/16/15, 5:26 AM 672 views

<?xml version="1.0" encoding="utf-8" ?>
<openerp>
 <data>
 <record id="view_order_form" model="ir.ui.view">
  <field name="name">sale.order.form.Mine</field>
  <field name="model">sale.order</field>
 <field name="inherit_id" ref="sale.view_order_form">
 <field name="arch" type="xml">
<xpath expr="/form/sheet/group/group[2]/field[@name='date_order']" position="after">
  <field name="date_edition" />
  <field name="type_annonce" />
  </xpath>
  </field>
  </field>
  </record>
  </data>
</openerp>

I recieve arch: Invalid XML for View Architecture!

1

Ivan

--Ivan--
3255
| 5 3 6
Jakarta, Indonesia
--Ivan--
Ivan
On 1/16/15, 6:17 AM

inherit_id field should not contain anything else : <field name="inherit_id" ref="sale.view_order_form"/> and then remove one of the </field> tag after </xpath>.

1
abin c ibrahim
On 1/16/15, 6:26 AM

Hi Azzaly,

For adding a field you first create a field in the corresponding class.

Here you have 2 fields named date_edition & type_annonce.These 2 fields should be defined in the model sale.order as following,

'date_edition':fields.datetime('Date of Edition'),

'type_annonce':fields.char(Announce'),

Under this you should add a new field,

for example to add a field 'published_by' you should code as,

'published_by':fields.char(Published By'),

Then you can add the field in xml as foolows,

  <field name="published_by" />

After that upgrade the sale module...

Hope it helps....

 

0
odoouser
On 1/16/15, 6:21 AM

it works  :D thanks a lot  Ivan

0
Kazim Mirza
On 1/16/15, 6:31 AM

Hello Azzaly

You cann simply use the inherit form view like below.

<record model="ir.ui.view" id="view_order_form_inherit"> #record id of xml is always unique.
            <field name="name">sale.order.form.Mine</field>
            <field name="model">sale.order</field>
            <field name="inherit_id" ref="sale.view_order_form"/>
            <field name="arch" type="xml">
                <field name="date_order" position="before">
                       <field name="date_edition" />
                       <field name="type_annonce" />
                </field>
            </field>
        </record>

XPATH is used when the reference field is inside the one2many <from><tree> views.

LIke, 

<data_ids>

   <tree>

           <field name="name"/> #if you want to add new field or replace this field so you need xpath because its inside the inline tree view#

   </tree>

<form>

           <field name="name"/>#if you want to add new field or replace this field so you need xpath because its inside the inline form view#

</form>

</data_ids>

Hope that this answer will help you.

Please don't hesitate to ask any question regarding this.

Thank You

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Register

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)

Stats

Asked: 1/16/15, 5:26 AM
Seen: 672 times
Last updated: 11/4/15, 5:08 AM