Related
I got an error while trying to reinstall my modulo, I think that was not the error.
I was reviewing other modules and could be that I typed something for error but the error does not appear in my editor and in the console just show the KeyError: '\x7f'
Traceback (most recent call last):
File "/home/cristian/odoo_practice/odoo/addons/base/models/ir_http.py", line 237, in _dispatch
result = request.dispatch()
File "/home/cristian/odoo_practice/odoo/http.py", line 683, in dispatch
result = self._call_function(**self.params)
File "/home/cristian/odoo_practice/odoo/http.py", line 359, in _call_function
return checked_call(self.db, *args, **kwargs)
File "/home/cristian/odoo_practice/odoo/service/model.py", line 94, in wrapper
return f(dbname, *args, **kwargs)
File "/home/cristian/odoo_practice/odoo/http.py", line 347, in checked_call
result = self.endpoint(*a, **kw)
File "/home/cristian/odoo_practice/odoo/http.py", line 912, in __call__
return self.method(*args, **kw)
File "/home/cristian/odoo_practice/odoo/http.py", line 531, in response_wrap
response = f(*args, **kw)
File "/home/cristian/odoo_practice/addons/web/controllers/main.py", line 1398, in call_button
action = self._call_kw(model, method, args, kwargs)
File "/home/cristian/odoo_practice/addons/web/controllers/main.py", line 1386, in _call_kw
return call_kw(request.env[model], method, args, kwargs)
File "/home/cristian/odoo_practice/odoo/api.py", line 399, in call_kw
result = _call_kw_multi(method, model, args, kwargs)
File "/home/cristian/odoo_practice/odoo/api.py", line 386, in _call_kw_multi
result = method(recs, *args, **kwargs)
File "<decorator-gen-72>", line 2, in button_immediate_install
File "/home/cristian/odoo_practice/odoo/addons/base/models/ir_module.py", line 74, in check_and_log
return method(self, *args, **kwargs)
File "/home/cristian/odoo_practice/odoo/addons/base/models/ir_module.py", line 475, in button_immediate_install
return self._button_immediate_function(type(self).button_install)
File "/home/cristian/odoo_practice/odoo/addons/base/models/ir_module.py", line 593, in _button_immediate_function
modules.registry.Registry.new(self._cr.dbname, update_module=True)
File "/home/cristian/odoo_practice/odoo/modules/registry.py", line 89, in new
odoo.modules.load_modules(registry._db, force_demo, status, update_module)
File "/home/cristian/odoo_practice/odoo/modules/loading.py", line 459, in load_modules
processed_modules += load_marked_modules(cr, graph,
File "/home/cristian/odoo_practice/odoo/modules/loading.py", line 347, in load_marked_modules
loaded, processed = load_module_graph(
File "/home/cristian/odoo_practice/odoo/modules/loading.py", line 222, in load_module_graph
load_data(cr, idref, mode, kind='data', package=package)
File "/home/cristian/odoo_practice/odoo/modules/loading.py", line 69, in load_data
tools.convert_file(cr, package.name, filename, idref, mode, noupdate, kind)
File "/home/cristian/odoo_practice/odoo/tools/convert.py", line 729, in convert_file
convert_csv_import(cr, module, pathname, fp.read(), idref, mode, noupdate)
File "/home/cristian/odoo_practice/odoo/tools/convert.py", line 771, in convert_csv_import
result = env[model].load(fields, datas)
File "/home/cristian/odoo_practice/odoo/models.py", line 1010, in load
if isinstance(model_fields[field_path[0]], odoo.fields.Many2one):
Exception
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/cristian/odoo_practice/odoo/http.py", line 639, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception)
File "/home/cristian/odoo_practice/odoo/http.py", line 315, in _handle_exception
raise exception.with_traceback(None) from new_cause
KeyError: '\x7f'```
Can somebody help me :(. Im learning to use Odoo
I am trying to get mail when a new record created and modified for a field in CRM Module so i have defined this functions , someone help me with this issue
in py file :
#api.multi
def write(self, vals):
if 'lead_status' in vals and self.ids:
for rec in self:
template = self.env.ref('crm_extended.crm_lead_mail_template')
template.send_mail(rec.id, force_send=True)
return super(crm_extended, self).write(vals)
#api.model
def create(self, vals):
rec = super(crm_extended, self).create(vals)
if 'opportunity_id' in vals:
template = self.env.ref('crm_extended.create_crm_lead_mail_template')
for rec in self:
template.send_mail (rec.id, force_send=True)
return rec
#api.multi
def create(self, vals):
res = super(crm_extended,self).create(vals)
if res and res.customer_name:
template = self.env.ref ('crm_extended.create_crm_lead_mail_template')
template.send_mail (res.id, force_send = True)
return res
when the change the state or give save, odoo popping me an error as below
Error:
Odoo Server Error
Traceback (most recent call last):
File "/opt/odoo/odoo-12.0/odoo/http.py", line 656, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception)
File "/opt/odoo/odoo-12.0/odoo/http.py", line 314, in _handle_exception
raise pycompat.reraise(type(exception), exception, sys.exc_info()[2])
File "/opt/odoo/odoo-12.0/odoo/tools/pycompat.py", line 87, in reraise
raise value
File "/opt/odoo/odoo-12.0/odoo/http.py", line 698, in dispatch
result = self._call_function(**self.params)
File "/opt/odoo/odoo-12.0/odoo/http.py", line 346, in _call_function
return checked_call(self.db, *args, **kwargs)
File "/opt/odoo/odoo-12.0/odoo/service/model.py", line 98, in wrapper
return f(dbname, *args, **kwargs)
File "/opt/odoo/odoo-12.0/odoo/http.py", line 339, in checked_call
result = self.endpoint(*a, **kw)
File "/opt/odoo/odoo-12.0/odoo/http.py", line 941, in __call__
return self.method(*args, **kw)
File "/opt/odoo/odoo-12.0/odoo/http.py", line 519, in response_wrap
response = f(*args, **kw)
File "/opt/odoo/odoo-12.0/addons/web/controllers/main.py", line 962, in call_kw
return self._call_kw(model, method, args, kwargs)
File "/opt/odoo/odoo-12.0/addons/web/controllers/main.py", line 954, in _call_kw
return call_kw(request.env[model], method, args, kwargs)
File "/opt/odoo/odoo-12.0/odoo/api.py", line 759, in call_kw
return _call_kw_multi(method, model, args, kwargs)
File "/opt/odoo/odoo-12.0/odoo/api.py", line 746, in _call_kw_multi
result = method(recs, *args, **kwargs)
TypeError: create() missing 1 required positional argument: 'vals'
I don't know what's wrong. When I duplicated an old record and saved, it worked.
You made a mistake : You can't use #api.multi to odoo's create method.
You have to use #api.model
I created 2 custom modules, "projects" and "laboratory".
Laboratory module has one2many field of projects.
Project module has many2one field of laboratory id.
I made some modification of "laboratory" module and when I tried update it I get this error:
Traceback (most recent call last):
File "C:\Odoo13\Odoo 13.0\server\odoo\http.py", line 624, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception)
File "C:\Odoo13\Odoo 13.0\server\odoo\http.py", line 310, in _handle_exception
raise pycompat.reraise(type(exception), exception, sys.exc_info()[2])
File "C:\Odoo13\Odoo 13.0\server\odoo\tools\pycompat.py", line 14, in reraise
raise value
File "C:\Odoo13\Odoo 13.0\server\odoo\http.py", line 669, in dispatch
result = self._call_function(**self.params)
File "C:\Odoo13\Odoo 13.0\server\odoo\http.py", line 350, in _call_function
return checked_call(self.db, *args, **kwargs)
File "C:\Odoo13\Odoo 13.0\server\odoo\service\model.py", line 94, in wrapper
return f(dbname, *args, **kwargs)
File "C:\Odoo13\Odoo 13.0\server\odoo\http.py", line 339, in checked_call
result = self.endpoint(*a, **kw)
File "C:\Odoo13\Odoo 13.0\server\odoo\http.py", line 915, in __call__
return self.method(*args, **kw)
File "C:\Odoo13\Odoo 13.0\server\odoo\http.py", line 515, in response_wrap
response = f(*args, **kw)
File "C:\Odoo13\Odoo 13.0\server\odoo\addons\web\controllers\main.py", line 1326, in call_button
action = self._call_kw(model, method, args, kwargs)
File "C:\Odoo13\Odoo 13.0\server\odoo\addons\web\controllers\main.py", line 1314, in _call_kw
return call_kw(request.env[model], method, args, kwargs)
File "C:\Odoo13\Odoo 13.0\server\odoo\api.py", line 387, in call_kw
result = _call_kw_multi(method, model, args, kwargs)
File "C:\Odoo13\Odoo 13.0\server\odoo\api.py", line 374, in _call_kw_multi
result = method(recs, *args, **kwargs)
File "<decorator-gen-65>", line 2, in button_immediate_upgrade
File "C:\Odoo13\Odoo 13.0\server\odoo\addons\base\models\ir_module.py", line 72, in check_and_log
return method(self, *args, **kwargs)
File "C:\Odoo13\Odoo 13.0\server\odoo\addons\base\models\ir_module.py", line 634, in button_immediate_upgrade
return self._button_immediate_function(type(self).button_upgrade)
File "C:\Odoo13\Odoo 13.0\server\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:\Odoo13\Odoo 13.0\server\odoo\modules\registry.py", line 86, in new
odoo.modules.load_modules(registry._db, force_demo, status, update_module)
File "C:\Odoo13\Odoo 13.0\server\odoo\modules\loading.py", line 419, in load_modules
force, status, report, loaded_modules, update_module, models_to_check)
File "C:\Odoo13\Odoo 13.0\server\odoo\modules\loading.py", line 315, in load_marked_modules
perform_checks=perform_checks, models_to_check=models_to_check
File "C:\Odoo13\Odoo 13.0\server\odoo\modules\loading.py", line 202, in load_module_graph
registry.init_models(cr, model_names, {'module': package.name}, new_install)
File "C:\Odoo13\Odoo 13.0\server\odoo\modules\registry.py", line 348, in init_models
model._auto_init()
File "C:\Odoo13\Odoo 13.0\server\odoo\models.py", line 2482, in _auto_init
new = field.update_db(self, columns)
File "C:\Odoo13\Odoo 13.0\server\odoo\fields.py", line 2417, in update_db
comodel = model.env[self.comodel_name]
File "C:\Odoo13\Odoo 13.0\server\odoo\api.py", line 463, in __getitem__
return self.registry[model_name]._browse(self, (), ())
File "C:\Odoo13\Odoo 13.0\server\odoo\modules\registry.py", line 177, in __getitem__
return self.models[model_name]
KeyError: 'projects'
As I googled this error, it seems that I didn't put dependencies of my module "projects".
So, next step was put dependencies:
# any module necessary for this one to work correctly
'depends': ['base','mail','projects'],
And now I get another error which is saying about dependencies on it self:
Odoo Server Error
Traceback (most recent call last):
File "C:\Odoo13\Odoo 13.0\server\odoo\http.py", line 624, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception)
File "C:\Odoo13\Odoo 13.0\server\odoo\http.py", line 310, in _handle_exception
raise pycompat.reraise(type(exception), exception, sys.exc_info()[2])
File "C:\Odoo13\Odoo 13.0\server\odoo\tools\pycompat.py", line 14, in reraise
raise value
File "C:\Odoo13\Odoo 13.0\server\odoo\http.py", line 669, in dispatch
result = self._call_function(**self.params)
File "C:\Odoo13\Odoo 13.0\server\odoo\http.py", line 350, in _call_function
return checked_call(self.db, *args, **kwargs)
File "C:\Odoo13\Odoo 13.0\server\odoo\service\model.py", line 94, in wrapper
return f(dbname, *args, **kwargs)
File "C:\Odoo13\Odoo 13.0\server\odoo\http.py", line 339, in checked_call
result = self.endpoint(*a, **kw)
File "C:\Odoo13\Odoo 13.0\server\odoo\http.py", line 915, in __call__
return self.method(*args, **kw)
File "C:\Odoo13\Odoo 13.0\server\odoo\http.py", line 515, in response_wrap
response = f(*args, **kw)
File "C:\Odoo13\Odoo 13.0\server\odoo\addons\web\controllers\main.py", line 1326, in call_button
action = self._call_kw(model, method, args, kwargs)
File "C:\Odoo13\Odoo 13.0\server\odoo\addons\web\controllers\main.py", line 1314, in _call_kw
return call_kw(request.env[model], method, args, kwargs)
File "C:\Odoo13\Odoo 13.0\server\odoo\api.py", line 387, in call_kw
result = _call_kw_multi(method, model, args, kwargs)
File "C:\Odoo13\Odoo 13.0\server\odoo\api.py", line 374, in _call_kw_multi
result = method(recs, *args, **kwargs)
File "<decorator-gen-66>", line 2, in button_immediate_upgrade
File "C:\Odoo13\Odoo 13.0\server\odoo\addons\base\models\ir_module.py", line 72, in check_and_log
return method(self, *args, **kwargs)
File "C:\Odoo13\Odoo 13.0\server\odoo\addons\base\models\ir_module.py", line 634, in button_immediate_upgrade
return self._button_immediate_function(type(self).button_upgrade)
File "C:\Odoo13\Odoo 13.0\server\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:\Odoo13\Odoo 13.0\server\odoo\modules\registry.py", line 86, in new
odoo.modules.load_modules(registry._db, force_demo, status, update_module)
File "C:\Odoo13\Odoo 13.0\server\odoo\modules\loading.py", line 419, in load_modules
force, status, report, loaded_modules, update_module, models_to_check)
File "C:\Odoo13\Odoo 13.0\server\odoo\modules\loading.py", line 315, in load_marked_modules
perform_checks=perform_checks, models_to_check=models_to_check
File "C:\Odoo13\Odoo 13.0\server\odoo\modules\loading.py", line 176, in load_module_graph
registry.setup_models(cr)
File "C:\Odoo13\Odoo 13.0\server\odoo\modules\registry.py", line 255, in setup_models
model._setup_fields()
File "C:\Odoo13\Odoo 13.0\server\odoo\models.py", line 2690, in _setup_fields
field.setup_full(self)
File "C:\Odoo13\Odoo 13.0\server\odoo\fields.py", line 431, in setup_full
self._setup_regular_full(model)
File "C:\Odoo13\Odoo 13.0\server\odoo\fields.py", line 2897, in _setup_regular_full
comodel = model.env[self.comodel_name]
File "C:\Odoo13\Odoo 13.0\server\odoo\api.py", line 463, in __getitem__
return self.registry[model_name]._browse(self, (), ())
File "C:\Odoo13\Odoo 13.0\server\odoo\modules\registry.py", line 177, in __getitem__
return self.models[model_name]
KeyError: 'laboratory'
And when I change dependency and add self module like this:
# any module necessary for this one to work correctly
'depends': ['base','mail','projects','laboratory'],
I am getting 500 Internal Server Error.
Could somebody explain why it happens and how I can handle it?
Reason
It is because of "circular dependency". Module "projects" depend on "laboratory". But "laboratory" depend "projects" and it become loop. As a result, module upgrades are not finished, fields are not added and KeyError will be shown. Check those modules in Apps, those will be stuck with only "Cancel Upgrade" button. I am testing this on odoo 11.
Fix
I can think of a few ways to solve this problem.
Move both "project" and "laboratory" models to same module.
Use "many2many" field instead.
Create another module that depend on both modules and define "one2many" and "many2one" here by inheritance.
Move one field to another module by inheritance. I mean, for e.g. inherit "Laboratory" and add "projects" field in "Projects" module.
an error while creating new reservation in hotel reservation module in odoo V8
error says
ValueError: "global name 'cr' is not defined" while evaluating
u'set_to_draft_reservation()'
while creating variable cr in the method and assign self.env.cr to it
to define it
an error says
multi-value for variable cr
Odoo Server Error
Traceback (most recent call last):
File "/opt/odoo/openerp/http.py", line 543, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception)
File "/opt/odoo/openerp/http.py", line 580, in dispatch
result = self._call_function(**self.params)
File "/opt/odoo/openerp/http.py", line 316, 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 313, in checked_call
return self.endpoint(*a, **kw)
File "/opt/odoo/openerp/http.py", line 809, in __call__
return self.method(*args, **kw)
File "/opt/odoo/openerp/http.py", line 409, in response_wrap
response = f(*args, **kw)
File "/opt/odoo/addons/web/controllers/main.py", line 944, in call_kw
return self._call_kw(model, method, args, kwargs)
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/api.py", line 372, in old_api
result = method(recs, *args, **kwargs)
File "/opt/odoo/addons/hotel_reservation/models/hotel_reservation.py", line 518, in create
return super(HotelReservation, self).create(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/addons/mail/mail_thread.py", line 381, in create
thread_id = super(mail_thread, self).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/api.py", line 372, in old_api
result = method(recs, *args, **kwargs)
File "/opt/odoo/openerp/models.py", line 4100, 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 4326, in _create
self.create_workflow(cr, user, [id_new], context=context)
File "/opt/odoo/openerp/api.py", line 268, in wrapper
return old_api(self, *args, **kwargs)
File "/opt/odoo/openerp/models.py", line 3546, in create_workflow
workflow.trg_create(uid, self._name, res_id, cr)
File "/opt/odoo/openerp/workflow/__init__.py", line 73, in trg_create
return WorkflowService.new(cr, uid, res_type, res_id).create()
File "/opt/odoo/openerp/workflow/service.py", line 81, in create
WorkflowInstance.create(self.session, self.record, wkf_id)
File "/opt/odoo/openerp/workflow/instance.py", line 54, in create
WorkflowItem.create(session, record, activity, instance_id, stack)
File "/opt/odoo/openerp/workflow/workitem.py", line 95, in create
workflow_item.process(stack=stack)
File "/opt/odoo/openerp/workflow/workitem.py", line 116, in process
if not self._execute(activity, stack):
File "/opt/odoo/openerp/workflow/workitem.py", line 162, in _execute
returned_action = self.wkf_expr_execute(activity)
File "/opt/odoo/openerp/workflow/workitem.py", line 313, in wkf_expr_execute
return self.wkf_expr_eval_expr(activity['action'])
File "/opt/odoo/openerp/workflow/workitem.py", line 291, in wkf_expr_eval_expr
result = eval(line, env, nocopy=True)
File "/opt/odoo/openerp/tools/safe_eval.py", line 314, in safe_eval
return eval(c, globals_dict, locals_dict)
File "", line 1, in <module>
File "/opt/odoo/openerp/api.py", line 266, in wrapper
return new_api(self, *args, **kwargs)
File "/opt/odoo/addons/hotel_reservation/models/hotel_reservation.py", line 321, in set_to_draft_reservation
self.delete_workflow(cr, uid, [reservation.id])
ValueError: "global name 'cr' is not defined" while evaluating
u'set_to_draft_reservation()'
the method causing error
#api.multi
def set_to_draft_reservation(self):
for reservation in self:
reservation.write({'state':'draft'})
# Deleting the existing instance of workflow for PO
self.delete_workflow(self._cr, self._uid, [reservation.id])
self.create_workflow(cr, uid, [reservation.id])
return True
Always I'm getting errors while installing modules on the Odoo 8 server, following is the error message. OpenERP Server Error:
Traceback (most recent call last): File
"/opt/odoo/odoo-server/openerp/http.py", line 476, in
_handle_exception return super(JsonRequest, self)._handle_exception(exception) File
"/opt/odoo/odoo-server/openerp/http.py", line 495, in dispatch result
= self._call_function(**self.params) File "/opt/odoo/odoo-server/openerp/http.py", line 311, in _call_function
return checked_call(self.db, *args, **kwargs) File
"/opt/odoo/odoo-server/openerp/service/model.py", line 113, in wrapper
return f(dbname, *args, **kwargs) File
"/opt/odoo/odoo-server/openerp/http.py", line 308, in checked_call
return self.endpoint(*a, **kw) File
"/opt/odoo/odoo-server/openerp/http.py", line 685, in __call__ return
self.method(*args, **kw) File "/opt/odoo/odoo-server/openerp/http.py",
line 360, in response_wrap response = f(*args, **kw) File
"/opt/odoo/odoo-server/addons/web/controllers/main.py", line 987, in
call_button action = self._call_kw(model, method, args, {}) File
"/opt/odoo/odoo-server/addons/web/controllers/main.py", line 975, in
_call_kw return getattr(request.registry.get(model), method)(request.cr, request.uid, *args, **kwargs) File
"/opt/odoo/odoo-server/openerp/api.py", line 204, in wrapper return
old_api(self, *args, **kwargs) File
"/opt/odoo/odoo-server/openerp/addons/base/module/module.py", line
450, in button_immediate_install return
self._button_immediate_function(cr, uid, ids, self.button_install,
context=context) File "/opt/odoo/odoo-server/openerp/api.py", line
204, in wrapper return old_api(self, *args, **kwargs) File
"/opt/odoo/odoo-server/openerp/addons/base/module/module.py", line
497, in _button_immediate_function registry =
openerp.modules.registry.RegistryManager.new(cr.dbname,
update_module=True) File
"/opt/odoo/odoo-server/openerp/modules/registry.py", line 322, in new
openerp.modules.load_modules(registry._db, force_demo, status,
update_module) File
"/opt/odoo/odoo-server/openerp/modules/loading.py", line 357, in
load_modules loaded_modules, update_module) File
"/opt/odoo/odoo-server/openerp/modules/loading.py", line 263, in
load_marked_modules loaded, processed = load_module_graph(cr, graph,
progressdict, report=report, skip_modules=loaded_modules,
perform_checks=perform_checks) File
"/opt/odoo/odoo-server/openerp/modules/loading.py", line 162, in
load_module_graph registry.setup_models(cr) File
"/opt/odoo/odoo-server/openerp/modules/registry.py", line 165, in
setup_models model._setup_fields(cr, SUPERUSER_ID) File
"/opt/odoo/odoo-server/openerp/api.py", line 204, in wrapper return
old_api(self, *args, **kwargs) File
"/opt/odoo/odoo-server/openerp/api.py", line 297, in old_api result =
method(recs, *args, **kwargs) File
"/opt/odoo/odoo-server/openerp/models.py", line 2961, in _setup_fields
field.setup(self.env) File "/opt/odoo/odoo-server/openerp/fields.py",
line 360, in setup self._setup(env) File
"/opt/odoo/odoo-server/openerp/fields.py", line 378, in _setup field =
dep_model._fields[field_name] KeyError: 'section_id'
Can anyone help me to resolve this problem?
OS spec: Ubuntu 14.04 LTS