How to add a Chatter in existing odoo module - odoo

I am trying to add a chatter in fleet in Vehicles Services Logs
and it give me this error when I am trying to update the inherit module that responsible to add the chatter,
this is the model:
# -*- coding: utf-8 -*-
from odoo import models, fields, api
class Fleet_Chatter_service(models.Model):
_name = 'fleet.chatter.service'
_inherit = ['fleet.vehicle.log.services', 'mail.thread', 'ir.needaction_mixin']
_description = "fleet chatter in cost and service"
this is the view:
<odoo>
<record model="ir.ui.view" id="odt_fleet_service_chatter_form">
<field name="name">odt.fleet.chatter.service</field>
<field name="model">fleet.chatter.service</field>
<field name="inherit_id" ref="fleet.fleet_vehicle_log_services_view_form"/>
<field name="arch" type="xml">
<xpath expr="//form/sheet" position="after">
<div class="oe_chatter">
<field name="message_follower_ids" widget="mail_followers"/>
<field name="activity_ids" widget="mail_activity"/>
<field name="message_ids" widget="mail_thread" />
</div>
</xpath>
</field>
</record>
</odoo>
and this is the error:
Error:
Odoo Server Error
Traceback (most recent call last): File
"C:\odt_work\zawaj\odoo-13\odoo\addons\base\models\ir_ui_view.py",
line 394, in check_xml
self.postprocess_and_fields(view.model, view_doc, view.id) File "C:\odt_work\zawaj\odoo-13\odoo\addons\base\models\ir_ui_view.py",
line 961, in postprocess_and_fields
self.raise_view_error(('Model not found: %(model)s') % dict(model=model), view_id) File
"C:\odt_work\zawaj\odoo-13\odoo\addons\base\models\ir_ui_view.py",
line 614, in raise_view_error
raise ValueError(message) ValueError: Model not found: fleet.chatter.service
Error context: View odt.fleet.chatter.service [view_id: 2990,
xml_id: n/a, model: fleet.chatter.service, parent_id: 494]
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File
"C:\odt_work\zawaj\odoo-13\odoo\tools\convert.py", line 712, in parse
self._tag_root(de) File "C:\odt_work\zawaj\odoo-13\odoo\tools\convert.py", line 674, in
_tag_root
f(rec) File "C:\odt_work\zawaj\odoo-13\odoo\tools\convert.py", line 577, in _tag_record
record = model._load_records([data], self.mode == 'update') File "C:\odt_work\zawaj\odoo-13\odoo\models.py", line 4168, in
_load_records
records = self._load_records_create([data['values'] for data in to_create]) File "C:\odt_work\zawaj\odoo-13\odoo\models.py", line
4082, in _load_records_create
return self.create(values) File "", line 2, in create File "C:\odt_work\zawaj\odoo-13\odoo\api.py", line 336, in
_model_create_multi
return create(self, arg) File "C:\odt_work\zawaj\odoo-13\odoo\addons\base\models\ir_ui_view.py",
line 475, in create
return super(View, self).create(vals_list) File "", line 2, in create File
"C:\odt_work\zawaj\odoo-13\odoo\api.py", line 336, in
_model_create_multi
return create(self, arg) File "C:\odt_work\zawaj\odoo-13\odoo\models.py", line 3843, in create
fields[0].determine_inverse(batch_recs) File "C:\odt_work\zawaj\odoo-13\odoo\fields.py", line 1155, in
determine_inverse
getattr(records, self.inverse)() File "C:\odt_work\zawaj\odoo-13\odoo\addons\base\models\ir_ui_view.py",
line 299, in _inverse_arch
view.write(data) File "C:\odt_work\zawaj\odoo-13\odoo\addons\base\models\ir_ui_view.py",
line 493, in write
res = super(View, self).write(self._compute_defaults(vals)) File "C:\odt_work\zawaj\odoo-13\odoo\models.py", line 3632, in write
real_recs._validate_fields(vals, inverse_fields) File "C:\odt_work\zawaj\odoo-13\odoo\models.py", line 1206, in
_validate_fields
check(self) File "C:\odt_work\zawaj\odoo-13\odoo\addons\base\models\ir_ui_view.py",
line 396, in check_xml
raise ValidationError("%s\n\n%s" % (("Error while validating view"), tools.ustr(e))) odoo.exceptions.ValidationError: ('Error while
validating view\n\nModel not found: fleet.chatter.service\n\nError
context:\nView odt.fleet.chatter.service\n[view_id: 2990, xml_id:
n/a, model: fleet.chatter.service, parent_id: 494]', None)
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File
"C:\odt_work\zawaj\odoo-13\odoo\http.py", line 624, in
_handle_exception
return super(JsonRequest, self)._handle_exception(exception) File "C:\odt_work\zawaj\odoo-13\odoo\http.py", line 310, in
_handle_exception
raise pycompat.reraise(type(exception), exception, sys.exc_info()[2]) File
"C:\odt_work\zawaj\odoo-13\odoo\tools\pycompat.py", line 14, in
reraise
raise value File "C:\odt_work\zawaj\odoo-13\odoo\http.py", line 669, in dispatch
result = self._call_function(**self.params) File "C:\odt_work\zawaj\odoo-13\odoo\http.py", line 350, in _call_function
return checked_call(self.db, *args, **kwargs) File "C:\odt_work\zawaj\odoo-13\odoo\service\model.py", line 94, in wrapper
return f(dbname, *args, **kwargs) File "C:\odt_work\zawaj\odoo-13\odoo\http.py", line 339, in checked_call
result = self.endpoint(*a, **kw) File "C:\odt_work\zawaj\odoo-13\odoo\http.py", line 915, in call
return self.method(*args, **kw) File "C:\odt_work\zawaj\odoo-13\odoo\http.py", line 515, in response_wrap
response = f(*args, **kw) File "c:\odt_work\zawaj\odoo-13\addons\web\controllers\main.py", line 1343,
in call_button
action = self._call_kw(model, method, args, kwargs) File "c:\odt_work\zawaj\odoo-13\addons\web\controllers\main.py", line 1331,
in _call_kw
return call_kw(request.env[model], method, args, kwargs) File "C:\odt_work\zawaj\odoo-13\odoo\api.py", line 387, in call_kw
result = _call_kw_multi(method, model, args, kwargs) File "C:\odt_work\zawaj\odoo-13\odoo\api.py", line 374, in _call_kw_multi
result = method(recs, *args, **kwargs) File "", line 2, in button_immediate_upgrade File
"C:\odt_work\zawaj\odoo-13\odoo\addons\base\models\ir_module.py", line
72, in check_and_log
return method(self, *args, **kwargs) File "C:\odt_work\zawaj\odoo-13\odoo\addons\base\models\ir_module.py", line
634, in button_immediate_upgrade
return self._button_immediate_function(type(self).button_upgrade) File "C:\odt_work\zawaj\odoo-13\odoo\addons\base\models\ir_module.py",
line 573, in _button_immediate_function
modules.registry.Registry.new(self._cr.dbname, update_module=True) File "C:\odt_work\zawaj\odoo-13\odoo\modules\registry.py", line 86, in
new
odoo.modules.load_modules(registry._db, force_demo, status, update_module) File
"C:\odt_work\zawaj\odoo-13\odoo\modules\loading.py", line 419, in
load_modules
force, status, report, loaded_modules, update_module, models_to_check) File
"C:\odt_work\zawaj\odoo-13\odoo\modules\loading.py", line 315, in
load_marked_modules
perform_checks=perform_checks, models_to_check=models_to_check File "C:\odt_work\zawaj\odoo-13\odoo\modules\loading.py", line 225, in
load_module_graph
load_data(cr, idref, mode, kind='data', package=package, report=report) File
"C:\odt_work\zawaj\odoo-13\odoo\modules\loading.py", line 68, in
load_data
tools.convert_file(cr, package.name, filename, idref, mode, noupdate, kind, report) File
"C:\odt_work\zawaj\odoo-13\odoo\tools\convert.py", line 736, in
convert_file
convert_xml_import(cr, module, fp, idref, mode, noupdate, report) File "C:\odt_work\zawaj\odoo-13\odoo\tools\convert.py", line 803, in
convert_xml_import
obj.parse(doc.getroot()) File "C:\odt_work\zawaj\odoo-13\odoo\tools\convert.py", line 721, in parse
exc_info[2] File "C:\odt_work\zawaj\odoo-13\odoo\tools\pycompat.py", line 13, in
reraise
raise value.with_traceback(tb) File "C:\odt_work\zawaj\odoo-13\odoo\tools\convert.py", line 712, in parse
self._tag_root(de) File "C:\odt_work\zawaj\odoo-13\odoo\tools\convert.py", line 674, in
_tag_root
f(rec) File "C:\odt_work\zawaj\odoo-13\odoo\tools\convert.py", line 577, in _tag_record
record = model._load_records([data], self.mode == 'update') File "C:\odt_work\zawaj\odoo-13\odoo\models.py", line 4168, in
_load_records
records = self._load_records_create([data['values'] for data in to_create]) File "C:\odt_work\zawaj\odoo-13\odoo\models.py", line
4082, in _load_records_create
return self.create(values) File "", line 2, in create File "C:\odt_work\zawaj\odoo-13\odoo\api.py", line 336, in
_model_create_multi
return create(self, arg) File "C:\odt_work\zawaj\odoo-13\odoo\addons\base\models\ir_ui_view.py",
line 475, in create
return super(View, self).create(vals_list) File "", line 2, in create File
"C:\odt_work\zawaj\odoo-13\odoo\api.py", line 336, in
_model_create_multi
return create(self, arg) File "C:\odt_work\zawaj\odoo-13\odoo\models.py", line 3843, in create
fields[0].determine_inverse(batch_recs) File "C:\odt_work\zawaj\odoo-13\odoo\fields.py", line 1155, in
determine_inverse
getattr(records, self.inverse)() File "C:\odt_work\zawaj\odoo-13\odoo\addons\base\models\ir_ui_view.py",
line 299, in _inverse_arch
view.write(data) File "C:\odt_work\zawaj\odoo-13\odoo\addons\base\models\ir_ui_view.py",
line 493, in write
res = super(View, self).write(self._compute_defaults(vals)) File "C:\odt_work\zawaj\odoo-13\odoo\models.py", line 3632, in write
real_recs._validate_fields(vals, inverse_fields) File "C:\odt_work\zawaj\odoo-13\odoo\models.py", line 1206, in
_validate_fields
check(self) File "C:\odt_work\zawaj\odoo-13\odoo\addons\base\models\ir_ui_view.py",
line 396, in check_xml
raise ValidationError("%s\n\n%s" % (("Error while validating view"), tools.ustr(e))) odoo.tools.convert.ParseError: "Error while
validating view
Model not found: fleet.chatter.service
Error context:
View `odt.fleet.chatter.service`
[view_id: 2990, xml_id: n/a, model: fleet.chatter.service, parent_id: 494]
None" while parsing file:/c:/odt_work/zawaj/zawaj_custom/odt_fleet_chatter/views/chatter_service_view.xml:1, near
<odoo>
<record model="ir.ui.view" id="odt_fleet_service_chatter_form">
<field name="name">odt.fleet.chatter.service</field>
<field name="model">fleet.chatter.service</field>
<field name="priority" eval="50"/>
<field name="inherit_id" ref="fleet.fleet_vehicle_log_services_view_form"/>
<field name="arch" type="xml">
<xpath expr="//form/sheet" position="after">
<div class="oe_chatter">
<field name="message_follower_ids" widget="mail_followers"/>
<field name="activity_ids" widget="mail_activity"/>
<field name="message_ids" widget="mail_thread"/>
</div>
</xpath>
</field>
</record>
</odoo>

Try to inherit "mail.activity.mixin" as well since it is the one that adds the "activity_ids" field which you use in your view.
# -*- coding: utf-8 -*-
from odoo import models, fields, api
class Fleet_Chatter_service(models.Model):
_name = 'fleet.chatter.service'
_inherit = [
'fleet.vehicle.log.services', 'mail.thread',
'mail.activity.mixin', 'ir.needaction_mixin'
]
_description = "fleet chatter in cost and service"

Inherit "mail.thread" in your class:
class Fleet_Chatter_service(models.Model):
_name = 'fleet.chatter.service'
_inherit = ['mail.thread', 'another.module.needed']
Now you have to add the chatter inside your view:
In case of custom view, put it just after the :
<div class="oe_chatter">
<field name="message_ids" widget="mail_thread"/>
</div>
Same if you are working on an inherited view, use this Xpath :
<xpath expr="//form/sheet" position="after">
<div class="oe_chatter">
<field name="message_ids" widget="mail_thread"/>
</div>
</xpath>
Regards,

Related

Odoo 15 - ValueError: Invalid field 'res_model_id' on model 'mail.activity.type'

I want to migrate my custom module to Odoo 15 code. But I get this kind of error all the time. I cant find a solution. The xml is in my data folder directed like this : custom_modul/data/mail_activity_types.xml. If you see any sytax errors it because I had to change the code a bit because of sensitive information. This code is Odoo 13 code and its working on it fine.
<?xml version="1.0" encoding="utf-8"?>
<odoo noupdate="0">
<record id="mail_activity" model="mail.activity.type">
<field name="name">Expiration</field>
<field name="res_model_id" ref="setup.my_model"/>
<field name="icon">fa-tasks</field>
<field name="force_next">1</field>
<field name="default_description">Please renew Red-Hat-License!</field>
<field name="delay_count">0</field>
</record>
<record id="mail_activity_secure" model="mail.activity.type">
<field name="name">Expiration</field>
<field name="res_model_id" ref="setup.my_model"/>
<field name="icon">fa-tasks</field>
<field name="delay_count">0</field>
</record>
<record id="mail_activity_certificates" model="mail.activity.type">
<field name="name">Expiration</field>
<field name="res_model_id" ref="setup.my_model"/>
<field name="icon">fa-tasks</field>
<field name="delay_count">0</field>
</record>
<record id="mail_activity" model="mail.activity.type">
<field name="name">Expiration</field>
<field name="res_model_id" ref="setup.my_model"/>
<field name="icon">fa-tasks</field>
<field name="delay_count">0</field>
</record>
</odoo>
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/odoo/tools/convert.py", line 680, in _tag_root
f(rec)
File "/usr/lib/python3/dist-packages/odoo/tools/convert.py", line 583, in _tag_record
record = model._load_records([data], self.mode == 'update')
File "/usr/lib/python3/dist-packages/odoo/models.py", line 4398, in _load_records
records = self._load_records_create([data['values'] for data in to_create])
File "/usr/lib/python3/dist-packages/odoo/models.py", line 4327, in _load_records_create
return self.create(values)
File "<decorator-gen-67>", line 2, in create
File "/usr/lib/python3/dist-packages/odoo/api.py", line 413, in _model_create_multi
return create(self, arg)
File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_fields.py", line 613, in create
recs = super().create(vals_list)
File "<decorator-gen-13>", line 2, in create
File "/usr/lib/python3/dist-packages/odoo/api.py", line 413, in _model_create_multi
return create(self, arg)
File "/usr/lib/python3/dist-packages/odoo/models.py", line 4020, in create
raise ValueError("Invalid field %r on model %r" % (key, self._name))
ValueError: Invalid field 'res_model_id' on model 'mail.activity.type'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_http.py", line 237, in _dispatch
result = request.dispatch()
File "/usr/lib/python3/dist-packages/odoo/http.py", line 687, in dispatch
result = self._call_function(**self.params)
File "/usr/lib/python3/dist-packages/odoo/http.py", line 359, in _call_function
return checked_call(self.db, *args, **kwargs)
File "/usr/lib/python3/dist-packages/odoo/service/model.py", line 94, in wrapper
return f(dbname, *args, **kwargs)
File "/usr/lib/python3/dist-packages/odoo/http.py", line 348, in checked_call
result = self.endpoint(*a, **kw)
File "/usr/lib/python3/dist-packages/odoo/http.py", line 916, in __call__
return self.method(*args, **kw)
File "/usr/lib/python3/dist-packages/odoo/http.py", line 535, in response_wrap
response = f(*args, **kw)
File "/usr/lib/python3/dist-packages/odoo/addons/web/controllers/main.py", line 1339, in call_button
action = self._call_kw(model, method, args, kwargs)
File "/usr/lib/python3/dist-packages/odoo/addons/web/controllers/main.py", line 1327, in _call_kw
return call_kw(request.env[model], method, args, kwargs)
File "/usr/lib/python3/dist-packages/odoo/api.py", line 464, in call_kw
result = _call_kw_multi(method, model, args, kwargs)
File "/usr/lib/python3/dist-packages/odoo/api.py", line 451, in _call_kw_multi
result = method(recs, *args, **kwargs)
File "<decorator-gen-74>", line 2, in button_immediate_install
File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_module.py", line 74, in check_and_log
return method(self, *args, **kwargs)
File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_module.py", line 483, in button_immediate_install
return self._button_immediate_function(type(self).button_install)
File "/usr/lib/python3/dist-packages/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 "/usr/lib/python3/dist-packages/odoo/modules/registry.py", line 87, in new
odoo.modules.load_modules(registry, force_demo, status, update_module)
File "/usr/lib/python3/dist-packages/odoo/modules/loading.py", line 474, in load_modules
processed_modules += load_marked_modules(cr, graph,
File "/usr/lib/python3/dist-packages/odoo/modules/loading.py", line 363, in load_marked_modules
loaded, processed = load_module_graph(
File "/usr/lib/python3/dist-packages/odoo/modules/loading.py", line 222, in load_module_graph
load_data(cr, idref, mode, kind='data', package=package)
File "/usr/lib/python3/dist-packages/odoo/modules/loading.py", line 69, in load_data
tools.convert_file(cr, package.name, filename, idref, mode, noupdate, kind)
File "/usr/lib/python3/dist-packages/odoo/tools/convert.py", line 745, in convert_file
convert_xml_import(cr, module, fp, idref, mode, noupdate)
File "/usr/lib/python3/dist-packages/odoo/tools/convert.py", line 811, in convert_xml_import
obj.parse(doc.getroot())
File "/usr/lib/python3/dist-packages/odoo/tools/convert.py", line 731, in parse
self._tag_root(de)
File "/usr/lib/python3/dist-packages/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 "/usr/lib/python3/dist-packages/odoo/http.py", line 643, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception)
File "/usr/lib/python3/dist-packages/odoo/http.py", line 301, in _handle_exception
raise exception.with_traceback(None) from new_cause
odoo.tools.convert.ParseError: while parsing /opt/Odoo/Custom_Addon/customer_instance_setup/data/mail_activity_types.xml:3, somewhere inside
<record id="mail_activity_red_hat" model="mail.activity.type">
<field name="name">Red Hat Expiration</field>
<field name="res_model_id" ref="setup.my_model"/>
<field name="icon">fa-tasks</field>
<field name="force_next">1</field>
<field name="default_description">Please renew License!</field>
<field name="delay_count">0</field>
</record>
The res_model_id field was converted to selection and renamed to res_model.
The following code:
<field name="res_model_id" ref="crm.model_crm_lead"/>
Should be written as follows:
<field name="res_model">crm.lead</field>
The changes are detailed in [FIX] mail: convert res_model_id to selection commit:
Following the removal of read access on ir.model (#69120),
the mail.activity.type model was not accessible to non-admin users due
to the res_model_id many2one field.Before this commit, a project user could not access the Activity Type
menu.Convert it to a selection field with the selection values being
computed in sudo.
The field res_model_id is not existing anymore on model mail.activity.type. You probably should set res_model instead, which is a selection field, but the selection keys are model names (technical names). So for example creating a new type by xml should look like:
<record id="mail_activity_certificates" model="mail.activity.type">
<field name="name">Expiration</field>
<field name="res_model">my.model</field>
<field name="icon">fa-tasks</field>
<field name="delay_count">0</field>
</record>

Odoo Add Button that should redirect to my Module View

I am using a module similar to this one: HR Org Chart
I want to open the view by clicking on a button in Profile Section.
I referred here: Reference
I am getting this error:
Odoo Server Error
Traceback (most recent call last):
File "/home/arijit/Project/odoo/odoo/src/odoo/tools/convert.py", line 678, in _tag_root
f(rec)
File "/home/arijit/Project/odoo/odoo/src/odoo/tools/convert.py", line 493, in _tag_record
model = env[rec_model]
File "/home/arijit/Project/odoo/odoo/src/odoo/api.py", line 533, in __getitem__
return self.registry[model_name]._browse(self, (), ())
File "/home/arijit/Project/odoo/odoo/src/odoo/modules/registry.py", line 177, in __getitem__
return self.models[model_name]
KeyError: 'ir.ui.client'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/arijit/Project/odoo/odoo/src/odoo/addons/base/models/ir_http.py", line 237, in _dispatch
result = request.dispatch()
File "/home/arijit/Project/odoo/odoo/src/odoo/http.py", line 683, in dispatch
result = self._call_function(**self.params)
File "/home/arijit/Project/odoo/odoo/src/odoo/http.py", line 359, in _call_function
return checked_call(self.db, *args, **kwargs)
File "/home/arijit/Project/odoo/odoo/src/odoo/service/model.py", line 94, in wrapper
return f(dbname, *args, **kwargs)
File "/home/arijit/Project/odoo/odoo/src/odoo/http.py", line 347, in checked_call
result = self.endpoint(*a, **kw)
File "/home/arijit/Project/odoo/odoo/src/odoo/http.py", line 912, in __call__
return self.method(*args, **kw)
File "/home/arijit/Project/odoo/odoo/src/odoo/http.py", line 531, in response_wrap
response = f(*args, **kw)
File "/home/arijit/Project/odoo/odoo/src/addons/web/controllers/main.py", line 1367, in call_button
action = self._call_kw(model, method, args, kwargs)
File "/home/arijit/Project/odoo/odoo/src/addons/web/controllers/main.py", line 1355, in _call_kw
return call_kw(request.env[model], method, args, kwargs)
File "/home/arijit/Project/odoo/odoo/src/odoo/api.py", line 456, in call_kw
result = _call_kw_multi(method, model, args, kwargs)
File "/home/arijit/Project/odoo/odoo/src/odoo/api.py", line 443, in _call_kw_multi
result = method(recs, *args, **kwargs)
File "<decorator-gen-77>", line 2, in button_immediate_upgrade
File "/home/arijit/Project/odoo/odoo/src/odoo/addons/base/models/ir_module.py", line 73, in check_and_log
return method(self, *args, **kwargs)
File "/home/arijit/Project/odoo/odoo/src/odoo/addons/base/models/ir_module.py", line 656, in button_immediate_upgrade
return self._button_immediate_function(type(self).button_upgrade)
File "/home/arijit/Project/odoo/odoo/src/odoo/addons/base/models/ir_module.py", line 595, in _button_immediate_function
modules.registry.Registry.new(self._cr.dbname, update_module=True)
File "/home/arijit/Project/odoo/odoo/src/odoo/modules/registry.py", line 89, in new
odoo.modules.load_modules(registry._db, force_demo, status, update_module)
File "/home/arijit/Project/odoo/odoo/src/odoo/modules/loading.py", line 465, in load_modules
processed_modules += load_marked_modules(cr, graph,
File "/home/arijit/Project/odoo/odoo/src/odoo/modules/loading.py", line 362, in load_marked_modules
loaded, processed = load_module_graph(
File "/home/arijit/Project/odoo/odoo/src/odoo/modules/loading.py", line 221, in load_module_graph
load_data(cr, idref, mode, kind='data', package=package)
File "/home/arijit/Project/odoo/odoo/src/odoo/modules/loading.py", line 69, in load_data
tools.convert_file(cr, package.name, filename, idref, mode, noupdate, kind)
File "/home/arijit/Project/odoo/odoo/src/odoo/tools/convert.py", line 734, in convert_file
convert_xml_import(cr, module, fp, idref, mode, noupdate)
File "/home/arijit/Project/odoo/odoo/src/odoo/tools/convert.py", line 800, in convert_xml_import
obj.parse(doc.getroot())
File "/home/arijit/Project/odoo/odoo/src/odoo/tools/convert.py", line 720, in parse
self._tag_root(de)
File "/home/arijit/Project/odoo/odoo/src/odoo/tools/convert.py", line 682, 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 "/home/arijit/Project/odoo/odoo/src/odoo/http.py", line 639, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception)
File "/home/arijit/Project/odoo/odoo/src/odoo/http.py", line 315, in _handle_exception
raise exception.with_traceback(None) from new_cause
odoo.tools.convert.ParseError: while parsing /home/arijit/Project/odoo/odoo/src/addons/hr_organizational_chart/views/show_employee_chart.xml:21, near
<record id="action_organizational_chart" model="ir.ui.client">
<field name="inherit_id" ref="hr.view_employee_form"/>
<field name="arch" type="xml">
<div id="o_work_employee_main" position="after">
<div id="o_employee_right">
<button name="%(hr_organization_chart.action_organizational_chart)d" type="action" string="Submit"/>
</div>
</div>
</field>
</record>
I want to add a button in the Employee profile section which should open up the module chart view.
Trying something like this to add the button in my profile section:
<field name="inherit_id" ref="hr.view_employee_form"/>
<field name="arch" type="xml">
<div id="o_work_employee_main" position="after">
<div id="o_employee_right">
<button name="%(hr_organization_chart.action_organizational_chart)d" type="action" string="Submit" />
</div>
</div>
</field>
The action_organizational_chart you want to reference from button is of type ir.ui.client which is not an action, its a view.
You should first create an ir.actions.act_window action that reference to your view, and then reference your button to that action instead of your view.

How can I migrate a custom submenu with ir.actions.server from Odoo9 to Odoo12?

I have a module with custom submenu for transfers in Odoo9.
In the xml, I have this code:
<record id='action_menu_location_transfer_server' model='ir.actions.server'>
<field name="name">Custom Transfers</field>
<field name="model_id" ref="model_wizard_location_transfers_internal_transfer"/>
<field name="state">code</field>
<field name="code">action = self.custom_get_transfer_views(cr, uid, context=context)</field>
<field eval="True" name="condition"/>
</record>
<menuitem id="menu_refund_returns"
name="Custom Transfers"
action="action_menu_location_transfer_server"
parent="stock.menu_stock_warehouse_mgmt"
sequence="1"
groups="base.group_user"/>
But in Odoo12, if I try to use the code, it shows this error:
Odoo Server Error
Traceback (most recent call last):
File "/etc/odoo/server12/odoo/tools/safe_eval.py", line 350, in safe_eval
return unsafe_eval(c, globals_dict, locals_dict)
File "", line 1, in <module>
NameError: name 'self' is not defined
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/etc/odoo/server12/odoo/http.py", line 656, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception)
File "/etc/odoo/server12/odoo/http.py", line 314, in _handle_exception
raise pycompat.reraise(type(exception), exception, sys.exc_info()[2])
File "/etc/odoo/server12/odoo/tools/pycompat.py", line 87, in reraise
raise value
File "/etc/odoo/server12/odoo/http.py", line 698, in dispatch
result = self._call_function(**self.params)
File "/etc/odoo/server12/odoo/http.py", line 346, in _call_function
return checked_call(self.db, *args, **kwargs)
File "/etc/odoo/server12/odoo/service/model.py", line 97, in wrapper
return f(dbname, *args, **kwargs)
File "/etc/odoo/server12/odoo/http.py", line 339, in checked_call
result = self.endpoint(*a, **kw)
File "/etc/odoo/server12/odoo/http.py", line 941, in __call__
return self.method(*args, **kw)
File "/etc/odoo/server12/odoo/http.py", line 519, in response_wrap
response = f(*args, **kw)
File "/etc/odoo/server12/addons/web/controllers/main.py", line 1269, in run
result = request.env['ir.actions.server'].browse([action_id]).run()
File "/etc/odoo/server12/odoo/addons/base/models/ir_actions.py", line 553, in run
res = func(action, eval_context=eval_context)
File "/etc/odoo/server12/odoo/addons/base/models/ir_actions.py", line 444, in run_action_code_multi
safe_eval(action.sudo().code.strip(), eval_context, mode="exec", nocopy=True) # nocopy allows to return 'action'
File "/etc/odoo/server12/odoo/tools/safe_eval.py", line 373, in safe_eval
pycompat.reraise(ValueError, ValueError('%s: "%s" while evaluating\n%r' % (ustr(type(e)), ustr(e), expr)), exc_info[2])
File "/etc/odoo/server12/odoo/tools/pycompat.py", line 86, in reraise
raise value.with_traceback(tb)
File "/etc/odoo/server12/odoo/tools/safe_eval.py", line 350, in safe_eval
return unsafe_eval(c, globals_dict, locals_dict)
File "", line 1, in <module>
ValueError: <class 'NameError'>: "name 'self' is not defined" while evaluating
'action = self.custom_get_transfer_views(cr, uid, context=context)'
What is the problem with the code for Odoo 12?
I have tried with self, record, object and nothing changes.
you can try this
<record id='action_menu_location_transfer_server' model='ir.actions.server'>
<field name="name">Custom Transfers</field>
<field name="model_id" ref="model_wizard_location_transfers_internal_transfer"/>
<field name="state">code</field>
<field name="code">model.custom_get_transfer_views()</field>
<field eval="True" name="condition"/>
</record>
the 'cr, uid,' no longer used in v12,
you can add the code of the 'custom_get_transfer_views' method to correct

Field not exist in odoo

I have error
2016-08-03 08:07:05,005 29822 ERROR odoov8 openerp.addons.base.ir.ir_ui_view: Field `shipaddr` not exist
My model extend sale.order:
from openerp.osv import osv, fields
class sale_order(osv.osv):
_inherit = 'sale.order'
_columns = {
#shipaddr = fields.Many2many('res.partner', string="Shipping address", readonly=False),
'shipaddr' : fields.many2many('res.partner', 'vips_shop_order_to_ship_rel', 'order_id', 'shipping_address_id', string="Shipping address"),
}
While I not added template for view all work fine (field not created but i haven't error)
<record model="ir.ui.view" id="sale_order_shipaddr_form_view">
<field name="name">order.shipaddr</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_order_form"/>
<field name="arch" type="xml">
<notebook position="inside">
<page string="Shipping address">
<group>
<field name="shipaddr"/>
</group>
</page>
</notebook>
</field>
</record>
After added this template I receive error in top. I received also this:
2016-08-03 08:07:05,022 29822 ERROR odoov8 werkzeug: Error on request:
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/werkzeug/serving.py", line 177, in run_wsgi
execute(self.server.app)
File "/usr/local/lib/python2.7/dist-packages/werkzeug/serving.py", line 165, in execute
application_iter = app(environ, start_response)
File "/home/skif/odoo/openerp/service/server.py", line 291, in app
return self.app(e, s)
File "/home/skif/odoo/openerp/service/wsgi_server.py", line 216, in application
return application_unproxied(environ, start_response)
File "/home/skif/odoo/openerp/service/wsgi_server.py", line 202, in application_unproxied
result = handler(environ, start_response)
File "/home/skif/odoo/openerp/http.py", line 1293, in __call__
return self.dispatch(environ, start_response)
File "/home/skif/odoo/openerp/http.py", line 1267, in __call__
return self.app(environ, start_wrapped)
File "/usr/local/lib/python2.7/dist-packages/werkzeug/wsgi.py", line 588, in __call__
return self.app(environ, start_response)
File "/home/skif/odoo/openerp/http.py", line 1431, in dispatch
ir_http = request.registry['ir.http']
File "/home/skif/odoo/openerp/http.py", line 349, in registry
return openerp.modules.registry.RegistryManager.get(self.db) if self.db else None
File "/home/skif/odoo/openerp/modules/registry.py", line 339, in get
update_module)
File "/home/skif/odoo/openerp/modules/registry.py", line 370, in new
openerp.modules.load_modules(registry._db, force_demo, status, update_module)
File "/home/skif/odoo/openerp/modules/loading.py", line 351, in load_modules
force, status, report, loaded_modules, update_module)
File "/home/skif/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 "/home/skif/odoo/openerp/modules/loading.py", line 176, in load_module_graph
_load_data(cr, module_name, idref, mode, kind='data')
File "/home/skif/odoo/openerp/modules/loading.py", line 118, in _load_data
tools.convert_file(cr, module_name, filename, idref, mode, noupdate, kind, report)
File "/home/skif/odoo/openerp/tools/convert.py", line 900, in convert_file
convert_xml_import(cr, module, fp, idref, mode, noupdate, report)
File "/home/skif/odoo/openerp/tools/convert.py", line 986, in convert_xml_import
obj.parse(doc.getroot(), mode=mode)
File "/home/skif/odoo/openerp/tools/convert.py", line 852, in parse
self._tags[rec.tag](self.cr, rec, n, mode=mode)
File "/home/skif/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 "/home/skif/odoo/openerp/api.py", line 268, in wrapper
return old_api(self, *args, **kwargs)
File "/home/skif/odoo/openerp/addons/base/ir/ir_model.py", line 1065, in _update
res_id = model_obj.create(cr, uid, values, context=context)
File "/home/skif/odoo/openerp/api.py", line 268, in wrapper
return old_api(self, *args, **kwargs)
File "/home/skif/odoo/openerp/addons/base/ir/ir_ui_view.py", line 255, in create
context=context)
File "/home/skif/odoo/openerp/api.py", line 268, in wrapper
return old_api(self, *args, **kwargs)
File "/home/skif/odoo/openerp/api.py", line 372, in old_api
result = method(recs, *args, **kwargs)
File "/home/skif/odoo/openerp/models.py", line 4094, in create
record = self.browse(self._create(old_vals))
File "/home/skif/odoo/openerp/api.py", line 266, in wrapper
return new_api(self, *args, **kwargs)
File "/home/skif/odoo/openerp/api.py", line 508, in new_api
result = method(self._model, cr, uid, *args, **old_kwargs)
File "/home/skif/odoo/openerp/models.py", line 4285, in _create
recs._validate_fields(vals)
File "/home/skif/odoo/openerp/api.py", line 266, in wrapper
return new_api(self, *args, **kwargs)
File "/home/skif/odoo/openerp/models.py", line 1271, in _validate_fields
raise ValidationError('
'.join(errors))
ParseError: "ValidateError
Field(s) `arch` failed against a constraint: Invalid view definition
Error details:
Field `shipaddr` not exist
Context error:
View `order.shipaddr`
[view_id: 1642, xml_id: n/a, model: sale.order, parent_id: 582]" while parsing /home/skif/odoo/my-modules/vips_shop/views/sale_order.xml:5, near
<record model="ir.ui.view" id="sale_order_shipaddr_form_view">
<field name="name">order.shipaddr</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_order_form"/>
<field name="arch" type="xml">
<notebook position="inside">
<page string="Shipping address">
<group>
<field name="shipaddr"/>
</group>
</page>
</notebook>
</field>
</record>
Why did not create a field in my model?
__openerp__.py
{
###
# any module necessary for this one to work correctly
'depends': ['base','sale', 'product', 'vips_vc'],
###
}
Module sale is using osv.osv model. Documentation for Odoo8 specified model.Model for create columns. I can not find doc for osv. This construction i wrote using code other modules. May be it not right.
Where have I error? Where am I can read doc for osv?
Thanks to Rawly for answer
In file openerp.py I fogot to add 'import sale_order'.
Now this file contains:
import controllers
import models
import partner
import product
import sale_order
As you see I added sale_order.
All working fine

Odoo inheritance issue

I have develop a module for odoo 8.
When I tried to deploy it a I got this error:
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 "/opt/odoo/addons/web/controllers/main.py", line 948, in call_button
action = self._call_kw(model, method, args, {})
File "/opt/odoo/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 "/opt/odoo/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 "/opt/odoo/openerp/api.py", line 268, in wrapper
return old_api(self, *args, **kwargs)
File "/opt/odoo/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 355, in load_modules
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 "/opt/odoo/openerp/addons/base/ir/ir_model.py", line 1065, in _update
res_id = model_obj.create(cr, uid, values, context=context)
File "/opt/odoo/openerp/api.py", line 268, in wrapper
return old_api(self, *args, **kwargs)
File "/opt/odoo/openerp/addons/base/ir/ir_ui_view.py", line 255, in create
context=context)
File "/opt/odoo/openerp/api.py", line 268, in wrapper
return old_api(self, *args, **kwargs)
File "/opt/odoo/openerp/api.py", line 372, in old_api
result = method(recs, *args, **kwargs)
File "/opt/odoo/openerp/models.py", line 4093, in create
record = self.browse(self._create(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 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
Error details:
Field `note` does not exist
Error context:
View `hr.skill form`
[view_id: 1027, xml_id: n/a, model: hr.skill, parent_id: 849]" while parsing /opt/odoo/addons/nge_skills_management/skill.xml:32, near
<record id="view_skill_form_inherit" model="ir.ui.view">
<field name="model">hr.skill</field>
<field name="inherit_id" ref="hr_skill.view_skill_form"/>
<field name="arch" type="xml">
<xpath expr="//field[#name='name']" position="after">
<field name="note" string="Note"/>
</xpath>
</field>
</record>
But When I check my database I found the note field:
select * from nge_skills_management_hr_skill;
id | parent_left | parent_right | create_uid | create_date | name | write_uid | note | parent_id | write_date | active
----+-------------+--------------+------------+-------------+------+-----------+------+-----------+------------+--------
There are my source code:
skill.py
from openerp import api, fields, models
class hr_skill(models.Model):
_inherit = "hr.skill"
_name = "nge_skills_management.hr_skill"
note = fields.Selection([('a', '3'),('b', '2'),('c', '1')])
skill.xml
<menuitem id="main_skill_menu" name="Nge Skills" />
<menuitem id="skill_menu" name="My skills"
parent="main_skill_menu" />
<record id="action_home_page" model="ir.actions.client">
<field name="name">Skill Home</field>
<field name="tag">nge_skills_management.homepage</field>
</record>
<menuitem id="home_page_skill_menu" name="Home Page" parent="skill_menu"
action="action_home_page"/>
<record model="ir.actions.act_window" id="nge_skills_action">
<field name="name">NGE Skills</field>
<field name="res_model">hr.skill</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="domain">[["parent_id.name", "=", "Programmation"]]</field>
</record>
<record id="view_skill_form_inherit" model="ir.ui.view">
<field name="model">hr.skill</field>
<field name="inherit_id" ref="hr_skill.view_skill_form"/>
<field name="arch" type="xml">
<xpath expr="//field[#name='name']" position="after">
<field name="note" string="Note"/>
</xpath>
</field>
</record>
<menuitem id="nge_skills_action_menu" name="NGE SKILLS" parent="skill_menu"
action="nge_skills_action"/>
Can anyone help me please !!
In odoo specifying _name creates a new table in the database (the name of the module is the name of the database table with the . replaced with _).
The problem is you are using:
_name = 'nge_skills_management.hr_skill' which is going to create a new table with the fields in hr.skill and add a notes field to it not to the hr_skill module
what you want (Normal inheritance) is simply to specify _inherit='hr.skill' only. this will enable you add new fields or new methods to the hr.skill model