Odoo Help

0
2
Niyas Raphy
On 2/13/18, 10:14 PM

Hi,

To add a new field you can  inherit the form and add a new field using xpath.

In Python :

First of all you have to inherit the model and add the  field to corresponding  model

from odoo import models, fields

class NameForClass(models.Model):
_inherit = "model_name"

new_field_name = fields.Char(string="Cost")

In XML:

<record id="give_an_id_for_record" model="ir.ui.view">  
<field name="name">a_name_here</field>
<field name="model">model_name</field>
<field name="inherit_id" ref="external_id_of_original_view"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='name_of_existing_field']" position="after">
             <field name="new_field_name"/>
</xpath>

</field>
</record>

Have a look at this video too : Additional field to existing view in odoo 10

Thanks

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 2/13/18, 11:18 AM
Seen: 420 times
Last updated: 2/18/18, 1:54 AM