When we try to insert a Timesheet record using the rest-api we get a mandatory field error.
Below is the exact error.
{{“_server_messages”:“["{\"message\": \"Error: Data missing in table: Time Sheets\"}"]”,“exc”:“["Traceback (most recent call last):\n File \"/home/benjamien/frappe-bench/apps/frappe/frappe/app.py\", line 60, in application\n response = frappe.api.handle()\n File \"/home/benjamien/frappe-bench/apps/frappe/frappe/api.py\", line 127, in handle\n \"data\": frappe.get_doc(data).insert().as_dict()\n File \"/home/benjamien/frappe-bench/apps/frappe/frappe/model/document.py\", line 230, in insert\n self._validate()\n File \"/home/benjamien/frappe-bench/apps/frappe/frappe/model/document.py\", line 460, in _validate\n self._validate_mandatory()\n File \"/home/benjamien/frappe-bench/apps/frappe/frappe/model/document.py\", line 740, in _validate_mandatory\n name=self.name))\nfrappe.exceptions.MandatoryError: [Timesheet, TS-2020-00001]: time_logs\n"]”}}
The json data looks to be correct and contains the time_logs. See below.
What could be the problem ? Is this a bug ?
I think this includes all mandatory fields.
But I keep getting the same response.
{{“exc”:“["Traceback (most recent call last):\n File \"/home/benjamien/frappe-bench/apps/frappe/frappe/app.py\", line 60, in application\n response = frappe.api.handle()\n File \"/home/benjamien/frappe-bench/apps/frappe/frappe/api.py\", line 127, in handle\n \"data\": frappe.get_doc(data).insert().as_dict()\n File \"/home/benjamien/frappe-bench/apps/frappe/frappe/model/document.py\", line 230, in insert\n self._validate()\n File \"/home/benjamien/frappe-bench/apps/frappe/frappe/model/document.py\", line 460, in _validate\n self._validate_mandatory()\n File \"/home/benjamien/frappe-bench/apps/frappe/frappe/model/document.py\", line 740, in _validate_mandatory\n name=self.name))\nfrappe.exceptions.MandatoryError: [Timesheet, TS-2020-00002]: time_logs\n"]”,“_server_messages”:“["{\"message\": \"Error: Data missing in table: Time Sheets\"}"]”}}
\"/opt/bench/erpnext/apps/erpnext/erpnext/projects/doctype/timesheet/timesheet.py\", line 130, in validate_dates\n if data.from_time and data.to_time and time_diff_in_hours(data.to_time, data.from_time) < 0:\nAttributeError: ‘str’ object has no attribute ‘from_time’\n"]"}