Skip to Content
Menu
This question has been flagged
2 Replies
2350 Views

Hi, 

i'm working to customize the page of "Sale Order". 

I need to hide a field: this have as code "template_id".

I use this code to replace the field

<record model="ir.ui.view" id="sale_mod2_view_order_form">
            <field name="name">sale.order.form.inherit</field>
            <field name="model">sale.order</field>
            <field name="inherit_id" ref="sale.view_order_form" />
            <field name="arch" type="xml">
                <xpath
                    expr="//field[@name='x_TIPO_ORDINE_IQ']"
                    position="before">
                    <field name="mandante"/>
                </xpath>

                <xpath
                    expr="//field[@name='pricelist_id']"
                    position="replace">
                </xpath>
                
                <xpath
                    expr="//field[@name='template_id']"
                    position="replace">
                </xpath>

            </field>
          </record>

When i Install the app, i recevice the follow error :


2017-08-02 17:10:29,566 12844 INFO sm_pro openerp.modules.loading: 1 modules loaded in 0.02s, 0 queries
2017-08-02 17:10:30,303 12844 INFO sm_pro openerp.modules.loading: loading 128 modules...
2017-08-02 17:10:33,224 12844 INFO sm_pro openerp.modules.module: module ordini_lavorazione: creating or updating database tables
2017-08-02 17:10:33,344 12844 INFO sm_pro openerp.modules.loading: loading ordini_lavorazione/views/ordine_spedizione.xml
2017-08-02 17:10:33,457 12844 ERROR sm_pro openerp.addons.base.ir.ir_ui_view: L'elemento '<xpath expr="//field[@name='template_id']">' non può esser localizzato nella vista genitore

Error context:
View `sale.order.form.inherit`
[view_id: 1893, xml_id: ordini_lavorazione.sale_mod2_view_order_form, model: sale.order, parent_id: 648]
2017-08-02 17:10:33,459 12844 ERROR sm_pro openerp.http: Exception during JSON request handling.
Traceback (most recent call last):
  File "/opt/odoo/openerp/http.py", line 539, in _handle_exception
    return super(JsonRequest, self)._handle_exception(exception)
  File "/opt/odoo/openerp/http.py", line 576, in dispatch
    result = self._call_function(**self.params)
  File "/opt/odoo/openerp/http.py", line 312, in _call_function
    return checked_call(self.db, *args, **kwargs)
  File "/opt/odoo/openerp/service/model.py", line 118, in wrapper
    return f(dbname, *args, **kwargs)
  File "/opt/odoo/openerp/http.py", line 309, in checked_call
    return self.endpoint(*a, **kw)
  File "/opt/odoo/openerp/http.py", line 805, in __call__
    return self.method(*args, **kw)
  File "/opt/odoo/openerp/http.py", line 405, in response_wrap
    response = f(*args, **kw)
  File "/usr/lib/python2.7/site-packages/odoo-8.0.post20160413-py2.7.egg/openerp/addons/web/controllers/main.py", line 948, in call_button
    action = self._call_kw(model, method, args, {})
  File "/usr/lib/python2.7/site-packages/odoo-8.0.post20160413-py2.7.egg/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 "/opt/odoo/openerp/api.py", line 268, in wrapper
    return old_api(self, *args, **kwargs)
  File "/usr/lib/python2.7/site-packages/odoo-8.0.post20160413-py2.7.egg/openerp/addons/base/module/module.py", line 534, in button_immediate_upgrade
    return self._button_immediate_function(cr, uid, ids, self.button_upgrade, context=context)
  File "/opt/odoo/openerp/api.py", line 268, in wrapper
    return old_api(self, *args, **kwargs)
  File "/usr/lib/python2.7/site-packages/odoo-8.0.post20160413-py2.7.egg/openerp/addons/base/module/module.py", line 495, in _button_immediate_function
    registry = openerp.modules.registry.RegistryManager.new(cr.dbname, update_module=True)
  File "/opt/odoo/openerp/modules/registry.py", line 370, in new
    openerp.modules.load_modules(registry._db, force_demo, status, update_module)
  File "/opt/odoo/openerp/modules/loading.py", line 351, in load_modules
    force, status, report, loaded_modules, update_module)
  File "/opt/odoo/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 "/opt/odoo/openerp/modules/loading.py", line 176, in load_module_graph
    _load_data(cr, module_name, idref, mode, kind='data')
  File "/opt/odoo/openerp/modules/loading.py", line 118, in _load_data
    tools.convert_file(cr, module_name, filename, idref, mode, noupdate, kind, report)
  File "/opt/odoo/openerp/tools/convert.py", line 900, in convert_file
    convert_xml_import(cr, module, fp, idref, mode, noupdate, report)
  File "/opt/odoo/openerp/tools/convert.py", line 986, in convert_xml_import
    obj.parse(doc.getroot(), mode=mode)
  File "/opt/odoo/openerp/tools/convert.py", line 852, in parse
    self._tags[rec.tag](self.cr, rec, n, mode=mode)
  File "/opt/odoo/openerp/tools/convert.py", line 762, in _tag_record
    id = self.pool['ir.model.data']._update(cr, self.uid, rec_model, self.module, res, rec_id or False, not self.isnoupdate(data_node), noupdate=self.isnoupdate(data_node), mode=self.mode, context=rec_context )
  File "/opt/odoo/openerp/api.py", line 268, in wrapper
    return old_api(self, *args, **kwargs)
  File "/usr/lib/python2.7/site-packages/odoo-8.0.post20160413-py2.7.egg/openerp/addons/base/ir/ir_model.py", line 1019, in _update
    model_obj.write(cr, uid, [res_id], values, context=context)
  File "/opt/odoo/openerp/api.py", line 268, in wrapper
    return old_api(self, *args, **kwargs)
  File "/usr/lib/python2.7/site-packages/odoo-8.0.post20160413-py2.7.egg/openerp/addons/base/ir/ir_ui_view.py", line 273, in write
    context)
  File "/opt/odoo/openerp/api.py", line 268, in wrapper
    return old_api(self, *args, **kwargs)
  File "/opt/odoo/openerp/api.py", line 399, in old_api
    result = method(recs, *args, **kwargs)
  File "/opt/odoo/openerp/models.py", line 3788, in write
    self._write(old_vals)
  File "/opt/odoo/openerp/api.py", line 266, in wrapper
    return new_api(self, *args, **kwargs)
  File "/opt/odoo/openerp/api.py", line 592, in new_api
    result = method(self._model, cr, uid, self.ids, *args, **old_kwargs)
  File "/opt/odoo/openerp/models.py", line 3960, in _write
    recs._validate_fields(vals)
  File "/opt/odoo/openerp/api.py", line 266, in wrapper
    return new_api(self, *args, **kwargs)
  File "/opt/odoo/openerp/models.py", line 1271, in _validate_fields
    raise ValidationError('\n'.join(errors))
ParseError: "ValidateError
Field(s) `arch` failed against a constraint: Invalid view definition

Dettagli dell'Errore:
L'elemento '<xpath expr="//field[@name='template_id']">' non può esser localizzato nella vista genitore

Error context:
View `sale.order.form.inherit`
[view_id: 1893, xml_id: ordini_lavorazione.sale_mod2_view_order_form, model: sale.order, parent_id: 648]" while parsing /home/odoo/custom/addons/ordini_lavorazione/views/ordine_spedizione.xml:32, near
<record model="ir.ui.view" id="sale_mod2_view_order_form">
            <field name="name">sale.order.form.inherit</field>
            <field name="model">sale.order</field>
            <field name="inherit_id" ref="sale.view_order_form"/>
            <field name="arch" type="xml">
                <data><xpath expr="//field[@name='x_TIPO_ORDINE_IQ']" position="before">
                    <field name="mandante"/>
                </xpath>

                <xpath expr="//field[@name='pricelist_id']" position="replace">
                </xpath>
                
                <xpath expr="//field[@name='template_id']" position="replace">
                </xpath>

            </data></field>
          </record>
2017-08-02 17:10:33,470 12844 INFO sm_pro werkzeug: 127.0.0.1 - - [02/Aug/2017 17:10:33] "POST /web/dataset/call_button HTTP/1.1" 200 -



Anyone help me ? 

Avatar
Discard
Author Best Answer

Hi, 

i used your code but not working. 

this is the code and the error: 

<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data>
  
        <record id="sale_mod2_view_order_tree" model="ir.ui.view">
            <field name="name">sale.mod2.view.order.tree</field>
            <field name="model">sale.order</field>
	    	<field name="inherit_id" ref="sale.view_order_tree"/>
            <field name="arch" type="xml">
				 <field name="date_order" position="replace">
				 	<field name="create_date"/>
                 </field>
                 <field name="user_id" position="replace">
                 </field>
                 
                 <field name="create_date" position="replace">
				 	<field name="date_order"/>
                 </field>
                 <field name="state" position="after">
                 	<field name="canale_vendita"/>
                 </field>              
            </field>
        </record>
		<record id="action_load_form7" model="ir.actions.act_window">
            <field name="name">Ordini di spedizione</field>
            <field name="res_model">sale.order</field>
            <field name="view_type">form</field>
            <field name="view_mode">tree,form</field>      
            <field name="view_id" ref="sale_mod2_view_order_tree"/>
        </record>
        
        <record model="ir.ui.view" id="sale_mod2_view_order_form">
            <field name="name">sale.order.form.inherit</field>
            <field name="model">sale.order</field>
            <field name="inherit_id" ref="sale.view_order_form" />
            <field name="arch" type="xml">
                <xpath
                    expr="//field[@name='x_TIPO_ORDINE_IQ']"
                    position="before">
                    <field name="mandante"/>
                </xpath>

            </field>
        </record>
		<record model="ir.ui.view" id="sale_order_form_quote_inherit">
		    <field name="name">sale.order.form.payment.inherit</field>
		    <field name="model">sale.order</field>
		    <field name="inherit_id" ref="website_quote.sale_order_form_quote"/>
		    <field name="arch" type="xml">
		        <xpath expr="//field[@name='template_id']" position="attributes">
		            <attribute name="invisible">1</attribute>
		        </xpath>
		    </field>     
		</record>
          
        
 
       
		<!-- Top level menu: no parent -->
        <menuitem id="main_data_menu_1" name="Ordini di lavorazione"/>
        
        <!-- A first level in the left side menu is needed before using action -->
        <menuitem id="data_group_menu_1" name="Ordini di lavorazione" parent="main_data_menu_1"/>

        <!-- A first action in the left side menu is "data loading" -->

		<menuitem id="load_menu_mainform7" name="Ordini di lavorazione" parent="data_group_menu_1" sequence="6" action="action_load_form7"/>
		
		
    </data>
</openerp>
  File "/opt/odoo/openerp/api.py", line 508, in new_api
    result = method(self._model, cr, uid, *args, **old_kwargs)
  File "/opt/odoo/openerp/models.py", line 4284, in _create
    recs._validate_fields(vals)
  File "/opt/odoo/openerp/api.py", line 266, in wrapper
    return new_api(self, *args, **kwargs)
  File "/opt/odoo/openerp/models.py", line 1271, in _validate_fields
    raise ValidationError('\n'.join(errors))
ParseError: "ValidateError
Field(s) `arch` failed against a constraint: Invalid view definition

Dettagli dell'Errore:
Field `price_unit` does not exist

Error context:
View `sale.order.form.payment.inherit`
[view_id: 1914, xml_id: n/d, model: sale.order, parent_id: 1053]" while parsing /home/odoo/custom/addons/ordini_lavorazione/views/ordine_spedizione.xml:45, near
<record model="ir.ui.view" id="sale_order_form_quote_inherit">
   <field name="name">sale.order.form.payment.inherit</field>
   <field name="model">sale.order</field>
   <field name="inherit_id" ref="website_quote.sale_order_form_quote"/>
   <field name="arch" type="xml">
       <xpath expr="//field[@name='template_id']" position="attributes">
           <attribute name="invisible">1</attribute>
       </xpath>
   </field>     
</record>
2017-08-10 10:07:10,302 4139 INFO sm_pro openerp.modules.loading: loading 1 modules...
2017-08-10 10:07:10,317 4139 INFO sm_pro openerp.modules.loading: 1 modules loaded in 0.
Avatar
Discard

Why did you put all the code?

I think your need can be satisfied with my code.

Just Try.

Author

I maked a only file .xml but I receive the same error.

Thanks for the help.

I must study another solution.

:(

Best Answer

Hi ,

You can't do that.

template_id field is coming from website_quote module. so you have to inherit the view of that module.
 

Try this code.

<record model="ir.ui.view" id="sale_order_form_quote_inherit">
<field name="name">sale.order.form.payment.inherit</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="website_quote.sale_order_form_quote"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='template_id']" position="attributes">
<attribute name="invisible">1</attribute>
</xpath>
</field>
</record>

Thank you.

Avatar
Discard
Related Posts Replies Views Activity
1
Apr 24
2044
3
Sep 24
236
0
Jan 24
38
2
Jan 23
1873
2
Oct 22
1924