i want to add an field in a view that exist in another module.
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Accounting
- Inventory
- PoS
- Project management
- MRP
This question has been flagged
Hi Inam,
This is done by creating a new module in which you add an XML file. In the XML file you add a record with an inherit_id which links to the original view. An example to inherit the form view from a product:
So what will this example do? It will inherit the product view from the module product and it will add a new field named 'your_new_field' right after the existing field 'sales_price'. The ref product.product_template_form_view links to the model product and searches for the view named 'product_template_form_view', which you can find here: https://github.com/odoo/odoo/blob/9.0/addons/product/product_view.xml#L69<?xml version="1.0" encoding="utf-8"?> <openerp> <data> <record id="view_product_form_inherit" model="ir.ui.view"> <field name="name">product.template.common.form.inherit</field> <field name="model">product.template</field> <field name="inherit_id" ref="product.product_template_form_view"/> <field name="arch" type="xml"> <xpath expr="//field[@name='sales_price']" position="after"> <field name="your_new_field"/> </xpath> </field> </record> </data> </openerp>
Yenthe
Hi, Yenthe
I have to add a new field in customer card under website field, like you told it i wrote this in xml file :
<?xml version="1.0"?>
<openerp>
<data>
<record id="view_partner_form_inherit" model="ir.ui.view" >
<field name="name">res.partner.form.inherit</field>
<field name="model">res.partner</field>
<field eval="1" name="priority"/>
<field name="inherit_id" ref="res.view_partner_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='website']" position="after">
<field name="new_field"/>
</xpath>
</field>
</record>
</data>
</openerp>
and this in the python file :
class childClasse(models.Model):
_inherit = 'res.partner.title'
field_1 = fields.Char(required=True,string="NVchamp")
but don't work :
raceback (most recent call last): File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 546, in _handle_exception return super(JsonRequest, self)._handle_exception(exception) File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 583, in dispatch result = self._call_function(**self.params) File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 319, in _call_function return checked_call(self.db, *args, **kwargs) File "/usr/lib/python2.7/dist-packages/openerp/service/model.py", line 118, in wrapper return f(dbname, *args, **kwargs) File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 316, in checked_call return self.endpoint(*a, **kw) File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 812, in __call__ return self.method(*args, **kw) File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 412, in response_wrap response = f(*args, **kw) File "/usr/lib/python2.7/dist-packages/openerp/addons/web/controllers/main.py", line 948, in call_button action = self._call_kw(model, method, args, {}) File "/usr/lib/python2.7/dist-packages/openerp/addons/web/controllers/main.py", line 936, in _call_kw return getattr(request.registry.get(model), method)(request.cr, request.uid, *args, **kwargs) File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 268, in wrapper return old_api(self, *args, **kwargs) File "/usr/lib/python2.7/dist-packages/openerp/addons/base/module/module.py", line 447, in button_immediate_install return self._button_immediate_function(cr, uid, ids, self.button_install, context=context) File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 268, in wrapper return old_api(self, *args, **kwargs) File "/usr/lib/python2.7/dist-packages/openerp/addons/base/module/module.py", line 495, in _button_immediate_function registry = openerp.modules.registry.RegistryManager.new(cr.dbname, update_module=True) File "/usr/lib/python2.7/dist-packages/openerp/modules/registry.py", line 370, in new openerp.modules.load_modules(registry._db, force_demo, status, update_module) File "/usr/lib/python2.7/dist-packages/openerp/modules/loading.py", line 355, in load_modules loaded_modules, update_module) File "/usr/lib/python2.7/dist-packages/openerp/modules/loading.py", line 255, in load_marked_modules loaded, processed = load_module_graph(cr, graph, progressdict, report=report, skip_modules=loaded_modules, perform_checks=perform_checks) File "/usr/lib/python2.7/dist-packages/openerp/modules/loading.py", line 176, in load_module_graph _load_data(cr, module_name, idref, mode, kind='data') File "/usr/lib/python2.7/dist-packages/openerp/modules/loading.py", line 118, in _load_data tools.convert_file(cr, module_name, filename, idref, mode, noupdate, kind, report) File "/usr/lib/python2.7/dist-packages/openerp/tools/convert.py", line 897, in convert_file convert_xml_import(cr, module, fp, idref, mode, noupdate, report) File "/usr/lib/python2.7/dist-packages/openerp/tools/convert.py", line 983, in convert_xml_import obj.parse(doc.getroot(), mode=mode) File "/usr/lib/python2.7/dist-packages/openerp/tools/convert.py", line 849, in parse self._tags[rec.tag](self.cr, rec, n, mode=mode) File "/usr/lib/python2.7/dist-packages/openerp/tools/convert.py", line 751, in _tag_record f_val = self.id_get(cr, f_ref) File "/usr/lib/python2.7/dist-packages/openerp/tools/convert.py", line 828, in id_get res = self.model_id_get(cr, id_str, raise_if_not_found) File "/usr/lib/python2.7/dist-packages/openerp/tools/convert.py", line 839, in model_id_get raise_if_not_found=raise_if_not_found) File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 268, in wrapper return old_api(self, *args, **kwargs) File "/usr/lib/python2.7/dist-packages/openerp/addons/base/ir/ir_model.py", line 909, in xmlid_to_res_model_res_id return self.xmlid_lookup(cr, uid, xmlid)[1:3] File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 268, in wrapper return old_api(self, *args, **kwargs) File "<decorator-gen-3>", line 2, in xmlid_lookup File "/usr/lib/python2.7/dist-packages/openerp/tools/cache.py", line 74, in lookup value = d[key] = self.method(*args, **kwargs) File "/usr/lib/python2.7/dist-packages/openerp/addons/base/ir/ir_model.py", line 899, in xmlid_lookup raise ValueError('External ID not found in the system: %s' % (xmlid)) ParseError: "External ID not found in the system: res.res_partner_view" while parsing /usr/lib/python2.7/dist-packages/openerp/addons/Field/Vue.xml:5, near <record id="view_partner_form_inherit" model="ir.ui.view"> <field name="name">res.partner.form.inherit</field> <field name="model">res.partner</field> <field eval="1" name="priority"/> <field name="inherit_id" ref="res.res_partner_view"/> <field name="arch" type="xml"> <xpath expr="//field[@name='website']" position="after"> <field name="new_field"/> </xpath> </field> </record>
Can you help me ?
Enjoying the discussion? Don't just read, join in!
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign upRelated Posts | Replies | Views | Activity | |
---|---|---|---|---|
|
1
May 23
|
1149 | ||
|
4
Aug 21
|
60821 | ||
|
0
Nov 20
|
4207 | ||
|
1
Jan 18
|
6075 | ||
|
3
Jan 17
|
13778 |
hope this will helps: https://learnopenerp.blogspot.com/2018/01/inheritance-in-models-and-views.html