Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
2 Odpowiedzi
5401 Widoki

Hello,
I'm having a issue with Lots/Serial Numbers in odoo 11 , i have third part module & was wroking fine 

but now when i wanna create new  Lots/Serial Numberi get this err :

Traceback (most recent call last):
File "/opt/odoo/odoo/http.py", line 653, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception)
File "/opt/odoo/odoo/http.py", line 312, in _handle_exception
raise pycompat.reraise(type(exception), exception, sys.exc_info()[2])
File "/opt/odoo/odoo/tools/pycompat.py", line 87, in reraise
raise value
File "/opt/odoo/odoo/http.py", line 695, in dispatch
result = self._call_function(**self.params)
File "/opt/odoo/odoo/http.py", line 344, in _call_function
return checked_call(self.db, *args, **kwargs)
File "/opt/odoo/odoo/service/model.py", line 97, in wrapper
return f(dbname, *args, **kwargs)
File "/opt/odoo/odoo/http.py", line 337, in checked_call
result = self.endpoint(*a, **kw)
File "/opt/odoo/odoo/http.py", line 939, in __call__
return self.method(*args, **kw)
File "/opt/odoo/odoo/http.py", line 517, in response_wrap
response = f(*args, **kw)
File "/opt/odoo/addons/web/controllers/main.py", line 935, in call_kw
return self._call_kw(model, method, args, kwargs)
File "/opt/odoo/addons/web/controllers/main.py", line 927, in _call_kw
return call_kw(request.env[model], method, args, kwargs)
File "/opt/odoo/odoo/api.py", line 697, in call_kw
return call_kw_model(method, model, args, kwargs)
File "/opt/odoo/odoo/api.py", line 682, in call_kw_model
result = method(recs, *args, **kwargs)
File "/opt/berger_addons/serial_unique_warning/models/stock_production_lot.py", line 75, in create
partner.write({'category_id': [( 4,tag_id.id)]})
File "/opt/odoo/odoo/fields.py", line 2590, in __get__
raise ValueError("Expected singleton: %s" % record)
ValueError: Expected singleton: res.partner.category(36, 59)

I have no idea how to solve this. Can anyone help ? Thanks in advance

Awatar
Odrzuć
Najlepsza odpowiedź

Hi,

You are getting singleton error when the self containing more than one record, in such cases you have to iterate the self/object over a for loop.

See the example:   https://www.youtube.com/watch?v=Rv44nFVn_5U&list=PLqRRLx0cl0homY1elJbSoWfeQbRKJ-oPO&index=30

Thanks

Awatar
Odrzuć
Najlepsza odpowiedź

Dear Tensai,

While using the module if it's one category working fine but in your error log says res.partner.category(36, 59) having two records to avoid this error you need to loop res.partner.category.

Thank you

Awatar
Odrzuć
Autor

Hi Ajin ,

Thanks for your reply

can you explain more how to loop res.partner.category ?

Powiązane posty Odpowiedzi Widoki Czynność
1
lip 24
1509
2
sie 25
621
2
lip 24
2743
2
lip 24
2052
1
cze 24
5194