OCA / timesheet

Odoo Timesheet Management Addons
GNU Affero General Public License v3.0
122 stars 346 forks source link

Creating new timesheet #372

Closed yuniesky1986 closed 4 years ago

yuniesky1986 commented 4 years ago

Traceback (most recent call last): File "/home/yunesky/PycharmProjects/odoo11/odoo/odoo/models.py", line 4436, in ensure_one _id, = self._ids ValueError: not enough values to unpack (expected 1, got 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/home/yunesky/PycharmProjects/odoo11/odoo/odoo/http.py", line 653, in _handle_exception return super(JsonRequest, self)._handle_exception(exception) File "/home/yunesky/PycharmProjects/odoo11/odoo/odoo/http.py", line 312, in _handle_exception raise pycompat.reraise(type(exception), exception, sys.exc_info()[2]) File "/home/yunesky/PycharmProjects/odoo11/odoo/odoo/tools/pycompat.py", line 87, in reraise raise value File "/home/yunesky/PycharmProjects/odoo11/odoo/odoo/http.py", line 695, in dispatch result = self._call_function(self.params) File "/home/yunesky/PycharmProjects/odoo11/odoo/odoo/http.py", line 344, in _call_function return checked_call(self.db, *args, *kwargs) File "/home/yunesky/PycharmProjects/odoo11/odoo/odoo/service/model.py", line 97, in wrapper return f(dbname, args, kwargs) File "/home/yunesky/PycharmProjects/odoo11/odoo/odoo/http.py", line 337, in checked_call result = self.endpoint(*a, kw) File "/home/yunesky/PycharmProjects/odoo11/odoo/odoo/http.py", line 939, in call return self.method(*args, *kw) File "/home/yunesky/PycharmProjects/odoo11/odoo/odoo/http.py", line 517, in response_wrap response = f(args, kw) File "/home/yunesky/PycharmProjects/odoo11/odoo/addons/web/controllers/main.py", line 934, in call_kw return self._call_kw(model, method, args, kwargs) File "/home/yunesky/PycharmProjects/odoo11/odoo/addons/web/controllers/main.py", line 926, in _call_kw return call_kw(request.env[model], method, args, kwargs) File "/home/yunesky/PycharmProjects/odoo11/odoo/odoo/api.py", line 699, in call_kw return call_kw_multi(method, model, args, kwargs) File "/home/yunesky/PycharmProjects/odoo11/odoo/odoo/api.py", line 690, in call_kw_multi result = method(recs, *args, **kwargs) File "/home/yunesky/PycharmProjects/odoo11/OCA/hr-timesheet/hr_timesheet_sheet_attendance/models/hr_timesheet_sheet.py", line 88, in get_attendance_by_day self.ensure_one() File "/home/yunesky/PycharmProjects/odoo11/odoo/odoo/models.py", line 4439, in ensure_one raise ValueError("Expected singleton: %s" % self) ValueError: Expected singleton: hr_timesheet.sheet()

pedrobaeza commented 4 years ago

Unless you put steps to reproduce the problem, and get it in a runbot instance (check the link in the README), this can't be solved (if there's a module bug).

bodi000 commented 4 years ago

I wanted to report the same thing. Should I open a new issue?

Briefly, when the form opens on a new system, with no time-sheet, or when you click on Create, the error rises and after closing the popup you can continue creating. It seems that js does not check for self, which it is empty on creation, so firing the function get_attendance_by_day gets the error.. Not sure it is the right wording, but here you have the empty self on create (I added a rise UserWarning statement to check for self):

`Odoo Server Error

Traceback (most recent call last): File "/srv/git/odoo-11.0/odoo/http.py", line 653, in _handle_exception return super(JsonRequest, self)._handle_exception(exception) File "/srv/git/odoo-11.0/odoo/http.py", line 312, in _handle_exception raise pycompat.reraise(type(exception), exception, sys.exc_info()[2]) File "/srv/git/odoo-11.0/odoo/tools/pycompat.py", line 87, in reraise raise value File "/srv/git/odoo-11.0/odoo/http.py", line 695, in dispatch result = self._call_function(self.params) File "/srv/git/odoo-11.0/odoo/http.py", line 344, in _call_function return checked_call(self.db, *args, *kwargs) File "/srv/git/odoo-11.0/odoo/service/model.py", line 97, in wrapper return f(dbname, args, kwargs) File "/srv/git/odoo-11.0/odoo/http.py", line 337, in checked_call result = self.endpoint(*a, kw) File "/srv/git/odoo-11.0/odoo/http.py", line 939, in call return self.method(*args, *kw) File "/srv/git/odoo-11.0/odoo/http.py", line 517, in response_wrap response = f(args, kw) File "/opt/odoo/11/addons/web/controllers/main.py", line 934, in call_kw return self._call_kw(model, method, args, kwargs) File "/opt/odoo/11/addons/web/controllers/main.py", line 926, in _call_kw return call_kw(request.env[model], method, args, kwargs) File "/srv/git/odoo-11.0/odoo/api.py", line 699, in call_kw return call_kw_multi(method, model, args, kwargs) File "/srv/git/odoo-11.0/odoo/api.py", line 690, in call_kw_multi result = method(recs, *args, kwargs) File "/opt/odoo/11/custom/addons/hr_timesheet_sheet_attendance/models/hr_timesheet_sheet.py", line 88, in get_attendance_by_day raise UserWarning(self) UserWarning: hr_timesheet.sheet()**`

without the raise statement:

`Erreur: Odoo Server Error

Traceback (most recent call last): File "/srv/git/odoo-11.0/odoo/models.py", line 4436, in ensure_one _id, = self._ids ValueError: not enough values to unpack (expected 1, got 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/srv/git/odoo-11.0/odoo/http.py", line 653, in _handle_exception return super(JsonRequest, self)._handle_exception(exception) File "/srv/git/odoo-11.0/odoo/http.py", line 312, in _handle_exception raise pycompat.reraise(type(exception), exception, sys.exc_info()[2]) File "/srv/git/odoo-11.0/odoo/tools/pycompat.py", line 87, in reraise raise value File "/srv/git/odoo-11.0/odoo/http.py", line 695, in dispatch result = self._call_function(self.params) File "/srv/git/odoo-11.0/odoo/http.py", line 344, in _call_function return checked_call(self.db, *args, *kwargs) File "/srv/git/odoo-11.0/odoo/service/model.py", line 97, in wrapper return f(dbname, args, kwargs) File "/srv/git/odoo-11.0/odoo/http.py", line 337, in checked_call result = self.endpoint(*a, kw) File "/srv/git/odoo-11.0/odoo/http.py", line 939, in call return self.method(*args, *kw) File "/srv/git/odoo-11.0/odoo/http.py", line 517, in response_wrap response = f(args, kw) File "/opt/odoo/11/addons/web/controllers/main.py", line 934, in call_kw return self._call_kw(model, method, args, kwargs) File "/opt/odoo/11/addons/web/controllers/main.py", line 926, in _call_kw return call_kw(request.env[model], method, args, kwargs) File "/srv/git/odoo-11.0/odoo/api.py", line 699, in call_kw return call_kw_multi(method, model, args, kwargs) File "/srv/git/odoo-11.0/odoo/api.py", line 690, in call_kw_multi result = method(recs, *args, kwargs) File "/opt/odoo/11/custom/addons/hr_timesheet_sheet_attendance/models/hr_timesheet_sheet.py", line 88, in get_attendance_by_day self.ensure_one() File "/srv/git/odoo-11.0/odoo/models.py", line 4439, in ensure_one raise ValueError("Expected singleton: %s" % self) ValueError: Expected singleton: hr_timesheet.sheet()`**

bodi000 commented 4 years ago

I see that in V12 the whole thing was expunged, but this is not really a way to solve the problem :-)