Odoo timesheet overlap
I'm using odoo 10... Current timesheet (hr_timesheet_sheet) structure is like that it can not overlap, because there is almost zero connection between analytic line and hr_timesheet_sheet except dates... I have tried following method:
I have created a new field in hr_timesheet_sheet named 'editing' and whole idea was to set it to the 1 when user edited the timesheet (there was a 3rd party button to start custom 'edit mode') and in analytic line i have checked where user_id == uid and editing = 1 -> get id from hr_timesheet_sheet and paste in sheet_id, once user saved the timesheet it would update to 0 again... But following practice has failed, because after page reload, it would refused to set 'editing' to 1 while i was clicking button.
My code looks like this:
def xtr(self): self.env.cr.execute(""" UPDATE hr_timesheet_sheet_sheet SET editing = %s WHERE id = %s""" %(1,self.id))
this is a button code where user starts 'edit_mode'
def _compute_sheet(self): """Links the timesheet line to the corresponding sheet """ for ts_line in self: if not ts_line.project_id: continue sheets = self.env['hr_timesheet_sheet.sheet'].search( [('editing', '=', 1), ('employee_id.user_id.id', '=', ts_line.user_id.id), ('state', 'in', ['draft', 'new'])]) if sheets: #  because only one sheet possible for an employee between 2 dates ts_line.sheet_id_computed = sheets ts_line.sheet_id = sheets self.env.cr.execute(""" UPDATE hr_timesheet_sheet_sheet SET editing = %s WHERE user_id = %s AND editing = %s""" %(0,self._context.get('uid'),1))
this is the code for sheet_id calculation...
p.s when user created a new timesheet after page reload (that would overlap) old sheet_ids which was belonged to previous sheet erased.
Simply, question is how to make 2 timesheet overlap... or how to fix m