跳至内容
菜单
此问题已终结
2 回复
1651 查看


Hi, we get AttributeError when pressing a button to change the state of an RFQ in our Odoo system while running this function:

def state_machine_trigger(self, trigger_name):
self.ensure_one()
proxy = Proxy(self, "state")
MACHINE.add_model(proxy, initial=self.state)
try:
proxy.trigger(trigger_name)
except MachineError as e:
_LOGGER.exception(e)
except Exception:
_LOGGER.exception("here be bork")
finally:
MACHINE.remove_model(proxy)





Traceback (most recent call last):
File "/home/odoo/odoo/lib/odoo/odoo/addons/base/models/ir_http.py", line 237, in _dispatch
result = request.dispatch()
File "/home/odoo/odoo/lib/odoo/odoo/http.py", line 685, in dispatch
result = self._call_function(**self.params)
File "/home/odoo/odoo/lib/odoo/odoo/http.py", line 361, in _call_function
return checked_call(self.db, *args, **kwargs)
File "/home/odoo/odoo/lib/odoo/odoo/service/model.py", line 94, in wrapper
return f(dbname, *args, **kwargs)
File "/home/odoo/odoo/lib/odoo/odoo/http.py", line 357, in checked_call
self._cr.precommit.run()
File "/home/odoo/odoo/lib/odoo/odoo/tools/misc.py", line 1165, in run
func()
File "/home/odoo/odoo/lib/odoo/addons/mail/models/mail_thread.py", line 550, in _finalize_tracking
tracking = records.with_context(context).message_track(fnames, initial_values)
File "/home/odoo/odoo/lib/odoo/addons/mail/models/mail_thread.py", line 626, in message_track
if not subtype.exists():
Exception

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/home/odoo/odoo/lib/odoo/odoo/http.py", line 641, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception)
File "/home/odoo/odoo/lib/odoo/odoo/http.py", line 317, in _handle_exception
raise exception.with_traceback(None) from new_cause
AttributeError: 'str' object has no attribute 'exists'

形象
丢弃
编写者 最佳答案

Yeah we discovered that the problem only occurs when adding tracking=True to the field. the subtype.exists() is being called in mail module that tracking uses, how do we fix our field so that we can use tracking? Thanks!

形象
丢弃

Thanks a lot for your answer, it works. I have been trying to migrate an odoo v12 module into v17, and the field parameter tracking_visibility seems to cause this subtype.exists() error.

最佳答案

here subtype.exists()  in subtype you are getting a string value not an object so you cant call subtype.exists()

形象
丢弃
相关帖文 回复 查看 活动
2
1月 25
2235
1
12月 24
5969
1
11月 24
2389
1
11月 24
1805
1
8月 24
3327