I don’t know where my problem is. Because anycodings_odoo years is char field must be string not anycodings_odoo bool. I feel really frustrated. What can I anycodings_odoo do to fix this problem? Any sort of help anycodings_odoo will be much appreciated! Please give me anycodings_odoo 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: anycodings_odoo ‘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