Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
5302 Lượt xem

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

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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

Ảnh đại diện
Huỷ bỏ
Tác giả

Hi Ajin ,

Thanks for your reply

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

Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 7 24
1414
2
thg 8 25
472
2
thg 7 24
2623
2
thg 7 24
1977
1
thg 6 24
5092