"Error" File "/home/tushar/odoo1/openerp/fields.py", line 1528, in get_values return [value for value, _ in selection]
TypeError: 'NoneType' object is not iterable
Stachtrace: Odoo Server Error
Traceback (most recent call last):
File "/home/tushar/odoo1/openerp/http.py", line 648, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception)
File "/home/tushar/odoo1/openerp/http.py", line 685, in dispatch
result = self._call_function(**self.params)
File "/home/tushar/odoo1/openerp/http.py", line 321, in _call_function
return checked_call(self.db, *args, **kwargs)
File "/home/tushar/odoo1/openerp/service/model.py", line 118, in wrapper
return f(dbname, *args, **kwargs)
File "/home/tushar/odoo1/openerp/http.py", line 314, in checked_call
result = self.endpoint(*a, **kw)
File "/home/tushar/odoo1/openerp/http.py", line 964, in __call__
return self.method(*args, **kw)
File "/home/tushar/odoo1/openerp/http.py", line 514, in response_wrap
response = f(*args, **kw)
File "/home/tushar/odoo1/addons/web/controllers/main.py", line 888, in call_kw
return self._call_kw(model, method, args, kwargs)
File "/home/tushar/odoo1/addons/web/controllers/main.py", line 880, in _call_kw
return getattr(request.registry.get(model), method)(request.cr, request.uid, *args, **kwargs)
File "/home/tushar/odoo1/openerp/api.py", line 250, in wrapper
return old_api(self, *args, **kwargs)
File "/home/tushar/odoo1/openerp/api.py", line 381, in old_api
result = method(recs, *args, **kwargs)
File "/home/tushar/odoo1/openerp/models.py", line 6028, in onchange
record = self.new(values)
File "/home/tushar/odoo1/openerp/api.py", line 248, in wrapper
return new_api(self, *args, **kwargs)
File "/home/tushar/odoo1/openerp/models.py", line 5595, in new
record._cache.update(record._convert_to_cache(values, update=True))
File "/home/tushar/odoo1/openerp/models.py", line 5490, in _convert_to_cache
for name, value in values.iteritems()
File "/home/tushar/odoo1/openerp/models.py", line 5491, in <dictcomp>
if name in fields
File "/home/tushar/odoo1/openerp/fields.py", line 1533, in convert_to_cache
if value in self.get_values(record.env):
File "/home/tushar/odoo1/openerp/fields.py", line 1528, in get_values
return [value for value, _ in selection]
TypeError: 'NoneType' object is not iterable
I got This Error for dynamic selection for selection field in odoo. I provide the code I have done. Please help me out of this
from openerp import models, fields, api
from test.test_support import temp_cwd
class scantech_laser_product_template(models.Model):
_name='product.template'
_inherit='product.template'
values2=[('ECDS0','ECDS0'),('ECDS1','ECDS1'),('ECDS2','ECDS2')]
main_category = fields.Selection([('SL0','SL0'),('SL1','SL1'),('SL2','SL2')],string="Main Category")
@api.multi
@api.depends("main_category")
def _get_selection_name(self):
if self.main_category == "SL0":
return [("ESDS1","ESDS1")]
sub_category = fields.Selection(selection=_get_selection_name,string="Sub Category")
When I am selecting the main category field it showing above error