Skip to Content
Menu
This question has been flagged
2 Replies
1358 Views

I tried to create a Many2one field  

product=fields.Many2one('product.product')

but the error occur:

TypeError: Cannot read properties of undefined (reading 'string')
    at http://localhost:8070/web/assets/731-b875ed4/web.assets_backend.min.js:6536:211
    at traverse (http://localhost:8070/web/assets/731-b875ed4/web.assets_backend.min.js:6531:200)
    at http://localhost:8070/web/assets/731-b875ed4/web.assets_backend.min.js:6531:242
    at Function.each (http://localhost:8070/web/assets/730-af65125/web.assets_common.min.js:171:149)
    at traverse (http://localhost:8070/web/assets/731-b875ed4/web.assets_backend.min.js:6531:211)
    at processArch (http://localhost:8070/web/assets/731-b875ed4/web.assets_backend.min.js:6535:180)
    at http://localhost:8070/web/assets/731-b875ed4/web.assets_backend.min.js:6536:494
    at traverse (http://localhost:8070/web/assets/731-b875ed4/web.assets_backend.min.js:6531:200)
    at http://localhost:8070/web/assets/731-b875ed4/web.assets_backend.min.js:6531:242
    at Function.each (http://localhost:8070/web/assets/730-af65125/web.assets_common.min.js:171:149)


Avatar
Discard

Can you please attach a screenshot of your code snippet

Author

the screens below
thanks in advance

Author

image0this the screenimage1

Author

I did that but there is another error

Traceback (most recent call last):
  File "D:\odoo16\server\odoo\http.py", line 1578, in _serve_db
    return service_model.retrying(self._serve_ir_http, self.env)
  File "D:\odoo16\server\odoo\service\model.py", line 134, in retrying
    result = func()
  File "D:\odoo16\server\odoo\http.py", line 1607, in _serve_ir_http
    response = self.dispatcher.dispatch(rule.endpoint, args)
  File "D:\odoo16\server\odoo\http.py", line 1804, in dispatch
    result = self.request.registry['ir.http']._dispatch(endpoint)
  File "D:\odoo16\server\odoo\addons\base\models\ir_http.py", line 140, in _dispatch
    result = endpoint(**request.params)
  File "D:\odoo16\server\odoo\http.py", line 698, in route_wrapper
    result = endpoint(self, *args, **params_ok)
  File "D:\odoo16\server\odoo\addons\web\controllers\dataset.py", line 42, in call_kw
    return self._call_kw(model, method, args, kwargs)
  File "D:\odoo16\server\odoo\addons\web\controllers\dataset.py", line 33, in _call_kw
    return call_kw(request.env[model], method, args, kwargs)
  File "D:\odoo16\server\odoo\api.py", line 461, in call_kw
    result = _call_kw_multi(method, model, args, kwargs)
  File "D:\odoo16\server\odoo\api.py", line 448, in _call_kw_multi
    result = method(recs, *args, **kwargs)
  File "D:\odoo16\server\odoo\models.py", line 6526, in onchange
    result['value'] = snapshot1.diff(snapshot0, force=first_call)
  File "D:\odoo16\server\odoo\models.py", line 6345, in diff
    result[name] = field.convert_to_onchange(self[name], record, {})
  File "D:\odoo16\server\odoo\fields.py", line 3012, in convert_to_onchange
    if not value.id:
AttributeError: '_unknown' object has no attribute 'id'


Best Answer

Hi,

Can you add product module to the dependency (depends) in the manifest and see if it make any difference.

Adding many2one field tutorial:  Many2One Field In Odoo

Thanks

Avatar
Discard
Author

Thanks very much
I made what you said and the problem solved

Best Answer

Hi,

In the begining of your python file, please replace the line with following code,

from odoo import fields, models, api, _

Try now and check if it helps

Note: press Ctrl + Alt + L to auto align the code for better code readability


Regards

Avatar
Discard
Author

I did that but there is another error
Traceback (most recent call last):
File "D:\odoo16\server\odoo\http.py", line 1578, in _serve_db
return service_model.retrying(self._serve_ir_http, self.env)
File "D:\odoo16\server\odoo\service\model.py", line 134, in retrying
result = func()
File "D:\odoo16\server\odoo\http.py", line 1607, in _serve_ir_http
response = self.dispatcher.dispatch(rule.endpoint, args)
File "D:\odoo16\server\odoo\http.py", line 1804, in dispatch
result = self.request.registry['ir.http']._dispatch(endpoint)
File "D:\odoo16\server\odoo\addons\base\models\ir_http.py", line 140, in _dispatch
result = endpoint(**request.params)
File "D:\odoo16\server\odoo\http.py", line 698, in route_wrapper
result = endpoint(self, *args, **params_ok)
File "D:\odoo16\server\odoo\addons\web\controllers\dataset.py", line 42, in call_kw
return self._call_kw(model, method, args, kwargs)
File "D:\odoo16\server\odoo\addons\web\controllers\dataset.py", line 33, in _call_kw
return call_kw(request.env[model], method, args, kwargs)
File "D:\odoo16\server\odoo\api.py", line 461, in call_kw
result = _call_kw_multi(method, model, args, kwargs)
File "D:\odoo16\server\odoo\api.py", line 448, in _call_kw_multi
result = method(recs, *args, **kwargs)
File "D:\odoo16\server\odoo\models.py", line 6526, in onchange
result['value'] = snapshot1.diff(snapshot0, force=first_call)
File "D:\odoo16\server\odoo\models.py", line 6345, in diff
result[name] = field.convert_to_onchange(self[name], record, {})
File "D:\odoo16\server\odoo\fields.py", line 3012, in convert_to_onchange
if not value.id:
AttributeError: '_unknown' object has no attribute 'id'

Author

I used community edition

Related Posts Replies Views Activity
1
Apr 23
227
0
Jul 24
2
Odoo App Solved
1
Nov 23
741
0
Nov 23
365
0
May 24
575