问题
i was trying to install a module but each time there is an error like this : Erreur:
Odoo Server Error
Traceback (most recent call last):
File "C:\Program Files (x86)\Odoo 12.0\server\odoo\models.py", line 1126, in _validate_fields
check(self)
File "c:\program files (x86)\odoo 12.0\server\odoo\addons\base\models\ir_ui_view.py", line 351, in _check_xml
self.postprocess_and_fields(view.model, view_doc, view.id)
File "c:\program files (x86)\odoo 12.0\server\odoo\addons\base\models\ir_ui_view.py", line 1131, in postprocess_and_fields
self.raise_view_error(message, view_id)
File "c:\program files (x86)\odoo 12.0\server\odoo\addons\base\models\ir_ui_view.py", line 568, in raise_view_error
raise ValueError(message)
ValueError: Le champ `nbre_ch` n'existe pas
Contexte de l'erreur :
Vue `Product`
[view_id: 1029, xml_id: n/a, model: product.template, parent_id: 496]
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Program Files (x86)\Odoo 12.0\server\odoo\tools\convert.py", line 758, in parse
self._tags[rec.tag](rec, de, mode=mode)
File "C:\Program Files (x86)\Odoo 12.0\server\odoo\tools\convert.py", line 663, in _tag_record
record = model.with_context(rec_context)._load_records([data], self.mode == 'update')
File "C:\Program Files (x86)\Odoo 12.0\server\odoo\models.py", line 3888, in _load_records
records = self._load_records_create([data['values'] for data in to_create])
File "c:\program files (x86)\odoo 12.0\server\odoo\addons\website\models\ir_ui_view.py", line 129, in _load_records_create
records = super(View, self)._load_records_create(values)
File "C:\Program Files (x86)\Odoo 12.0\server\odoo\models.py", line 3802, in _load_records_create
return self.create(values)
File "<decorator-gen-32>", line 2, in create
File "C:\Program Files (x86)\Odoo 12.0\server\odoo\api.py", line 462, in _model_create_multi
return create(self, arg)
File "c:\program files (x86)\odoo 12.0\server\odoo\addons\base\models\ir_ui_view.py", line 428, in create
return super(View, self).create(vals_list)
File "<decorator-gen-3>", line 2, in create
File "C:\Program Files (x86)\Odoo 12.0\server\odoo\api.py", line 462, in _model_create_multi
return create(self, arg)
File "C:\Program Files (x86)\Odoo 12.0\server\odoo\models.py", line 3619, in create
fields[0].determine_inverse(batch_recs)
File "C:\Program Files (x86)\Odoo 12.0\server\odoo\fields.py", line 1141, in determine_inverse
getattr(records, self.inverse)()
File "c:\program files (x86)\odoo 12.0\server\odoo\addons\base\models\ir_ui_view.py", line 275, in _inverse_arch
view.write(data)
File "c:\program files (x86)\odoo 12.0\server\odoo\addons\website\models\ir_ui_view.py", line 41, in write
return super(View, self).write(vals)
File "c:\program files (x86)\odoo 12.0\server\odoo\addons\base\models\ir_ui_view.py", line 445, in write
res = super(View, self).write(self._compute_defaults(vals))
File "C:\Program Files (x86)\Odoo 12.0\server\odoo\models.py", line 3344, in write
self._write(store_vals)
File "C:\Program Files (x86)\Odoo 12.0\server\odoo\models.py", line 3480, in _write
self._validate_fields(vals)
File "C:\Program Files (x86)\Odoo 12.0\server\odoo\models.py", line 1130, 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\nLe champ `nbre_ch` n'existe pas\n\nContexte de l'erreur :\nVue `Product`\n[view_id: 1029, xml_id: n/a, model: product.template, parent_id: 496]", None)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Program Files (x86)\Odoo 12.0\server\odoo\http.py", line 656, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception)
File "C:\Program Files (x86)\Odoo 12.0\server\odoo\http.py", line 314, in _handle_exception
raise pycompat.reraise(type(exception), exception, sys.exc_info()[2])
File "C:\Program Files (x86)\Odoo 12.0\server\odoo\tools\pycompat.py", line 87, in reraise
raise value
File "C:\Program Files (x86)\Odoo 12.0\server\odoo\http.py", line 698, in dispatch
result = self._call_function(**self.params)
File "C:\Program Files (x86)\Odoo 12.0\server\odoo\http.py", line 346, in _call_function
return checked_call(self.db, *args, **kwargs)
File "C:\Program Files (x86)\Odoo 12.0\server\odoo\service\model.py", line 98, in wrapper
return f(dbname, *args, **kwargs)
File "C:\Program Files (x86)\Odoo 12.0\server\odoo\http.py", line 339, in checked_call
result = self.endpoint(*a, **kw)
File "C:\Program Files (x86)\Odoo 12.0\server\odoo\http.py", line 941, in __call__
return self.method(*args, **kw)
File "C:\Program Files (x86)\Odoo 12.0\server\odoo\http.py", line 519, in response_wrap
response = f(*args, **kw)
File "c:\program files (x86)\odoo 12.0\server\odoo\addons\web\controllers\main.py", line 966, in call_button
action = self._call_kw(model, method, args, {})
File "c:\program files (x86)\odoo 12.0\server\odoo\addons\web\controllers\main.py", line 954, in _call_kw
return call_kw(request.env[model], method, args, kwargs)
File "C:\Program Files (x86)\Odoo 12.0\server\odoo\api.py", line 759, in call_kw
return _call_kw_multi(method, model, args, kwargs)
File "C:\Program Files (x86)\Odoo 12.0\server\odoo\api.py", line 746, in _call_kw_multi
result = method(recs, *args, **kwargs)
File "<decorator-gen-61>", line 2, in button_immediate_install
File "c:\program files (x86)\odoo 12.0\server\odoo\addons\base\models\ir_module.py", line 74, in check_and_log
return method(self, *args, **kwargs)
File "c:\program files (x86)\odoo 12.0\server\odoo\addons\base\models\ir_module.py", line 445, in button_immediate_install
return self._button_immediate_function(type(self).button_install)
File "c:\program files (x86)\odoo 12.0\server\odoo\addons\base\models\ir_module.py", line 561, in _button_immediate_function
modules.registry.Registry.new(self._cr.dbname, update_module=True)
File "C:\Program Files (x86)\Odoo 12.0\server\odoo\modules\registry.py", line 86, in new
odoo.modules.load_modules(registry._db, force_demo, status, update_module)
File "C:\Program Files (x86)\Odoo 12.0\server\odoo\modules\loading.py", line 421, in load_modules
loaded_modules, update_module, models_to_check)
File "C:\Program Files (x86)\Odoo 12.0\server\odoo\modules\loading.py", line 313, in load_marked_modules
perform_checks=perform_checks, models_to_check=models_to_check
File "C:\Program Files (x86)\Odoo 12.0\server\odoo\modules\loading.py", line 222, in load_module_graph
load_data(cr, idref, mode, kind='data', package=package, report=report)
File "C:\Program Files (x86)\Odoo 12.0\server\odoo\modules\loading.py", line 68, in load_data
tools.convert_file(cr, package.name, filename, idref, mode, noupdate, kind, report)
File "C:\Program Files (x86)\Odoo 12.0\server\odoo\tools\convert.py", line 802, in convert_file
convert_xml_import(cr, module, fp, idref, mode, noupdate, report)
File "C:\Program Files (x86)\Odoo 12.0\server\odoo\tools\convert.py", line 865, in convert_xml_import
obj.parse(doc.getroot(), mode=mode)
File "C:\Program Files (x86)\Odoo 12.0\server\odoo\tools\convert.py", line 764, in parse
exc_info[2]
File "C:\Program Files (x86)\Odoo 12.0\server\odoo\tools\pycompat.py", line 86, in reraise
raise value.with_traceback(tb)
File "C:\Program Files (x86)\Odoo 12.0\server\odoo\tools\convert.py", line 758, in parse
self._tags[rec.tag](rec, de, mode=mode)
File "C:\Program Files (x86)\Odoo 12.0\server\odoo\tools\convert.py", line 663, in _tag_record
record = model.with_context(rec_context)._load_records([data], self.mode == 'update')
File "C:\Program Files (x86)\Odoo 12.0\server\odoo\models.py", line 3888, in _load_records
records = self._load_records_create([data['values'] for data in to_create])
File "c:\program files (x86)\odoo 12.0\server\odoo\addons\website\models\ir_ui_view.py", line 129, in _load_records_create
records = super(View, self)._load_records_create(values)
File "C:\Program Files (x86)\Odoo 12.0\server\odoo\models.py", line 3802, in _load_records_create
return self.create(values)
File "<decorator-gen-32>", line 2, in create
File "C:\Program Files (x86)\Odoo 12.0\server\odoo\api.py", line 462, in _model_create_multi
return create(self, arg)
File "c:\program files (x86)\odoo 12.0\server\odoo\addons\base\models\ir_ui_view.py", line 428, in create
return super(View, self).create(vals_list)
File "<decorator-gen-3>", line 2, in create
File "C:\Program Files (x86)\Odoo 12.0\server\odoo\api.py", line 462, in _model_create_multi
return create(self, arg)
File "C:\Program Files (x86)\Odoo 12.0\server\odoo\models.py", line 3619, in create
fields[0].determine_inverse(batch_recs)
File "C:\Program Files (x86)\Odoo 12.0\server\odoo\fields.py", line 1141, in determine_inverse
getattr(records, self.inverse)()
File "c:\program files (x86)\odoo 12.0\server\odoo\addons\base\models\ir_ui_view.py", line 275, in _inverse_arch
view.write(data)
File "c:\program files (x86)\odoo 12.0\server\odoo\addons\website\models\ir_ui_view.py", line 41, in write
return super(View, self).write(vals)
File "c:\program files (x86)\odoo 12.0\server\odoo\addons\base\models\ir_ui_view.py", line 445, in write
res = super(View, self).write(self._compute_defaults(vals))
File "C:\Program Files (x86)\Odoo 12.0\server\odoo\models.py", line 3344, in write
self._write(store_vals)
File "C:\Program Files (x86)\Odoo 12.0\server\odoo\models.py", line 3480, in _write
self._validate_fields(vals)
File "C:\Program Files (x86)\Odoo 12.0\server\odoo\models.py", line 1130, 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
Le champ `nbre_ch` n'existe pas
Contexte de l'erreur :
Vue `Product`
[view_id: 1029, xml_id: n/a, model: product.template, parent_id: 496]
None" while parsing file:/c:/program%20files%20(x86)/odoo%2012.0/server/odoo/addons/gestionimmo/views/gesimmo_views.xml:7, near
<record model="ir.ui.view" id="view_form_gesimmo">
<field name="name">Product</field>
<field name="model">product.template</field>
<field name="inherit_id" ref="product.product_template_only_form_view"/>
<field name="arch" type="xml">
<data><!--<xpath expr="//field[@name='default_code']" position="after">
<group>
<field name="prop" style="width:300%%"/>
<field name="ref" style="width:300%%"/>
<field name="surface" style="width:300%%"/>
<field name="immo_cat" style="width:300%%"/>
<field name="immo_titre" style="width:300%%"/>
<field name="immo_date" style="width:300%%"/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/><br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<field name="img_one" widget="image" style="width:400%%"/>
<field name="refimmo"/>
</group>
</xpath>-->
<xpath expr="//field[@name='standard_price']" position="attributes">
<attribute name="invisible">1</attribute>
</xpath>
<xpath expr="//field[@name='barcode']" position="attributes" nolabel="true">
<attribute name="invisible">1</attribute>
</xpath>
<xpath expr="//field[@name='categ_id']" position="attributes">
<attribute name="invisible">1</attribute>
</xpath>
<xpath expr="//field[@name='type']" position="attributes">
<attribute name="invisible">1</attribute>
</xpath>
<xpath expr="//field[@name='default_code']" position="attributes">
<attribute name="invisible">1</attribute>
</xpath>
<xpath expr="//label[@for='standard_price']" position="attributes">
<attribute name="invisible">1</attribute>
</xpath>
<xpath expr="//field[@name='taxes_id']" position="after">
<group>
<field name="nbre_ch" style="width:300%%"/>
<br/>
<br/>
<br/>
<field name="pr" style="width:300%%"/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<field name="rue" placeholder="Rue" style="width:300%%"/>
<field name="gouv" placeholder="Gouvernorat" style="width:300%%"/>
<field name="ville" placeholder="Ville" style="width:300%%"/>
<field name="codepostal" placeholder="Code postal" style="width:300%%"/>
<field name="pays" placeholder="Pays" style="width:300%%" readonly="1"/>
<br/>
<br/>
<br/>
<br/>
<br/>
<field name="img_two" widget="image" style="width:400%%"/>
</group>
</xpath>
<xpath expr="//field[@name='taxes_id']" position="attributes">
<attribute name="invisible">1</attribute>
</xpath>
<xpath expr="//field[@name='list_price']" position="attributes">
<attribute name="invisible">1</attribute>
</xpath>
<label for="name" position="replace">
<label for="name" string="Nom du bien immobilier"/>
</label>
<!--<label for="sale_ok" position="replace">
<label for="sale_ok" string="A Vendre"/>
</label>-->
<!--<label for="purchase_ok" position="replace">
<label for="purchase_ok" string="A Louer"/>
</label>-->
<xpath expr="//page[@name='variants']" position="attributes">
<attribute name="invisible">1</attribute>
</xpath>
<xpath expr="//page[@name='sales']" position="attributes">
<attribute name="invisible">1</attribute>
</xpath>
<xpath expr="//page[@name='purchase']" position="attributes">
<attribute name="invisible">1</attribute>
</xpath>
<xpath expr="//page[@name='inventory']" position="attributes">
<attribute name="invisible">1</attribute>
</xpath>
<xpath expr="//field[@name='pays']" position="before">
<button name="open_map" type="object" icon="/GestionIMMO/static/src/img/google_maps.png"/>
</xpath>
<!--<button name="action_update_quantity_on_hand" position = "attributes" >
<attribute name = "invisible">1</attribute>
</button>-->
<xpath expr="//button[@name='toggle_active']" position="attributes">
<attribute name="invisible">1</attribute>
</xpath>
<xpath expr="//button[@name='action_view_sales']" position="attributes">
<attribute name="invisible">1</attribute>
</xpath>
<xpath expr="//button[@name='action_view_po']" position="attributes">
<attribute name="invisible">1</attribute>
</xpath>
<!--<xpath expr="//button[@name='action_open_quants']" position="attributes">
<attribute name="invisible">1</attribute>
</xpath>-->
<!--<xpath expr="//button[@name='action_view_stock_move_lines']" position="attributes">
<attribute name="invisible">1</attribute>
</xpath>-->
<xpath expr="//field[@name='sale_ok']" position="attributes">
<attribute name="invisible">1</attribute>
</xpath>
<xpath expr="//field[@name='purchase_ok']" position="attributes">
<attribute name="invisible">1</attribute>
</xpath>
<label for="sale_ok" position="replace">
<label for="sale_ok" invisible="1"/>
</label>
<label for="purchase_ok" position="replace">
<label for="purchase_ok" invisible="1"/>
</label>
<xpath expr="//field[@name='name']" position="after">
<!--<field name="a_louer" invisible="1"/>-->
<!--<field name="type_b" widget="radio" class="oe_edit_only" options="{'horizontal': true}"/>-->
<!--<field name="choix_type" widget="many2many_tags" options="{'color_field': 'color', 'no_create_edit': True}" placeholder="Tags..." default="name"/>-->
</xpath>
<!--<xpath expr="//field[@name='immo_date']" position="after">
<field name="description_bien" placeholder="Description..." style="width:300%%"/>
</xpath>-->
<!--<xpath expr="//button[@name='356']" position="attributes">
<attribute name="invisible">1</attribute>
</xpath>-->
<!--<xpath expr="//button[@name='action_view_orderpoints']" position="attributes">
<attribute name="invisible">1</attribute>
</xpath>-->
<!--<xpath expr="//button[@name='action_open_product_lot']" position="attributes">
<attribute name="invisible">1</attribute>
</xpath>-->
</data></field>
</record>
but the field does exist in .py file and in the xml view , i checked my init.py and everything is fine , i tried to comment the field in the xml and the .py file and run it again and it is the same error with another field .. Please help and thanks
回答1:
Make sure you have added dependency of product
module in your manifest file. Or something is missing on init file level.
来源:https://stackoverflow.com/questions/61787482/fields-does-not-exist-error-working-with-odoo-12