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

I want to delete the field "product_uom_qty"  but it does not work it does not give error

here is what I did

<?xml version="1.0" encoding="UTF-8"?>

<odoo>

<!-- Add instructor field to existing view -->

<record model="ir.ui.view" id="sale_order_form_view">

<field name="name">sale.instructor</field>

<field name="model">sale.order</field>

<field name="inherit_id" ref="sale.view_order_form"/>

<field name="arch" type="xml">

<field name="product_uom_qty" position="attributes">

<attribute name="invisible">True</attribute>

</field>

</field>

</record>

</odoo>

and in manifest I add

   # always loaded

'data': [

# 'security/ir.model.access.csv',

'views/views.xml',

'views/vente.xml',

],

Avatar
Discard
Best Answer

Hi,

If you are trying to remove the field Product_uom_qty from the sale order line, you can do it like this,

<record id="sale_order_inherit" model="ir.ui.view">    
    <field name="name">sale.order</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/notebook/page/field[@name='order_line']/tree/field[@name='product_uom_qty']" position="attributes">
            <attribute name="invisible">1</attribute>
        </xpath>
    </field>
</record>


Thanks

Avatar
Discard
Author Best Answer

it does not work, I have this error

Contexte de l'erreur :

Vue `sale.order`

[view_id: 1191, xml_id: n/a, model: sale.order, parent_id: 1130]


During handling of the above exception, another exception occurred:


Traceback (most recent call last):

  File "/opt/odoo/odoo/odoo/tools/convert.py", line 741, in parse

    self._tags[rec.tag](rec, de, mode=mode)

  File "/opt/odoo/odoo/odoo/tools/convert.py", line 651, in _tag_record

    id = self.env(context=rec_context)['ir.model.data']._update(rec_model, self.module, res, rec_id or False, not self.isnoupdate(data_node), noupdate=self.isnoupdate(data_node), mode=self.mode)

  File "/opt/odoo/odoo/odoo/addons/base/ir/ir_model.py", line 1469, in _update

    record = record.create(values)

  File "/opt/odoo/odoo/odoo/addons/base/ir/ir_ui_view.py", line 398, in create

    return super(View, self).create(self._compute_defaults(values))

  File "/opt/odoo/odoo/odoo/models.py", line 3356, in create

    self._fields[key].determine_inverse(record)

  File "/opt/odoo/odoo/odoo/fields.py", line 1070, in determine_inverse

    getattr(records, self.inverse)()

  File "/opt/odoo/odoo/odoo/addons/base/ir/ir_ui_view.py", line 266, in _inverse_arch

    view.write(data)

  File "/opt/odoo/odoo/odoo/addons/base/ir/ir_ui_view.py", line 414, in write

    return super(View, self).write(self._compute_defaults(vals))

  File "/opt/odoo/odoo/odoo/models.py", line 3065, in write

    self._write(old_vals)

  File "/opt/odoo/odoo/odoo/models.py", line 3231, in _write

    self._validate_fields(vals)

  File "/opt/odoo/odoo/odoo/models.py", line 1027, in _validate_fields

    raise ValidationError("%s\n\n%s" % (_("Error while validating constraint"), tools.ustr(e)))

odoo.exceptions.ValidationError: ('Erreur lors de la validation de la contrainte\n\nField \'product_uom_qty\' used in attributes must be present in view but is missing:\n - \'product_uom_qty\' in context="{\'partner_id\':parent.partner_id, \'quantity\':product_uom_qty, \'pricelist\':parent.pricelist_id, \'uom\':product_uom, \'company_id\': parent.company_id}"\n\nContexte de l\'erreur :\nVue `sale.order`\n[view_id: 1191, xml_id: n/a, model: sale.order, parent_id: 1130]', None)


During handling of the above exception, another exception occurred:


Traceback (most recent call last):

  File "/opt/odoo/odoo/odoo/http.py", line 650, in _handle_exception

    return super(JsonRequest, self)._handle_exception(exception)

  File "/opt/odoo/odoo/odoo/http.py", line 310, in _handle_exception

    raise pycompat.reraise(type(exception), exception, sys.exc_info()[2])

  File "/opt/odoo/odoo/odoo/tools/pycompat.py", line 87, in reraise

    raise value

  File "/opt/odoo/odoo/odoo/http.py", line 692, in dispatch

    result = self._call_function(**self.params)

  File "/opt/odoo/odoo/odoo/http.py", line 342, in _call_function

    return checked_call(self.db, *args, **kwargs)

  File "/opt/odoo/odoo/odoo/service/model.py", line 97, in wrapper

    return f(dbname, *args, **kwargs)

  File "/opt/odoo/odoo/odoo/http.py", line 335, in checked_call

    result = self.endpoint(*a, **kw)

  File "/opt/odoo/odoo/odoo/http.py", line 936, in __call__

    return self.method(*args, **kw)

  File "/opt/odoo/odoo/odoo/http.py", line 515, in response_wrap

    response = f(*args, **kw)

  File "/opt/odoo/odoo/addons/web/controllers/main.py", line 934, in call_button

    action = self._call_kw(model, method, args, {})

  File "/opt/odoo/odoo/addons/web/controllers/main.py", line 922, in _call_kw

    return call_kw(request.env[model], method, args, kwargs)

  File "/opt/odoo/odoo/odoo/api.py", line 689, in call_kw

    return call_kw_multi(method, model, args, kwargs)

  File "/opt/odoo/odoo/odoo/api.py", line 680, in call_kw_multi

    result = method(recs, *args, **kwargs)

  File "<decorator-gen-46>", line 2, in button_immediate_upgrade

  File "/opt/odoo/odoo/odoo/addons/base/module/module.py", line 71, in check_and_log

    return method(self, *args, **kwargs)

  File "/opt/odoo/odoo/odoo/addons/base/module/module.py", line 602, in button_immediate_upgrade

    return self._button_immediate_function(type(self).button_upgrade)

  File "/opt/odoo/odoo/odoo/addons/base/module/module.py", line 541, in _button_immediate_function

    modules.registry.Registry.new(self._cr.dbname, update_module=True)

  File "/opt/odoo/odoo/odoo/modules/registry.py", line 85, in new

    odoo.modules.load_modules(registry._db, force_demo, status, update_module)

  File "/opt/odoo/odoo/odoo/modules/loading.py", line 339, in load_modules

    force, status, report, loaded_modules, update_module)

  File "/opt/odoo/odoo/odoo/modules/loading.py", line 242, 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/odoo/odoo/modules/loading.py", line 156, in load_module_graph

    _load_data(cr, module_name, idref, mode, kind='data')

  File "/opt/odoo/odoo/odoo/modules/loading.py", line 94, in _load_data

    tools.convert_file(cr, module_name, filename, idref, mode, noupdate, kind, report)

  File "/opt/odoo/odoo/odoo/tools/convert.py", line 788, in convert_file

    convert_xml_import(cr, module, fp, idref, mode, noupdate, report)

  File "/opt/odoo/odoo/odoo/tools/convert.py", line 849, in convert_xml_import

    obj.parse(doc.getroot(), mode=mode)

  File "/opt/odoo/odoo/odoo/tools/convert.py", line 748, in parse

    exc_info[2]

  File "/opt/odoo/odoo/odoo/tools/pycompat.py", line 86, in reraise

    raise value.with_traceback(tb)

  File "/opt/odoo/odoo/odoo/tools/convert.py", line 741, in parse

    self._tags[rec.tag](rec, de, mode=mode)

  File "/opt/odoo/odoo/odoo/tools/convert.py", line 651, in _tag_record

    id = self.env(context=rec_context)['ir.model.data']._update(rec_model, self.module, res, rec_id or False, not self.isnoupdate(data_node), noupdate=self.isnoupdate(data_node), mode=self.mode)

  File "/opt/odoo/odoo/odoo/addons/base/ir/ir_model.py", line 1469, in _update

    record = record.create(values)

  File "/opt/odoo/odoo/odoo/addons/base/ir/ir_ui_view.py", line 398, in create

    return super(View, self).create(self._compute_defaults(values))

  File "/opt/odoo/odoo/odoo/models.py", line 3356, in create

    self._fields[key].determine_inverse(record)

  File "/opt/odoo/odoo/odoo/fields.py", line 1070, in determine_inverse

    getattr(records, self.inverse)()

  File "/opt/odoo/odoo/odoo/addons/base/ir/ir_ui_view.py", line 266, in _inverse_arch

    view.write(data)

  File "/opt/odoo/odoo/odoo/addons/base/ir/ir_ui_view.py", line 414, in write

    return super(View, self).write(self._compute_defaults(vals))

  File "/opt/odoo/odoo/odoo/models.py", line 3065, in write

    self._write(old_vals)

  File "/opt/odoo/odoo/odoo/models.py", line 3231, in _write

    self._validate_fields(vals)

  File "/opt/odoo/odoo/odoo/models.py", line 1027, in _validate_fields

    raise ValidationError("%s\n\n%s" % (_("Error while validating constraint"), tools.ustr(e)))

odoo.tools.convert.ParseError: "Erreur lors de la validation de la contrainte


Field 'product_uom_qty' used in attributes must be present in view but is missing:

 - 'product_uom_qty' in context="{'partner_id':parent.partner_id, 'quantity':product_uom_qty, 'pricelist':parent.pricelist_id, 'uom':product_uom, 'company_id': parent.company_id}"


Contexte de l'erreur :

Vue `sale.order`

[view_id: 1191, xml_id: n/a, model: sale.order, parent_id: 1130]

None" while parsing /home/zh/Documents/projects/tutorial/addons/venteextends/views/vente.xml:3, near

<record id="sale_order_inherit" model="ir.ui.view">

    <field name="name">sale.order</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/notebook/page/field[@name='order_line']/tree/field[@name='product_uom_qty']" position="replace">

        </xpath>

    </field>

</record>



Avatar
Discard