Odoo13 to_date gives False - python

I am running Odoo13 Manufacturing App. I am getting an error when clicking on "Plan" in a Manufacturing Order.This error occurs after installing accounting app and creating a vendor for a product in a BOM.
My Order view is given as an image:
Error:
Odoo Server Error
Traceback (most recent call last):
File "/home/odoo/src/odoo/odoo/http.py", line 619, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception)
File "/home/odoo/src/odoo/odoo/http.py", line 309, in _handle_exception
raise pycompat.reraise(type(exception), exception, sys.exc_info()[2])
File "/home/odoo/src/odoo/odoo/tools/pycompat.py", line 14, in reraise
raise value
File "/home/odoo/src/odoo/odoo/http.py", line 664, in dispatch
result = self._call_function(**self.params)
File "/home/odoo/src/odoo/odoo/http.py", line 345, in _call_function
return checked_call(self.db, *args, **kwargs)
File "/home/odoo/src/odoo/odoo/service/model.py", line 93, in wrapper
return f(dbname, *args, **kwargs)
File "/home/odoo/src/odoo/odoo/http.py", line 338, in checked_call
result = self.endpoint(*a, **kw)
File "/home/odoo/src/odoo/odoo/http.py", line 909, in __call__
return self.method(*args, **kw)
File "/home/odoo/src/odoo/odoo/http.py", line 510, in response_wrap
response = f(*args, **kw)
File "/home/odoo/src/odoo/addons/web/controllers/main.py", line 1323, in call_button
action = self._call_kw(model, method, args, kwargs)
File "/home/odoo/src/odoo/addons/web/controllers/main.py", line 1311, in _call_kw
return call_kw(request.env[model], method, args, kwargs)
File "/home/odoo/src/odoo/odoo/api.py", line 395, in call_kw
result = _call_kw_multi(method, model, args, kwargs)
File "/home/odoo/src/odoo/odoo/api.py", line 382, in _call_kw_multi
result = method(recs, *args, **kwargs)
File "/home/odoo/src/enterprise/mrp_workorder/models/mrp_production.py", line 13, in button_plan
res = super(MrpProduction, self).button_plan()
File "/home/odoo/src/odoo/addons/mrp/models/mrp_production.py", line 690, in button_plan
order._plan_workorders()
File "/home/odoo/src/odoo/addons/mrp/models/mrp_production.py", line 725, in _plan_workorders
if to_date < best_finished_date: TypeError: '<' not supported between instances of 'bool' and 'datetime.datetime'

Pull the latest code from Odoo git repo and you will find this error has gone:
https://github.com/odoo/odoo/blob/13.0/addons/mrp/models/mrp_production.py#L736
if to_date < best_finished_date
changed to
if to_date and to_date < best_finished_date

Related

TypeError: 'bool' object is not subscriptable in Python3,odoo

I don't know where my problem is. Because years is char field must be string not bool.
I feel really frustrated. What can I do to fix this problem?
Any sort of help will be much appreciated!
Please give me some suggestions. Thanks!
Here is my code:
class HreDetailList(models.EcoModel):
_name = "hre.detail.list"
def _compute_holiday_flag(self):
for record in self:
record.work_on_holiday = False
now_year = int(record.years[:4])
next_year = now_year + 1
holiday_obj = self.env['hra.holiday']
holiday_data = holiday_obj.search([('holi_yy', 'ilike', next_year),
('holi_name', '=', 'Xmas')])
change_obj = self.env['hre.changedtl']
change_data = change_obj.search([('hre_empbas_id.emp_no', '=', record.emp_no),
('trans_flag', '=', True),
('lt_startdate', '=like', record.years[:4] + '%')])
for change_datadtl in change_data:
if change_datadtl.chg_kind == '6M' or change_datadtl.chg_kind == '6N' or change_datadtl.chg_kind == '6L':
if holiday_data.holi_date >= change_datadtl.lt_startdate and holiday_data.holi_date <= change_datadtl.lt_enddate:
record.work_on_holiday = True
break
else:
record.work_on_holiday = False
years = fields.Char(string='Year', size=7, required=True)
work_on_holiday = fields.Boolean(compute=_compute_holiday_flag, string='Work on holiday')
I am getting following error: TypeError: 'bool' object is not subscriptable:
Odoo Server Error
Traceback (most recent call last):
File "/vagrant/odoo/odoo/addons/base/models/ir_http.py", line 237, in _dispatch
result = request.dispatch()
File "/vagrant/odoo/odoo/http.py", line 682, in dispatch
result = self._call_function(**self.params)
File "/vagrant/odoo/odoo/http.py", line 358, in _call_function
return checked_call(self.db, *args, **kwargs)
File "/vagrant/odoo/odoo/service/model.py", line 94, in wrapper
return f(dbname, *args, **kwargs)
File "/vagrant/odoo/odoo/http.py", line 346, in checked_call
result = self.endpoint(*a, **kw)
File "/vagrant/odoo/odoo/http.py", line 911, in __call__
return self.method(*args, **kw)
File "/vagrant/odoo/odoo/http.py", line 530, in response_wrap
response = f(*args, **kw)
File "/vagrant/odoo/addons/web/controllers/main.py", line 1359, in call_kw
return self._call_kw(model, method, args, kwargs)
File "/vagrant/odoo/addons/web/controllers/main.py", line 1351, in _call_kw
return call_kw(request.env[model], method, args, kwargs)
File "/vagrant/odoo/odoo/api.py", line 396, in call_kw
result = _call_kw_multi(method, model, args, kwargs)
File "/vagrant/odoo/odoo/api.py", line 383, in _call_kw_multi
result = method(recs, *args, **kwargs)
File "/vagrant/odoo/odoo/models.py", line 6165, in onchange
value = record[name]
File "/vagrant/odoo/odoo/models.py", line 5640, in __getitem__
return self._fields[key].__get__(self, type(self))
File "/vagrant/odoo/odoo/fields.py", line 972, in __get__
self.compute_value(recs)
File "/vagrant/odoo/odoo/fields.py", line 1111, in compute_value
records._compute_field_value(self)
File "/vagrant/odoo/odoo/models.py", line 4037, in _compute_field_value
field.compute(self)
File "/vagrant/odoo/addons/hre_formwork/models/hre_formwork.py", line 3887, in_compute_holiday_flag
now_year = int(record.years[:4])
Exception
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/vagrant/odoo/odoo/http.py", line 638, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception)
File "/vagrant/odoo/odoo/http.py", line 314, in _handle_exception
raise exception.with_traceback(None) from new_cause
TypeError: 'bool' object is not subscriptable

How to fix model error when upgrading module in odoo 13

I get this error when I try to upgrade my custom module in odoo 13.
Odoo Server Error
Traceback (most recent call last):
File "/odoo/odoo-server/odoo/http.py", line 619, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception)
File "/odoo/odoo-server/odoo/http.py", line 309, in _handle_exception
raise pycompat.reraise(type(exception), exception, sys.exc_info()[2])
File "/odoo/odoo-server/odoo/tools/pycompat.py", line 14, in reraise
raise value
File "/odoo/odoo-server/odoo/http.py", line 664, in dispatch
result = self._call_function(**self.params)
File "/odoo/odoo-server/odoo/http.py", line 345, in _call_function
return checked_call(self.db, *args, **kwargs)
File "/odoo/odoo-server/odoo/service/model.py", line 93, in wrapper
return f(dbname, *args, **kwargs)
File "/odoo/odoo-server/odoo/http.py", line 338, in checked_call
result = self.endpoint(*a, **kw)
File "/odoo/odoo-server/odoo/http.py", line 910, in __call__
return self.method(*args, **kw)
File "/odoo/odoo-server/odoo/http.py", line 510, in response_wrap
response = f(*args, **kw)
File "/odoo/odoo-server/addons/web/controllers/main.py", line 1324, in call_button
action = self._call_kw(model, method, args, kwargs)
File "/odoo/odoo-server/addons/web/controllers/main.py", line 1312, in _call_kw
return call_kw(request.env[model], method, args, kwargs)
File "/odoo/odoo-server/odoo/api.py", line 387, in call_kw
result = _call_kw_multi(method, model, args, kwargs)
File "/odoo/odoo-server/odoo/api.py", line 374, in _call_kw_multi
result = method(recs, *args, **kwargs)
File "<decorator-gen-64>", line 2, in button_immediate_upgrade
File "/odoo/odoo-server/odoo/addons/base/models/ir_module.py", line 72, in check_and_log
return method(self, *args, **kwargs)
File "/odoo/odoo-server/odoo/addons/base/models/ir_module.py", line 629, in button_immediate_upgrade
return self._button_immediate_function(type(self).button_upgrade)
File "/odoo/odoo-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 "/odoo/odoo-server/odoo/modules/registry.py", line 86, in new
odoo.modules.load_modules(registry._db, force_demo, status, update_module)
File "/odoo/odoo-server/odoo/modules/loading.py", line 471, in load_modules
env['ir.model.data']._process_end(processed_modules)
File "/odoo/odoo-server/odoo/addons/base/models/ir_model.py", line 1971, in _process_end
record.unlink()
File "/odoo/odoo-server/odoo/addons/base/models/ir_model.py", line 1190, in unlink
table=self.env[selection.field_id.model]._table,
File "/opt/odoo/odoo13/odoo/api.py", line 463, in __getitem__
return self.registry[model_name]._browse(self, (), ())
File "/opt/odoo/odoo13/odoo/modules/registry.py", line 177, in __getitem__
return self.models[model_name]
KeyError: 'sales.terms'
This is the sales.terms model
class SalesTermsAndConditions(models.Model):
_name = 'sales.terms'
_description = 'Terms and Conditions'
_rec_name = 'typex'
new_type = fields.Selection([
('accessories', 'Accessories'),
('glass', 'Glass Work'),
('aluminium', 'Aluminium profiles'),
('projects', 'Projects')
], string='Testing')
d_active = fields.Boolean(string='Active')
notes = fields.Text()
I have a new model named 'sales.terms' I created and I created the corresponding ir.model.access.csv file for it, so I traced down the error and discovered that it isn't the whole model giving causing the error but just the selection field, if i remove the selection field the module upgrades fine.
I am confused as to what might be wrong.
I think there is something missing
class SalesTermsAndConditions(models.Model):
_name = 'sales.terms'
_description = 'Terms and Conditions'
_rec_name = 'typex'
new_type = fields.Selection([
('test', 'Test'),
('atest', 'A test'), // Comma is missing
('accessories', 'Accessories'),
('glass', 'Glass Work'),
('aluminium', 'Aluminium profiles'),
('projects', 'Projects')
], string='Testing')
d_active = fields.Boolean(string='Active')
notes = fields.Text()
Try to remove _rec_name.Replace with some field.
_rec_name = "new_type"
The selection seem to be ok. if you rename new_type does it then upgrade?
Can you look first errors wen you boot odoo or reload modules

Odoo 10 - To verify email for a partner

Here my function for to verify a email :
# Vérifie que l'adresse mail du partner soit valide
#api.onchange('email')
def adressmailtoverify(self):
for rec in self:
address_to_verify = rec.email
match = re.match("^[a-zA-Z0-9_\-]+(\.[a-zA-Z0-9_\-]+)*#[a-zA-Z0-9_\-]+"
"(\.[a-zA-Z0-9_\-]+)*(\.[a-zA-Z]{2,6})$", address_to_verify)
if not match:
raise ValidationError("Problème de synthaxe adresse mail, merci de modifier")
else:
pass
Here my error :
Odoo Server Error
Traceback (most recent call last):
File "/var/lib/odoo/odoo/odoo/odoo/http.py", line 640, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception)
File "/var/lib/odoo/odoo/odoo/odoo/http.py", line 677, in dispatch
result = self._call_function(**self.params)
File "/var/lib/odoo/odoo/odoo/odoo/http.py", line 333, in _call_function
return checked_call(self.db, *args, **kwargs)
File "/var/lib/odoo/odoo/odoo/odoo/service/model.py", line 101, in wrapper
return f(dbname, *args, **kwargs)
File "/var/lib/odoo/odoo/odoo/odoo/http.py", line 326, in checked_call
result = self.endpoint(*a, **kw)
File "/var/lib/odoo/odoo/odoo/odoo/http.py", line 935, in __call__
return self.method(*args, **kw)
File "/var/lib/odoo/odoo/odoo/odoo/http.py", line 506, in response_wrap
response = f(*args, **kw)
File "/usr/lib/python2.7/dist-packages/odoo/addons/web/controllers/main.py", line 885, in call_kw
return self._call_kw(model, method, args, kwargs)
File "/usr/lib/python2.7/dist-packages/odoo/addons/web/controllers/main.py", line 877, in _call_kw
return call_kw(request.env[model], method, args, kwargs)
File "/var/lib/odoo/odoo/odoo/odoo/api.py", line 689, in call_kw
return call_kw_multi(method, model, args, kwargs)
File "/var/lib/odoo/odoo/odoo/odoo/api.py", line 680, in call_kw_multi
result = method(recs, *args, **kwargs)
File "/var/lib/odoo/horanet/horanet_go/horanet_web/models/tool_field_dirty.py", line 59, in onchange
res = super(ToolFieldDirty, self).onchange(values, field_name, field_onchange)
File "/var/lib/odoo/odoo/odoo/odoo/models.py", line 5494, in onchange
record._onchange_eval(name, field_onchange[name], result)
File "/var/lib/odoo/odoo/odoo/odoo/models.py", line 5392, in _onchange_eval
method_res = method(self)
File "/var/lib/odoo/projects/Odoo/parthenay_tpa_mediatheque/models/inherited_partner.py", line 127, in adressmailtoverify
"(\.[a-zA-Z0-9_\-]+)*(\.[a-zA-Z]{2,6})$", address_to_verify)
File "/usr/lib/python2.7/re.py", line 141, in match
return _compile(pattern, flags).match(string)
TypeError: expected string or buffer
I have this error when to clear a email.
My second concern is that even if my exception is thrown, my partner is registered. Can you help me ? Thank you
Change the for line and use this instead:
for rec in self.filtered("email"):
The problem happens because values are False in Odoo, and you cannot apply a regex to a bool.

odoo 9 AssertionError assert self in records and field in fs

while I am trying to update value that affect computed field I got this error:
Odoo Server Error
Traceback (most recent call last):
File "/Users/abdalla/projects/greenway/odoo-server/openerp/http.py", line 647, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception)
File "/Users/abdalla/projects/greenway/odoo-server/openerp/http.py", line 684, in dispatch
result = self._call_function(**self.params)
File "/Users/abdalla/projects/greenway/odoo-server/openerp/http.py", line 320, in _call_function
return checked_call(self.db, *args, **kwargs)
File "/Users/abdalla/projects/greenway/odoo-server/openerp/service/model.py", line 118, in wrapper
return f(dbname, *args, **kwargs)
File "/Users/abdalla/projects/greenway/odoo-server/openerp/http.py", line 313, in checked_call
result = self.endpoint(*a, **kw)
File "/Users/abdalla/projects/greenway/odoo-server/openerp/http.py", line 963, in call
return self.method(*args, **kw)
File "/Users/abdalla/projects/greenway/odoo-server/openerp/http.py", line 513, in response_wrap
response = f(*args, **kw)
File "/Users/abdalla/projects/greenway/odoo-server/addons/web/controllers/main.py", line 904, in call_kw
return self._call_kw(model, method, args, kwargs)
File "/Users/abdalla/projects/greenway/odoo-server/addons/web/controllers/main.py", line 896, in _call_kw
return getattr(request.registry.get(model), method)(request.cr, request.uid, *args, **kwargs)
File "/Users/abdalla/projects/greenway/odoo-server/openerp/api.py", line 250, in wrapper
return old_api(self, *args, **kwargs)
File "/Users/abdalla/projects/greenway/odoo-server/openerp/api.py", line 381, in old_api
result = method(recs, *args, **kwargs)
File "/Users/abdalla/projects/greenway/odoo-server/openerp/models.py", line 6036, in onchange
record.mapped(field_seq)
File "/Users/abdalla/projects/greenway/odoo-server/openerp/models.py", line 5534, in mapped
recs = recs._mapped_func(operator.itemgetter(name))
File "/Users/abdalla/projects/greenway/odoo-server/openerp/models.py", line 5514, in _mapped_func
vals = [func(rec) for rec in self]
File "/Users/abdalla/projects/greenway/odoo-server/openerp/models.py", line 5752, in getitem
return self._fields[key].get(self, type(self))
File "/Users/abdalla/projects/greenway/odoo-server/openerp/fields.py", line 829, in get
self.determine_value(record)
File "/Users/abdalla/projects/greenway/odoo-server/openerp/fields.py", line 927, in determine_value
record._prefetch_field(self)
File "/Users/abdalla/projects/greenway/odoo-server/openerp/api.py", line 248, in wrapper
return new_api(self, *args, **kwargs)
File "/Users/abdalla/projects/greenway/odoo-server/openerp/models.py", line 3295, in _prefetch_field
assert self in records and field in fs
AssertionError
finally I found the problem:
the problem is that the method of the computed field is not exist (I renamed it accidentally). so when odoo try to get the value of this field it failed, and show this strange error

How to resolve the error in Odoo 8?

Recently I had restored a Odoo DB to a newly created instance, From then on i am getting the following error whenever I go to the respective menu :
KeyError: u'mro.request'
How to resolve such kind of errors?
Any suggestion would be really helpful. Thanks!!
Traceback (most recent call last):
File "/home/administrator/second2/apps/odoo/lib/odoo-8.0_a2115ef-py2.7.egg/openerp/http.py", line 517, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception)
File "/home/administrator/second2/apps/odoo/lib/odoo-8.0_a2115ef-py2.7.egg/openerp/http.py", line 538, in dispatch
result = self._call_function(**self.params)
File "/home/administrator/second2/apps/odoo/lib/odoo-8.0_a2115ef-py2.7.egg/openerp/http.py", line 294, in _call_function
return checked_call(self.db, *args, **kwargs)
File "/home/administrator/second2/apps/odoo/lib/odoo-8.0_a2115ef-py2.7.egg/openerp/service/model.py", line 113, in wrapper
return f(dbname, *args, **kwargs)
File "/home/administrator/second2/apps/odoo/lib/odoo-8.0_a2115ef-py2.7.egg/openerp/http.py", line 291, in checked_call
return self.endpoint(*a, **kw)
File "/home/administrator/second2/apps/odoo/lib/odoo-8.0_a2115ef-py2.7.egg/openerp/http.py", line 754, in __call__
return self.method(*args, **kw)
File "/home/administrator/second2/apps/odoo/lib/odoo-8.0_a2115ef-py2.7.egg/openerp/http.py", line 387, in response_wrap
response = f(*args, **kw)
File "/home/administrator/second2/apps/odoo/lib/odoo-8.0_a2115ef-py2.7.egg/openerp/addons/web/controllers/main.py", line 1251, in load
action = request.session.model(action_type).read([action_id], False, ctx)
File "/home/administrator/second2/apps/odoo/lib/odoo-8.0_a2115ef-py2.7.egg/openerp/http.py", line 856, in proxy
result = meth(cr, request.uid, *args, **kw)
File "/home/administrator/second2/apps/odoo/lib/odoo-8.0_a2115ef-py2.7.egg/openerp/api.py", line 237, in wrapper
return old_api(self, *args, **kwargs)
File "/home/administrator/second2/apps/odoo/lib/odoo-8.0_a2115ef-py2.7.egg/openerp/addons/base/ir/ir_actions.py", line 326, in read
results = super(ir_actions_act_window, self).read(cr, uid, ids, fields=fields, context=context, load=load)
File "/home/administrator/second2/apps/odoo/lib/odoo-8.0_a2115ef-py2.7.egg/openerp/api.py", line 237, in wrapper
return old_api(self, *args, **kwargs)
File "/home/administrator/second2/apps/odoo/lib/odoo-8.0_a2115ef-py2.7.egg/openerp/models.py", line 3083, in read
result = BaseModel.read(records, fields, load=load)
File "/home/administrator/second2/apps/odoo/lib/odoo-8.0_a2115ef-py2.7.egg/openerp/api.py", line 235, in wrapper
return new_api(self, *args, **kwargs)
File "/home/administrator/second2/apps/odoo/lib/odoo-8.0_a2115ef-py2.7.egg/openerp/models.py", line 3115, in read
self._read_from_database(stored)
File "/home/administrator/second2/apps/odoo/lib/odoo-8.0_a2115ef-py2.7.egg/openerp/api.py", line 235, in wrapper
return new_api(self, *args, **kwargs)
File "/home/administrator/second2/apps/odoo/lib/odoo-8.0_a2115ef-py2.7.egg/openerp/models.py", line 3279, in _read_from_database
res2 = self._columns[f].get(cr, self._model, ids, f, user, context=context, values=result)
File "/home/administrator/second2/apps/odoo/lib/odoo-8.0_a2115ef-py2.7.egg/openerp/osv/fields.py", line 1356, in get
result = self._fnct(obj, cr, uid, ids, name, self._arg, context)
File "/home/administrator/second2/apps/odoo/lib/odoo-8.0_a2115ef-py2.7.egg/openerp/addons/base/ir/ir_actions.py", line 265, in _search_view
field_get = self.pool[act.res_model].fields_view_get(cr, uid,
File "/home/administrator/second2/apps/odoo/lib/odoo-8.0_a2115ef-py2.7.egg/openerp/modules/registry.py", line 101, in __getitem__
return self.models[model_name]
KeyError: u'mro.request'
I solved the above problem by upgrading the modules which were in the dependencies.

Categories