We have two custom modules written for Odoo 15, each with their own models. To make things simple and avoid sharing too much information, we'll call them process and tank. A process can have many tanks, but a tank can only have one process. I used a Many2one and One2many field relationship between tanks and processes, and I've shown the field definition lines for each file below.
Whenever I upgrade either the tank parent module or process parent module, I get the error shown below, up until I push literally any commit to Odoo.sh involving the models' definition files. The error example shown below comes from the process parent module. I upgrade the module, and then get this error until I push ANY commit to Odoo.sh (which forces a reload in our case) involving the process.py file. I'm not quite sure of the root cause of the issue, and I've spent about 2 weeks off and on Googling and trying to solve this weird issue. The bandaid fix is enough for development environments, but this application goes live soon so I'd like to get it taken care of.
This is the field definition line from the process.py file. The model name is process:
tank_ids = fields.One2many('tank', 'process_id')
This is the field definition line from the tank.py file. The model name is tank:
process_id = fields.Many2one('process', 'tank_ids')
Below is the full error traceback:
Traceback (most recent call last): File "/home/odoo/src/odoo/odoo/api.py", line 886, in get return field_cache[record._ids[0]] KeyError: 1 During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/home/odoo/src/odoo/odoo/fields.py", line 1082, in __get__ value = env.cache.get(record, self) File "/home/odoo/src/odoo/odoo/api.py", line 889, in get raise CacheMiss(record, field) odoo.exceptions.CacheMiss: 'process(1,).total_cost' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/home/odoo/src/odoo/odoo/api.py", line 886, in get return field_cache[record._ids[0]] KeyError: 1 During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/home/odoo/src/odoo/odoo/fields.py", line 1082, in __get__ value = env.cache.get(record, self) File "/home/odoo/src/odoo/odoo/api.py", line 889, in get raise CacheMiss(record, field) odoo.exceptions.CacheMiss: 'process(1,).tank_ids' The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/home/odoo/src/odoo/odoo/addons/base/models/ir_http.py", line 237, in _dispatch result = request.dispatch() File "/home/odoo/src/odoo/odoo/http.py", line 698, in dispatch result = self._call_function(**self.params) File "/home/odoo/src/odoo/odoo/http.py", line 368, in _call_function return checked_call(self.db, *args, **kwargs) File "/home/odoo/src/odoo/odoo/service/model.py", line 94, in wrapper return f(dbname, *args, **kwargs) File "/home/odoo/src/odoo/odoo/http.py", line 357, in checked_call result = self.endpoint(*a, **kw) File "/home/odoo/src/odoo/odoo/http.py", line 921, in __call__ return self.method(*args, **kw) File "/home/odoo/src/odoo/odoo/http.py", line 546, in response_wrap response = f(*args, **kw) File "/home/odoo/src/odoo/addons/web/controllers/main.py", line 1282, in search_read return self.do_search_read(model, fields, offset, limit, domain, sort) File "/home/odoo/src/odoo/addons/web/controllers/main.py", line 1301, in do_search_read return Model.web_search_read(domain, fields, offset=offset, limit=limit, order=sort) File "/home/odoo/src/odoo/addons/web/models/models.py", line 62, in web_search_read records = self.search_read(domain, fields, offset=offset, limit=limit, order=order) File "/home/odoo/src/odoo/odoo/models.py", line 5064, in search_read result = records.read(fields, **read_kwargs) File "/home/odoo/src/odoo/odoo/models.py", line 3232, in read return self._read_format(fnames=fields, load=load) File "/home/odoo/src/odoo/odoo/models.py", line 3252, in _read_format vals[name] = convert(record[name], record, use_name_get) File "/home/odoo/src/odoo/odoo/models.py", line 5902, in __getitem__ return self._fields[key].__get__(self, type(self)) File "/home/odoo/src/odoo/odoo/fields.py", line 1131, in __get__ self.compute_value(recs) File "/home/odoo/src/odoo/odoo/fields.py", line 1290, in compute_value records._compute_field_value(self) File "/home/odoo/src/odoo/odoo/models.py", line 4266, in _compute_field_value fields.determine(field.compute, self) File "/home/odoo/src/odoo/odoo/fields.py", line 87, in determine return needle(*args) File "/home/odoo/src/user/mixer_quoting/models/process.py", line 34, in _compute_total_cost if len(record.tank_ids) > 0: File "/home/odoo/src/odoo/odoo/fields.py", line 3402, in __get__ return super().__get__(records, owner) File "/home/odoo/src/odoo/odoo/fields.py", line 2617, in __get__ return super().__get__(records, owner) File "/home/odoo/src/odoo/odoo/fields.py", line 1108, in __get__ recs._fetch_field(self) File "/home/odoo/src/odoo/odoo/models.py", line 3281, in _fetch_field self._read(fnames) File "/home/odoo/src/odoo/odoo/models.py", line 3385, in _read field.read(fetched) File "/home/odoo/src/odoo/odoo/fields.py", line 3419, in read group[get_id(line[inverse])].append(line.id) File "/home/odoo/src/odoo/odoo/fields.py", line 3411, in <lambda> get_id = (lambda rec: rec.id) if inverse_field.type == 'many2one' else int Exception The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/home/odoo/src/odoo/odoo/http.py", line 654, in _handle_exception return super(JsonRequest, self)._handle_exception(exception) File "/home/odoo/src/odoo/odoo/http.py", line 301, in _handle_exception raise exception.with_traceback(None) from new_cause AttributeError: '_unknown' object has no attribute 'id'