Odoo custom module modifying crm.leads - python

I'd like to add some fields from a custom module (following the tutorial here: https://www.odoo.com/documentation/11.0/howtos/backend.html#model-inheritance) to the lead form but I can't get it to work.
I always get the following error:
Odoo Server Error
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/odoo/models.py", line 971, in _validate_fields
check(self)
File "/usr/lib/python3/dist-packages/odoo/addons/base/ir/ir_ui_view.py", line 321, in _check_xml
self.postprocess_and_fields(view.model, view_doc, view.id)
File "/usr/lib/python3/dist-packages/odoo/addons/base/ir/ir_ui_view.py", line 919, in postprocess_and_fields
self.raise_view_error(message, view_id)
File "/usr/lib/python3/dist-packages/odoo/addons/base/ir/ir_ui_view.py", line 489, in raise_view_error
raise ValueError(message)
ValueError: Field `country` does not exist
Error context:
View `crm_case_form_view_leads_extended`
[view_id: 990, xml_id: n/a, model: crm.lead, parent_id: 442]
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/odoo/tools/convert.py", line 741, in parse
self._tags[rec.tag](rec, de, mode=mode)
File "/usr/lib/python3/dist-packages/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 "/usr/lib/python3/dist-packages/odoo/addons/base/ir/ir_model.py", line 1467, in _update
record = record.create(values)
File "/usr/lib/python3/dist-packages/odoo/addons/base/ir/ir_ui_view.py", line 384, in create
return super(View, self).create(self._compute_defaults(values))
File "/usr/lib/python3/dist-packages/odoo/models.py", line 3289, in create
self._fields[key].determine_inverse(record)
File "/usr/lib/python3/dist-packages/odoo/fields.py", line 1078, in determine_inverse
getattr(records, self.inverse)()
File "/usr/lib/python3/dist-packages/odoo/addons/base/ir/ir_ui_view.py", line 253, in _inverse_arch
view.write(data)
File "/usr/lib/python3/dist-packages/odoo/addons/base/ir/ir_ui_view.py", line 400, in write
return super(View, self).write(self._compute_defaults(vals))
File "/usr/lib/python3/dist-packages/odoo/models.py", line 3011, in write
self._write(old_vals)
File "/usr/lib/python3/dist-packages/odoo/models.py", line 3164, in _write
self._validate_fields(vals)
File "/usr/lib/python3/dist-packages/odoo/models.py", line 975, in _validate_fields
raise ValidationError("%s\n\n%s" % (_("Error while validating constraint"), tools.ustr(e)))
odoo.exceptions.ValidationError: ('Error while validating constraint\n\nField `country` does not exist\n\nError context:\nView `crm_case_form_view_leads_extended`\n[view_id: 990, xml_id: n/a, model: crm.lead, parent_id: 442]', None)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/odoo/http.py", line 646, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception)
File "/usr/lib/python3/dist-packages/odoo/http.py", line 307, in _handle_exception
raise pycompat.reraise(type(exception), exception, sys.exc_info()[2])
File "/usr/lib/python3/dist-packages/odoo/tools/pycompat.py", line 87, in reraise
raise value
File "/usr/lib/python3/dist-packages/odoo/http.py", line 683, in dispatch
result = self._call_function(**self.params)
File "/usr/lib/python3/dist-packages/odoo/http.py", line 339, in _call_function
return checked_call(self.db, *args, **kwargs)
File "/usr/lib/python3/dist-packages/odoo/service/model.py", line 97, in wrapper
return f(dbname, *args, **kwargs)
File "/usr/lib/python3/dist-packages/odoo/http.py", line 332, in checked_call
result = self.endpoint(*a, **kw)
File "/usr/lib/python3/dist-packages/odoo/http.py", line 927, in __call__
return self.method(*args, **kw)
File "/usr/lib/python3/dist-packages/odoo/http.py", line 512, in response_wrap
response = f(*args, **kw)
File "/usr/lib/python3/dist-packages/odoo/addons/web/controllers/main.py", line 924, in call_button
action = self._call_kw(model, method, args, {})
File "/usr/lib/python3/dist-packages/odoo/addons/web/controllers/main.py", line 912, in _call_kw
return call_kw(request.env[model], method, args, kwargs)
File "/usr/lib/python3/dist-packages/odoo/api.py", line 689, in call_kw
return call_kw_multi(method, model, args, kwargs)
File "/usr/lib/python3/dist-packages/odoo/api.py", line 680, in call_kw_multi
result = method(recs, *args, **kwargs)
File "<decorator-gen-39>", line 2, in button_immediate_install
File "/usr/lib/python3/dist-packages/odoo/addons/base/module/module.py", line 70, in check_and_log
return method(self, *args, **kwargs)
File "/usr/lib/python3/dist-packages/odoo/addons/base/module/module.py", line 437, in button_immediate_install
return self._button_immediate_function(type(self).button_install)
File "/usr/lib/python3/dist-packages/odoo/addons/base/module/module.py", line 530, in _button_immediate_function
modules.registry.Registry.new(self._cr.dbname, update_module=True)
File "/usr/lib/python3/dist-packages/odoo/modules/registry.py", line 84, in new
odoo.modules.load_modules(registry._db, force_demo, status, update_module)
File "/usr/lib/python3/dist-packages/odoo/modules/loading.py", line 343, in load_modules
loaded_modules, update_module)
File "/usr/lib/python3/dist-packages/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 "/usr/lib/python3/dist-packages/odoo/modules/loading.py", line 156, in load_module_graph
_load_data(cr, module_name, idref, mode, kind='data')
File "/usr/lib/python3/dist-packages/odoo/modules/loading.py", line 94, in _load_data
tools.convert_file(cr, module_name, filename, idref, mode, noupdate, kind, report)
File "/usr/lib/python3/dist-packages/odoo/tools/convert.py", line 788, in convert_file
convert_xml_import(cr, module, fp, idref, mode, noupdate, report)
File "/usr/lib/python3/dist-packages/odoo/tools/convert.py", line 849, in convert_xml_import
obj.parse(doc.getroot(), mode=mode)
File "/usr/lib/python3/dist-packages/odoo/tools/convert.py", line 738, in parse
self.parse(rec, mode)
File "/usr/lib/python3/dist-packages/odoo/tools/convert.py", line 748, in parse
exc_info[2]
File "/usr/lib/python3/dist-packages/odoo/tools/pycompat.py", line 86, in reraise
raise value.with_traceback(tb)
File "/usr/lib/python3/dist-packages/odoo/tools/convert.py", line 741, in parse
self._tags[rec.tag](rec, de, mode=mode)
File "/usr/lib/python3/dist-packages/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 "/usr/lib/python3/dist-packages/odoo/addons/base/ir/ir_model.py", line 1467, in _update
record = record.create(values)
File "/usr/lib/python3/dist-packages/odoo/addons/base/ir/ir_ui_view.py", line 384, in create
return super(View, self).create(self._compute_defaults(values))
File "/usr/lib/python3/dist-packages/odoo/models.py", line 3289, in create
self._fields[key].determine_inverse(record)
File "/usr/lib/python3/dist-packages/odoo/fields.py", line 1078, in determine_inverse
getattr(records, self.inverse)()
File "/usr/lib/python3/dist-packages/odoo/addons/base/ir/ir_ui_view.py", line 253, in _inverse_arch
view.write(data)
File "/usr/lib/python3/dist-packages/odoo/addons/base/ir/ir_ui_view.py", line 400, in write
return super(View, self).write(self._compute_defaults(vals))
File "/usr/lib/python3/dist-packages/odoo/models.py", line 3011, in write
self._write(old_vals)
File "/usr/lib/python3/dist-packages/odoo/models.py", line 3164, in _write
self._validate_fields(vals)
File "/usr/lib/python3/dist-packages/odoo/models.py", line 975, in _validate_fields
raise ValidationError("%s\n\n%s" % (_("Error while validating constraint"), tools.ustr(e)))
odoo.tools.convert.ParseError: "Error while validating constraint
Field `country` does not exist
Error context:
View `crm_case_form_view_leads_extended`
[view_id: 990, xml_id: n/a, model: crm.lead, parent_id: 442]
None" while parsing /mnt/extra-addons/leads_events/views/views.xml:6, near
<record id="crm.crm_case_form_view_leads_extended" model="ir.ui.view">
<field name="name">crm_case_form_view_leads_extended</field>
<field name="model">crm.lead</field>
<field name="inherit_id" ref="crm.crm_case_form_view_leads"/>
<field name="arch" type="xml">
<data><!-- Change title placeholder -->
<xpath expr="//h1/field[#name='name']" position="replace">
<field name="name" placeholder="Name"/>
</xpath>
<!-- Add new fields -->
<xpath expr="//notebook" position="before">
<group>
<field name="city"/>
<field name="country"/>
</group>
</xpath>
</data></field>
</record>
Here is my code:
__manifest__.py
'data': [
# 'security/ir.model.access.csv',
'views/views.xml',
__init__.py
# -*- coding: utf-8 -*-
from . import controllers
from . import models
models.py
# -*- coding: utf-8 -*-
from odoo import models, fields, api
class Leads_extended(models.Model):
_inherit = 'crm.lead'
_name = 'crm.lead.events'
city = fields.Char(String="City")
country = fields.Many2one('res.country', string="Country")
views.xml
<odoo>
<data>
<!-- explicit list view definition -->
<record id="crm.crm_case_form_view_leads_extended" model="ir.ui.view">
<field name="name">crm_case_form_view_leads_extended</field>
<field name="model">crm.lead</field>
<field name="inherit_id" ref="crm.crm_case_form_view_leads"/>
<field name="arch" type="xml">
<!-- Change title placeholder -->
<xpath expr="//h1/field[#name='name']" position="replace">
<field name="name" placeholder="Name" />
</xpath>
<!-- Add new fields -->
<xpath expr="//notebook" position="before">
<group>
<field name="city"/>
<field name="country"/>
</group>
</xpath>
</field>
</record>
</data>
</odoo>
I can't figure out what's wrong in my code... Any leads?
Thanks !

When you set the name of your module as _name = 'crm.lead.events' you create a new table.
On your xml you are still referencing crm.lead. So, remove the the line
_name = 'crm.lead.events'
And it should work.

Related

ValueError: Field doesn't exists [Odoo 12]

I'm trying to get a client_order_ref from a sale order, from the account.invoice module. I don't know why it says that the field doesn't exits, and the field it's defined. Please help me
Python code
from odoo import models, fields, api, _
class AccountInvoice(models.Model):
_inherit = 'account.invoice'
client_order_ref = fields.Char(string="Client Order Ref", compute="get_client_from_sale_order")
#api.depends('name')
def get_client_from_sale_order(self):
self.ensure_one()
for rec in self:
sale_order = self.env['sale.order'].search(
[('name', '=', rec.origin)]
)
rec.client_order_ref = sale_order.client_order_ref
XML code
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="invoice_tree" model="ir.ui.view">
<field name="name">account_invoice_tree_inherit</field>
<field name="model">account.invoice</field>
<field name="inherit_id" ref="account.invoice_tree"/>
<field name="arch" type="xml">
<xpath expr="//field[#name='partner_id']" position="after">
<field name="client_order_ref"/>
</xpath>
</field>
</record>
</odoo>
TRACEBACK
Error: Odoo Server Error
Traceback (most recent call last): File
"/opt/odoo/custom/src/odoo/odoo/models.py", line 1128, in
_validate_fields
check(self) File "/opt/odoo/custom/src/odoo/odoo/addons/base/models/ir_ui_view.py",
line 351, in _check_xml
self.postprocess_and_fields(view.model, view_doc, view.id) File "/opt/odoo/custom/src/odoo/odoo/addons/base/models/ir_ui_view.py",
line 1138, in postprocess_and_fields
self.raise_view_error(message, view_id) File "/opt/odoo/custom/src/odoo/odoo/addons/base/models/ir_ui_view.py",
line 568, in raise_view_error
raise ValueError(message) ValueError: Field client_order_ref does not exist
Error context: View account_invoice_tree_inherit [view_id: 1311,
xml_id: cloudpiles_custom.invoice_tree, model: account.invoice,
parent_id: 681]
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File
"/opt/odoo/custom/src/odoo/odoo/tools/convert.py", line 758, in parse
self._tags[rec.tag](rec, de, mode=mode) File "/opt/odoo/custom/src/odoo/odoo/tools/convert.py", line 663, in
_tag_record
record = model.with_context(rec_context)._load_records([data], self.mode == 'update') File
"/opt/odoo/custom/src/odoo/odoo/models.py", line 3883, in
_load_records
data['record']._load_records_write(data['values']) File "/opt/odoo/custom/src/odoo/odoo/addons/base/models/ir_ui_view.py",
line 1542, in _load_records_write
super(View, self)._load_records_write(values) File "/opt/odoo/custom/src/odoo/odoo/models.py", line 3821, in
_load_records_write
self.write(values) File "/opt/odoo/custom/src/odoo/odoo/addons/base/models/ir_ui_view.py",
line 445, in write
res = super(View, self).write(self._compute_defaults(vals)) File "/opt/odoo/custom/src/odoo/odoo/models.py", line 3392, in write
fields[0].determine_inverse(records) File "/opt/odoo/custom/src/odoo/odoo/fields.py", line 1200, in
determine_inverse
getattr(records, self.inverse)() File "/opt/odoo/custom/src/odoo/odoo/addons/base/models/ir_ui_view.py",
line 275, in _inverse_arch
view.write(data) File "/opt/odoo/custom/src/odoo/odoo/addons/base/models/ir_ui_view.py",
line 445, in write
res = super(View, self).write(self._compute_defaults(vals)) File "/opt/odoo/custom/src/odoo/odoo/models.py", line 3366, in write
self._write(store_vals) File "/opt/odoo/custom/src/odoo/odoo/models.py", line 3502, in _write
self._validate_fields(vals) File "/opt/odoo/custom/src/odoo/odoo/models.py", line 1132, in
validate_fields
raise ValidationError("%s\n\n%s" % (("Error while validating constraint"), tools.ustr(e))) odoo.exceptions.ValidationError: ('Error
while validating constraint\n\nField client_order_ref does not
exist\n\nError context:\nView
account_invoice_tree_inherit\n[view_id: 1311, xml_id:
cloudpiles_custom.invoice_tree, model: account.invoice, parent_id:
681]', None)
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File
"/opt/odoo/custom/src/odoo/odoo/http.py", line 656, in
_handle_exception
return super(JsonRequest, self)._handle_exception(exception) File "/opt/odoo/custom/src/odoo/odoo/http.py", line 314, in
_handle_exception
raise pycompat.reraise(type(exception), exception, sys.exc_info()[2]) File
"/opt/odoo/custom/src/odoo/odoo/tools/pycompat.py", line 87, in
reraise
raise value File "/opt/odoo/custom/src/odoo/odoo/http.py", line 698, in dispatch
result = self._call_function(**self.params) File "/opt/odoo/custom/src/odoo/odoo/http.py", line 346, in _call_function
return checked_call(self.db, *args, **kwargs) File "/opt/odoo/custom/src/odoo/odoo/service/model.py", line 98, in wrapper
return f(dbname, *args, **kwargs) File "/opt/odoo/custom/src/odoo/odoo/http.py", line 339, in checked_call
result = self.endpoint(*a, **kw) File "/opt/odoo/custom/src/odoo/odoo/http.py", line 941, in call
return self.method(*args, **kw) File "/opt/odoo/custom/src/odoo/odoo/http.py", line 519, in response_wrap
response = f(*args, **kw) File "/opt/odoo/auto/addons/web/controllers/main.py", line 967, in
call_button
action = self._call_kw(model, method, args, {}) File "/opt/odoo/auto/addons/web/controllers/main.py", line 955, in _call_kw
return call_kw(request.env[model], method, args, kwargs) File "/opt/odoo/custom/src/odoo/odoo/api.py", line 759, in call_kw
return _call_kw_multi(method, model, args, kwargs) File "/opt/odoo/custom/src/odoo/odoo/api.py", line 746, in _call_kw_multi
result = method(recs, *args, **kwargs) File "", line 2, in button_immediate_upgrade File
"/opt/odoo/custom/src/odoo/odoo/addons/base/models/ir_module.py", line
75, in check_and_log
return method(self, *args, **kwargs) File "/opt/odoo/custom/src/odoo/odoo/addons/base/models/ir_module.py", line
628, in button_immediate_upgrade
return self._button_immediate_function(type(self).button_upgrade) File "/opt/odoo/custom/src/odoo/odoo/addons/base/models/ir_module.py",
line 562, in _button_immediate_function
modules.registry.Registry.new(self._cr.dbname, update_module=True) File "/opt/odoo/custom/src/odoo/odoo/modules/registry.py", line 86, in
new
odoo.modules.load_modules(registry._db, force_demo, status, update_module) File
"/opt/odoo/custom/src/odoo/odoo/modules/loading.py", line 417, in
load_modules
force, status, report, loaded_modules, update_module, models_to_check) File
"/opt/odoo/custom/src/odoo/odoo/modules/loading.py", line 313, in
load_marked_modules
perform_checks=perform_checks, models_to_check=models_to_check File "/opt/odoo/custom/src/odoo/odoo/modules/loading.py", line 222, in
load_module_graph
load_data(cr, idref, mode, kind='data', package=package, report=report) File
"/opt/odoo/custom/src/odoo/odoo/modules/loading.py", line 68, in
load_data
tools.convert_file(cr, package.name, filename, idref, mode, noupdate, kind, report) File
"/opt/odoo/custom/src/odoo/odoo/tools/convert.py", line 802, in
convert_file
convert_xml_import(cr, module, fp, idref, mode, noupdate, report) File "/opt/odoo/custom/src/odoo/odoo/tools/convert.py", line 865, in
convert_xml_import
obj.parse(doc.getroot(), mode=mode) File "/opt/odoo/custom/src/odoo/odoo/tools/convert.py", line 764, in parse
exc_info[2] File "/opt/odoo/custom/src/odoo/odoo/tools/pycompat.py", line 86, in
reraise
raise value.with_traceback(tb) File "/opt/odoo/custom/src/odoo/odoo/tools/convert.py", line 758, in parse
self._tags[rec.tag](rec, de, mode=mode) File "/opt/odoo/custom/src/odoo/odoo/tools/convert.py", line 663, in
_tag_record
record = model.with_context(rec_context)._load_records([data], self.mode == 'update') File
"/opt/odoo/custom/src/odoo/odoo/models.py", line 3883, in
_load_records
data['record']._load_records_write(data['values']) File "/opt/odoo/custom/src/odoo/odoo/addons/base/models/ir_ui_view.py",
line 1542, in _load_records_write
super(View, self)._load_records_write(values) File "/opt/odoo/custom/src/odoo/odoo/models.py", line 3821, in
_load_records_write
self.write(values) File "/opt/odoo/custom/src/odoo/odoo/addons/base/models/ir_ui_view.py",
line 445, in write
res = super(View, self).write(self._compute_defaults(vals)) File "/opt/odoo/custom/src/odoo/odoo/models.py", line 3392, in write
fields[0].determine_inverse(records) File "/opt/odoo/custom/src/odoo/odoo/fields.py", line 1200, in
determine_inverse
getattr(records, self.inverse)() File "/opt/odoo/custom/src/odoo/odoo/addons/base/models/ir_ui_view.py",
line 275, in _inverse_arch
view.write(data) File "/opt/odoo/custom/src/odoo/odoo/addons/base/models/ir_ui_view.py",
line 445, in write
res = super(View, self).write(self._compute_defaults(vals)) File "/opt/odoo/custom/src/odoo/odoo/models.py", line 3366, in write
self._write(store_vals) File "/opt/odoo/custom/src/odoo/odoo/models.py", line 3502, in _write
self._validate_fields(vals) File "/opt/odoo/custom/src/odoo/odoo/models.py", line 1132, in
validate_fields
raise ValidationError("%s\n\n%s" % (("Error while validating constraint"), tools.ustr(e))) odoo.tools.convert.ParseError: "Error
while validating constraint
Field client_order_ref does not exist
Error context: View account_invoice_tree_inherit [view_id: 1311,
xml_id: cloudpiles_custom.invoice_tree, model: account.invoice,
parent_id: 681] None" while parsing
/opt/odoo/auto/addons/cloudpiles_custom/views/account_invoice_view.xml:3,
near
account_invoice_tree_inherit
account.invoice
I guess, you forgot an important point about inheritance from odoo's models...
when you added a new field on existing model in odoo's modules ,first of all you have to upgrading your module with command, not with odoo interface...
just run this command: ./odoo-bin -c /etc/odoo-server.conf -d data_base_name -u module_name
I hope this will help you.

Odoo Server Error : from new_cause odoo.tools.convert.ParseError: while parsing near

i got error when i add field into views.xml file.
when i am trying to update myb custom module which a field is links to a new model i am getting.
error : odoo.tools.convert.ParseError
can you please help me
please give me answer for this.
i installed odoo 14 version on my ubuntu system
Error:
Odoo Server Error
Traceback (most recent call last):
File "/odoo-14/odoo-14-server/odoo/tools/convert.py", line 677, in _tag_root
f(rec)
File "/odoo-14/odoo-14-server/odoo/tools/convert.py", line 492, in _tag_record
model = env[rec_model]
File "/odoo-14/odoo-14-server/odoo/api.py", line 476, in __getitem__
return self.registry[model_name]._browse(self, (), ())
File "/odoo-14/odoo-14-server/odoo/modules/registry.py", line 177, in __getitem__
return self.models[model_name]
KeyError: 'view_order_form_inherit_new'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/odoo-14/odoo-14-server/odoo/addons/base/models/ir_http.py", line 237, in _dispatch
result = request.dispatch()
File "/odoo-14/odoo-14-server/odoo/http.py", line 683, in dispatch
result = self._call_function(**self.params)
File "/odoo-14/odoo-14-server/odoo/http.py", line 359, in _call_function
return checked_call(self.db, *args, **kwargs)
File "/odoo-14/odoo-14-server/odoo/service/model.py", line 94, in wrapper
return f(dbname, *args, **kwargs)
File "/odoo-14/odoo-14-server/odoo/http.py", line 347, in checked_call
result = self.endpoint(*a, **kw)
File "/odoo-14/odoo-14-server/odoo/http.py", line 912, in __call__
return self.method(*args, **kw)
File "/odoo-14/odoo-14-server/odoo/http.py", line 531, in response_wrap
response = f(*args, **kw)
File "/odoo-14/odoo-14-server/addons/web/controllers/main.py", line 1394, in call_button
action = self._call_kw(model, method, args, kwargs)
File "/odoo-14/odoo-14-server/addons/web/controllers/main.py", line 1382, in _call_kw
return call_kw(request.env[model], method, args, kwargs)
File "/odoo-14/odoo-14-server/odoo/api.py", line 399, in call_kw
result = _call_kw_multi(method, model, args, kwargs)
File "/odoo-14/odoo-14-server/odoo/api.py", line 386, in _call_kw_multi
result = method(recs, *args, **kwargs)
File "<decorator-gen-78>", line 2, in button_immediate_upgrade
File "/odoo-14/odoo-14-server/odoo/addons/base/models/ir_module.py", line 74, in check_and_log
return method(self, *args, **kwargs)
File "/odoo-14/odoo-14-server/odoo/addons/base/models/ir_module.py", line 654, in button_immediate_upgrade
return self._button_immediate_function(type(self).button_upgrade)
File "/odoo-14/odoo-14-server/odoo/addons/base/models/ir_module.py", line 593, in _button_immediate_function
modules.registry.Registry.new(self._cr.dbname, update_module=True)
File "/odoo-14/odoo-14-server/odoo/modules/registry.py", line 89, in new
odoo.modules.load_modules(registry._db, force_demo, status, update_module)
File "/odoo-14/odoo-14-server/odoo/modules/loading.py", line 455, in load_modules
processed_modules += load_marked_modules(cr, graph,
File "/odoo-14/odoo-14-server/odoo/modules/loading.py", line 347, in load_marked_modules
loaded, processed = load_module_graph(
File "/odoo-14/odoo-14-server/odoo/modules/loading.py", line 222, in load_module_graph
load_data(cr, idref, mode, kind='data', package=package)
File "/odoo-14/odoo-14-server/odoo/modules/loading.py", line 69, in load_data
tools.convert_file(cr, package.name, filename, idref, mode, noupdate, kind)
File "/odoo-14/odoo-14-server/odoo/tools/convert.py", line 733, in convert_file
convert_xml_import(cr, module, fp, idref, mode, noupdate)
File "/odoo-14/odoo-14-server/odoo/tools/convert.py", line 799, in convert_xml_import
obj.parse(doc.getroot())
File "/odoo-14/odoo-14-server/odoo/tools/convert.py", line 719, in parse
self._tag_root(de)
File "/odoo-14/odoo-14-server/odoo/tools/convert.py", line 677, in _tag_root
f(rec)
File "/odoo-14/odoo-14-server/odoo/tools/convert.py", line 681, in _tag_root
raise ParseError('while parsing %s:%s, near\n%s' % (
Exception
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/odoo-14/odoo-14-server/odoo/http.py", line 639, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception)
File "/odoo-14/odoo-14-server/odoo/http.py", line 315, in _handle_exception
raise exception.with_traceback(None) from new_cause
odoo.tools.convert.ParseError: while parsing /odoo-14/custom/addons/om_odoo_inheritance/views/sale_order.xml:4, near
<record id="ir.ui.view" model="view_order_form_inherit_new">
<field name="name">sale.order.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='payment_term_id']" position="after">
<field name="confirmed_user_id"/>
</xpath>
</field>
</record>
You've mixed up id and model. You have to swap them:
<record id="view_order_form_inherit_new" model="ir.ui.view">

Odoo15 custom module creation

I just created my new custom module, but I'd like to have the form view present in the module.
I used the scaffold method to drag all the required files for the module, but when I try to affect the file view.xml so I can reflect the fields I already have included It gives me an error and I don't know how to solve it.
This is the code I have for view.xml:
<odoo>
<data>
<!-- explicit list view definition -->
<record model="ir.ui.view" id="secondmodule.list">
<field name="name">secondmodule list</field>
<field name="model">second.module</field>
<field name="arch" type="xml">
<tree>
<field name="name"/>
<field name="value"/>
<field name="value2"/>
</tree>
</field>
</record>
<!-- actions opening views on models -->
<record model="ir.actions.act_window" id="secondmodule.action_window">
<field name="name">secondmodule window</field>
<field name="res_model">second.module</field>
<field name="view_mode">tree,form</field>
</record>
<!-- server action to the one above -->
<record model="ir.actions.server" id="secondmodule.action_server">
<field name="name">secondmodule server</field>
<field name="model_id" ref="model_secondmodule_secondmodule"/>
<field name="state">code</field>
<field name="code">
action = {
"type": "ir.actions.act_window",
"view_mode": "tree,form",
"res_model": model._name,
}
</field>
</record>
<!-- Top menu item -->
<menuitem name="secondmodule" id="secondmodule.menu_root"/>
<!-- menu categories -->
<menuitem name="Part 1" id="secondmodule.menu_1" parent="secondmodule.menu_root"/>
<menuitem name="Part 2" id="secondmodule.menu_2" parent="secondmodule.menu_root"/>
<!-- actions -->
<menuitem name="List" id="secondmodule.menu_1_list" parent="secondmodule.menu_1"
action="secondmodule.action_window"/>
<menuitem name="Server to list" id="secondmodule" parent="secondmodule.menu_2"
action="secondmodule.action_server"/>
</data>
</odoo>
All the code that is written here is from the scaffold method preseted
Now this is the code I have from the models.py file:
from odoo import models, fields,api
class secondmodule(models.Model):
_name = 'second.module'
_description = 'This is the Second Module'
name = fields.Char(string="name", required=True)
edad = fields.Integer(string="age")
life_goal = fields.Text(string="Wh?")
favorite_thing = fields.Char(string="Que le gusta hacer?")
end_date = fields.Date(string="Ultima fecha de felicidad")
value = fields.Date(string="value")
value2 = fields.Date(string="value2")
So everything looks cool until now, and then this error comes up when I try to upgrade the model in the apps section:
Traceback (most recent call last):
File "C:\odooo\odoo\odoo\tools\cache.py", line 85, in lookup
r = d[key]
File "C:\odooo\odoo\odoo\tools\func.py", line 71, in wrapper
return func(self, *args, **kwargs)
File "C:\odooo\odoo\odoo\tools\lru.py", line 34, in __getitem__
a = self.d[obj]
KeyError: ('ir.model.data', <function IrModelData._xmlid_lookup at 0x000001CAEB7EE0D0>, 'secondmodule.model_secondmodule_secondmodule')
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\odooo\odoo\odoo\tools\convert.py", line 680, in _tag_root
f(rec)
File "C:\odooo\odoo\odoo\tools\convert.py", line 567, in _tag_record
f_val = self.id_get(f_ref)
File "C:\odooo\odoo\odoo\tools\convert.py", line 663, in id_get
res = self.model_id_get(id_str, raise_if_not_found)
File "C:\odooo\odoo\odoo\tools\convert.py", line 669, in model_id_get
return self.env['ir.model.data']._xmlid_to_res_model_res_id(id_str, raise_if_not_found=raise_if_not_found)
File "C:\odooo\odoo\odoo\addons\base\models\ir_model.py", line 1935, in _xmlid_to_res_model_res_id
return self._xmlid_lookup(xmlid)[1:3]
File "<decorator-gen-35>", line 2, in _xmlid_lookup
File "C:\odooo\odoo\odoo\tools\cache.py", line 90, in lookup
value = d[key] = self.method(*args, **kwargs)
File "C:\odooo\odoo\odoo\addons\base\models\ir_model.py", line 1928, in _xmlid_lookup
raise ValueError('External ID not found in the system: %s' % xmlid)
ValueError: External ID not found in the system: secondmodule.model_secondmodule_secondmodule
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\odooo\odoo\odoo\addons\base\models\ir_http.py", line 237, in _dispatch
result = request.dispatch()
File "C:\odooo\odoo\odoo\http.py", line 688, in dispatch
result = self._call_function(**self.params)
File "C:\odooo\odoo\odoo\http.py", line 360, in _call_function
return checked_call(self.db, *args, **kwargs)
File "C:\odooo\odoo\odoo\service\model.py", line 94, in wrapper
return f(dbname, *args, **kwargs)
File "C:\odooo\odoo\odoo\http.py", line 349, in checked_call
result = self.endpoint(*a, **kw)
File "C:\odooo\odoo\odoo\http.py", line 917, in __call__
return self.method(*args, **kw)
File "C:\odooo\odoo\odoo\http.py", line 536, in response_wrap
response = f(*args, **kw)
File "c:\odooo\odoo\addons\web\controllers\main.py", line 1352, in call_button
action = self._call_kw(model, method, args, kwargs)
File "c:\odooo\odoo\addons\web\controllers\main.py", line 1340, in _call_kw
return call_kw(request.env[model], method, args, kwargs)
File "C:\odooo\odoo\odoo\api.py", line 464, in call_kw
result = _call_kw_multi(method, model, args, kwargs)
File "C:\odooo\odoo\odoo\api.py", line 451, in _call_kw_multi
result = method(recs, *args, **kwargs)
File "<decorator-gen-80>", line 2, in button_immediate_upgrade
File "C:\odooo\odoo\odoo\addons\base\models\ir_module.py", line 74, in check_and_log
return method(self, *args, **kwargs)
File "C:\odooo\odoo\odoo\addons\base\models\ir_module.py", line 662, in button_immediate_upgrade
return self._button_immediate_function(type(self).button_upgrade)
File "C:\odooo\odoo\odoo\addons\base\models\ir_module.py", line 600, in _button_immediate_function
registry = modules.registry.Registry.new(self._cr.dbname, update_module=True)
File "C:\odooo\odoo\odoo\modules\registry.py", line 87, in new
odoo.modules.load_modules(registry, force_demo, status, update_module)
File "C:\odooo\odoo\odoo\modules\loading.py", line 470, in load_modules
processed_modules += load_marked_modules(cr, graph,
File "C:\odooo\odoo\odoo\modules\loading.py", line 363, in load_marked_modules
loaded, processed = load_module_graph(
File "C:\odooo\odoo\odoo\modules\loading.py", line 222, in load_module_graph
load_data(cr, idref, mode, kind='data', package=package)
File "C:\odooo\odoo\odoo\modules\loading.py", line 69, in load_data
tools.convert_file(cr, package.name, filename, idref, mode, noupdate, kind)
File "C:\odooo\odoo\odoo\tools\convert.py", line 745, in convert_file
convert_xml_import(cr, module, fp, idref, mode, noupdate)
File "C:\odooo\odoo\odoo\tools\convert.py", line 811, in convert_xml_import
obj.parse(doc.getroot())
File "C:\odooo\odoo\odoo\tools\convert.py", line 731, in parse
self._tag_root(de)
File "C:\odooo\odoo\odoo\tools\convert.py", line 680, in _tag_root
f(rec)
File "C:\odooo\odoo\odoo\tools\convert.py", line 693, in _tag_root
raise ParseError('while parsing %s:%s, somewhere inside\n%s' % (
Exception
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\odooo\odoo\odoo\http.py", line 644, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception)
File "C:\odooo\odoo\odoo\http.py", line 302, in _handle_exception
raise exception.with_traceback(None) from new_cause
odoo.tools.convert.ParseError: while parsing file:/c:/odooo/odoo/addons/secondmodule/views/views.xml:29, somewhere inside
<record model="ir.actions.server" id="secondmodule.action_server">
<field name="name">secondmodule server</field>
<field name="model_id" ref="model_secondmodule_secondmodule"/>
<field name="state">code</field>
<field name="code">
action = {
"type": "ir.actions.act_window",
"view_mode": "tree,form",
"res_model": model._name,
}
</field>
</record>
Please try to read error (log)
External ID not found in the system: secondmodule.model_secondmodule_secondmodule
That means : odoo can't find this id that exist in your code in action server in "ref" attribute .. so make sure you have a model with this name 'model_secondmodule_secondmodule' and it's file added in init file .
Or remove all lines in your module and then add your models and views because scaffold command add test models and views for you .
Recommended : Create a Module in Odoo

Odoo Server Error while upgrading an Odoo 13 module to Odoo 14

I was trying to upgrade a module from Odoo 13 to Odoo 14 (stock_split_picking to be exact), I found an error that I don't really understand and I can't figure how to fix it.
It's an error that happen when I want to install the module, and after hours of search on the internet, hours of just reading Odoo's code in a hope of understanding what's happening... I just can't understand where is the problem, nothing seems to be anormal from what I've read on Odoo's Documentation on their website.
Here is my error :
Odoo Server Error
Traceback (most recent call last):
File "/opt/odoo/odoo/odoo/tools/convert.py", line 677, in _tag_root
f(rec)
File "/opt/odoo/odoo/odoo/tools/convert.py", line 580, in _tag_record
record = model._load_records([data], self.mode == 'update')
File "/opt/odoo/odoo/odoo/models.py", line 4185, in _load_records
records = self._load_records_create([data['values'] for data in to_create])
File "/opt/odoo/odoo/odoo/models.py", line 4114, in _load_records_create
return self.create(values)
File "<decorator-gen-43>", line 2, in create
File "/opt/odoo/odoo/odoo/api.py", line 345, in _model_create_multi
return create(self, arg)
File "/opt/odoo/odoo/odoo/addons/base/models/ir_ui_view.py", line 482, in create
return super(View, self).create(vals_list)
File "<decorator-gen-65>", line 2, in create
File "/opt/odoo/odoo/odoo/api.py", line 345, in _model_create_multi
return create(self, arg)
File "/opt/odoo/odoo/odoo/addons/base/models/ir_fields.py", line 508, in create
recs = super().create(vals_list)
File "<decorator-gen-13>", line 2, in create
File "/opt/odoo/odoo/odoo/api.py", line 345, in _model_create_multi
return create(self, arg)
File "/opt/odoo/odoo/odoo/models.py", line 3875, in create
fields[0].determine_inverse(batch_recs)
File "/opt/odoo/odoo/odoo/fields.py", line 1128, in determine_inverse
getattr(records, self.inverse)()
File "/opt/odoo/odoo/odoo/addons/base/models/ir_ui_view.py", line 300, in _inverse_arch
view.write(data)
File "/opt/odoo/odoo/odoo/addons/base/models/ir_ui_view.py", line 500, in write
res = super(View, self).write(self._compute_defaults(vals))
File "/opt/odoo/odoo/odoo/models.py", line 3664, in write
real_recs._validate_fields(set(vals) - set(inverse_fields))
File "/opt/odoo/odoo/odoo/models.py", line 1249, in _validate_fields
check(self)
File "/opt/odoo/odoo/odoo/addons/base/models/ir_ui_view.py", line 385, in _check_xml
view_def = view.read_combined(['arch'])
File "/opt/odoo/odoo/odoo/addons/base/models/ir_ui_view.py", line 813, in read_combined
arch = root.apply_view_inheritance(arch_tree, self.model)
File "/opt/odoo/odoo/odoo/addons/base/models/ir_ui_view.py", line 755, in apply_view_inheritance
return self._apply_view_inheritance(source, inherit_tree)
File "/opt/odoo/odoo/odoo/addons/base/models/ir_ui_view.py", line 764, in _apply_view_inheritance
source = view._apply_view_inheritance(source, inherit_tree)
File "/opt/odoo/odoo/odoo/addons/base/models/ir_ui_view.py", line 760, in _apply_view_inheritance
arch_tree = etree.fromstring(view.arch.encode('utf-8'))
File "src/lxml/lxml.etree.pyx", line 3213, in lxml.etree.fromstring (src/lxml/lxml.etree.c:79003)
File "src/lxml/parser.pxi", line 1848, in lxml.etree._parseMemoryDocument (src/lxml/lxml.etree.c:118334)
File "src/lxml/parser.pxi", line 1736, in lxml.etree._parseDoc (src/lxml/lxml.etree.c:117014)
File "src/lxml/parser.pxi", line 1102, in lxml.etree._BaseParser._parseDoc (src/lxml/lxml.etree.c:111258)
File "src/lxml/parser.pxi", line 595, in lxml.etree._ParserContext._handleParseResultDoc (src/lxml/lxml.etree.c:105102)
File "src/lxml/parser.pxi", line 706, in lxml.etree._handleParseResult (src/lxml/lxml.etree.c:106810)
File "src/lxml/parser.pxi", line 646, in lxml.etree._raiseParseError (src/lxml/lxml.etree.c:105956)
File "<string>", line 0
lxml.etree.XMLSyntaxError: <no detail available>
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/opt/odoo/odoo/odoo/addons/base/models/ir_http.py", line 237, in _dispatch
result = request.dispatch()
File "/opt/odoo/odoo/odoo/http.py", line 683, in dispatch
result = self._call_function(**self.params)
File "/opt/odoo/odoo/odoo/http.py", line 359, in _call_function
return checked_call(self.db, *args, **kwargs)
File "/opt/odoo/odoo/odoo/service/model.py", line 94, in wrapper
return f(dbname, *args, **kwargs)
File "/opt/odoo/odoo/odoo/http.py", line 347, in checked_call
result = self.endpoint(*a, **kw)
File "/opt/odoo/odoo/odoo/http.py", line 912, in __call__
return self.method(*args, **kw)
File "/opt/odoo/odoo/odoo/http.py", line 531, in response_wrap
response = f(*args, **kw)
File "/opt/odoo/odoo/addons/web/controllers/main.py", line 1367, in call_button
action = self._call_kw(model, method, args, kwargs)
File "/opt/odoo/odoo/addons/web/controllers/main.py", line 1355, in _call_kw
return call_kw(request.env[model], method, args, kwargs)
File "/opt/odoo/odoo/odoo/api.py", line 396, in call_kw
result = _call_kw_multi(method, model, args, kwargs)
File "/opt/odoo/odoo/odoo/api.py", line 383, in _call_kw_multi
result = method(recs, *args, **kwargs)
File "/opt/odoo/odoo/addons/gfi_base/models/ir_module_module.py", line 35, in button_immediate_install
return super(IrModuleModule, self).button_immediate_install()
File "<decorator-gen-72>", line 2, in button_immediate_install
File "/opt/odoo/odoo/odoo/addons/base/models/ir_module.py", line 73, in check_and_log
return method(self, *args, **kwargs)
File "/opt/odoo/odoo/odoo/addons/base/models/ir_module.py", line 474, in button_immediate_install
return self._button_immediate_function(type(self).button_install)
File "/opt/odoo/odoo/odoo/addons/base/models/ir_module.py", line 592, in _button_immediate_function
modules.registry.Registry.new(self._cr.dbname, update_module=True)
File "/opt/odoo/odoo/odoo/modules/registry.py", line 89, in new
odoo.modules.load_modules(registry._db, force_demo, status, update_module)
File "/opt/odoo/odoo/odoo/modules/loading.py", line 455, in load_modules
loaded_modules, update_module, models_to_check)
File "/opt/odoo/odoo/odoo/modules/loading.py", line 348, in load_marked_modules
perform_checks=perform_checks, models_to_check=models_to_check
File "/opt/odoo/odoo/odoo/modules/loading.py", line 221, in load_module_graph
load_data(cr, idref, mode, kind='data', package=package)
File "/opt/odoo/odoo/odoo/modules/loading.py", line 69, in load_data
tools.convert_file(cr, package.name, filename, idref, mode, noupdate, kind)
File "/opt/odoo/odoo/odoo/tools/convert.py", line 733, in convert_file
convert_xml_import(cr, module, fp, idref, mode, noupdate)
File "/opt/odoo/odoo/odoo/tools/convert.py", line 799, in convert_xml_import
obj.parse(doc.getroot())
File "/opt/odoo/odoo/odoo/tools/convert.py", line 719, in parse
self._tag_root(de)
File "/opt/odoo/odoo/odoo/tools/convert.py", line 677, in _tag_root
f(rec)
File "/opt/odoo/odoo/odoo/tools/convert.py", line 685, in _tag_root
)) from e
Exception
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/opt/odoo/odoo/odoo/http.py", line 639, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception)
File "/opt/odoo/odoo/odoo/http.py", line 315, in _handle_exception
raise exception.with_traceback(None) from new_cause
odoo.tools.convert.ParseError: while parsing /opt/odoo/odoo/addons/stock/views/res_partner_views.xml:8, near
<record id="view_partner_stock_form" model="ir.ui.view">
<field name="name">res.partner.stock.property.form.inherit</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="mail.res_partner_view_form_inherit_mail"/>
<field name="arch" type="xml">
<xpath expr="//page[#name='sales_purchases']/group" position="inside">
<group name="container_row_stock" groups="base.group_no_one" priority="6">
<group string="Inventory" name="inventory" colspan="2">
<field name="property_stock_customer"/>
<field name="property_stock_supplier"/>
</group>
</group>
</xpath>
</field>
</record>
My first thought was that the xpath was bad, but the error is not the same as an xpath error.
I already tried to delete this record for the installation, and then rewrite the record after having installing the module, and magic : the module can be upgraded without any error. Problem is that when we want to use the module, the error come again and make it impossible to use the module.

Odoo: ValueError: Field website_published does not exist

I am currently using Odoo 12 and I have installed the following Apps: CRM, Website, Project, Invoicing, Sales, Notes, Purchase, Employees, Expenses, Contacts, Discuss and Calendar.
Ever since this morning I am unable to open the contacts app. It's throwing the following error:
Error:
Odoo Server Error
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/odoo/http.py", line 654, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception)
File "/usr/lib/python3/dist-packages/odoo/http.py", line 312, in _handle_exception
raise pycompat.reraise(type(exception), exception, sys.exc_info()[2])
File "/usr/lib/python3/dist-packages/odoo/tools/pycompat.py", line 87, in reraise
raise value
File "/usr/lib/python3/dist-packages/odoo/http.py", line 696, in dispatch
result = self._call_function(**self.params)
File "/usr/lib/python3/dist-packages/odoo/http.py", line 344, in _call_function
return checked_call(self.db, *args, **kwargs)
File "/usr/lib/python3/dist-packages/odoo/service/model.py", line 97, in wrapper
return f(dbname, *args, **kwargs)
File "/usr/lib/python3/dist-packages/odoo/http.py", line 337, in checked_call
result = self.endpoint(*a, **kw)
File "/usr/lib/python3/dist-packages/odoo/http.py", line 939, in __call__
return self.method(*args, **kw)
File "/usr/lib/python3/dist-packages/odoo/http.py", line 517, in response_wrap
response = f(*args, **kw)
File "/usr/lib/python3/dist-packages/odoo/addons/web/controllers/main.py", line 962, in call_kw
return self._call_kw(model, method, args, kwargs)
File "/usr/lib/python3/dist-packages/odoo/addons/web/controllers/main.py", line 954, in _call_kw
return call_kw(request.env[model], method, args, kwargs)
File "/usr/lib/python3/dist-packages/odoo/api.py", line 745, in call_kw
return _call_kw_model(method, model, args, kwargs)
File "/usr/lib/python3/dist-packages/odoo/api.py", line 718, in _call_kw_model
result = method(recs, *args, **kwargs)
File "/usr/lib/python3/dist-packages/odoo/models.py", line 1376, in load_views
for [v_id, v_type] in views
File "/usr/lib/python3/dist-packages/odoo/models.py", line 1376, in <dictcomp>
for [v_id, v_type] in views
File "/usr/lib/python3/dist-packages/odoo/addons/mail/models/mail_thread.py", line 410, in fields_view_get
res = super(MailThread, self).fields_view_get(view_id=view_id, view_type=view_type, toolbar=toolbar, submenu=submenu)
File "/usr/lib/python3/dist-packages/odoo/models.py", line 1462, in fields_view_get
xarch, xfields = View.postprocess_and_fields(self._name, etree.fromstring(result['arch']), view_id)
File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_ui_view.py", line 1095, in postprocess_and_fields
self.raise_view_error(message, view_id)
File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_ui_view.py", line 548, in raise_view_error
raise ValueError(message)
ValueError: Field `website_published` does not exist
Error context:
View `res.partner.form`
[view_id: 113, xml_id: base.view_partner_form, model: res.partner, parent_id: n/a]
Is there an easy way to resolve this issue?
For my case:
Edit view: view.res.partner.form.website
Remove the button like following
<?xml version="1.0"?>
<data>
<!--
<button name="toggle_active" position="before">
<button class="oe_stat_button" name="website_publish_button" type="object" icon="fa-globe">
<field name="website_published" widget="website_button"/>
</button>
</button>
-->
</data>

Categories

Resources