Browse Source

[ADD] Filter from today to J+ 4

[FIX] Silent error when reverting counter info while status change of task when missing some access right
[IMP] Performance improvement in shift generation: Skip message generation
pull/43/merge
Thibault Francois 7 years ago
parent
commit
6c3110e78d
  1. 11
      beesdoo_shift/models/task.py
  2. 10
      beesdoo_shift/views/task.xml
  3. 2
      beesdoo_shift/wizard/instanciate_planning.py

11
beesdoo_shift/models/task.py

@ -100,12 +100,9 @@ class Task(models.Model):
def _revert(self): def _revert(self):
if not self.revert_info: if not self.revert_info:
return return
try:
data = json.loads(self.revert_info)
self.env['cooperative.status'].browse(data['status_id'])._change_counter(data['data'])
self.revert_info = False
except:
pass
data = json.loads(self.revert_info)
self.env['cooperative.status'].browse(data['status_id']).sudo()._change_counter(data['data'])
self.revert_info = False
def _update_stage(self, old_stage, new_stage): def _update_stage(self, old_stage, new_stage):
self.ensure_one() self.ensure_one()
@ -160,5 +157,7 @@ class Task(models.Model):
data['irregular_absence_date'] = self.start_time[:10] data['irregular_absence_date'] = self.start_time[:10]
data['irregular_absence_counter'] = -1 data['irregular_absence_counter'] = -1
else:
raise UserError(_("The worker has not a proper working mode define, please check the worker is subscribed"))
status.sudo()._change_counter(data) status.sudo()._change_counter(data)
self._set_revert_info(data, status) self._set_revert_info(data, status)

10
beesdoo_shift/views/task.xml

@ -37,13 +37,15 @@
<filter string="Unassigned" name="unassigned" <filter string="Unassigned" name="unassigned"
domain="[('worker_id', '=', False)]" /> domain="[('worker_id', '=', False)]" />
<separator /> <separator />
<filter string="J-5" name="jminus1"
<filter string="4 next days" name="nextweek"
domain="[('end_time','&gt;', context_today().strftime('%%Y-%%m-%%d 00:00:00')), ('start_time','&lt;', (context_today() + datetime.timedelta(days=4)).strftime('%%Y-%%m-%%d 23:59:59'))]" />
<filter string="J-5" name="jminus5"
domain="[('end_time','&gt;', (context_today() - datetime.timedelta(days=5)).strftime('%%Y-%%m-%%d 00:00:00')), ('start_time','&lt;', (context_today() - datetime.timedelta(days=5)).strftime('%%Y-%%m-%%d 23:59:59'))]" /> domain="[('end_time','&gt;', (context_today() - datetime.timedelta(days=5)).strftime('%%Y-%%m-%%d 00:00:00')), ('start_time','&lt;', (context_today() - datetime.timedelta(days=5)).strftime('%%Y-%%m-%%d 23:59:59'))]" />
<filter string="J-4" name="jminus1"
<filter string="J-4" name="jminus4"
domain="[('end_time','&gt;', (context_today() - datetime.timedelta(days=4)).strftime('%%Y-%%m-%%d 00:00:00')), ('start_time','&lt;', (context_today() - datetime.timedelta(days=4)).strftime('%%Y-%%m-%%d 23:59:59'))]" /> domain="[('end_time','&gt;', (context_today() - datetime.timedelta(days=4)).strftime('%%Y-%%m-%%d 00:00:00')), ('start_time','&lt;', (context_today() - datetime.timedelta(days=4)).strftime('%%Y-%%m-%%d 23:59:59'))]" />
<filter string="J-3" name="jminus1"
<filter string="J-3" name="jminus3"
domain="[('end_time','&gt;', (context_today() - datetime.timedelta(days=3)).strftime('%%Y-%%m-%%d 00:00:00')), ('start_time','&lt;', (context_today() - datetime.timedelta(days=3)).strftime('%%Y-%%m-%%d 23:59:59'))]" /> domain="[('end_time','&gt;', (context_today() - datetime.timedelta(days=3)).strftime('%%Y-%%m-%%d 00:00:00')), ('start_time','&lt;', (context_today() - datetime.timedelta(days=3)).strftime('%%Y-%%m-%%d 23:59:59'))]" />
<filter string="J-2" name="jminus1"
<filter string="J-2" name="jminus2"
domain="[('end_time','&gt;', (context_today() - datetime.timedelta(days=2)).strftime('%%Y-%%m-%%d 00:00:00')), ('start_time','&lt;', (context_today() - datetime.timedelta(days=2)).strftime('%%Y-%%m-%%d 23:59:59'))]" /> domain="[('end_time','&gt;', (context_today() - datetime.timedelta(days=2)).strftime('%%Y-%%m-%%d 00:00:00')), ('start_time','&lt;', (context_today() - datetime.timedelta(days=2)).strftime('%%Y-%%m-%%d 23:59:59'))]" />
<filter string="J-1" name="jminus1" <filter string="J-1" name="jminus1"
domain="[('end_time','&gt;', (context_today() - datetime.timedelta(days=1)).strftime('%%Y-%%m-%%d 00:00:00')), ('start_time','&lt;', (context_today() - datetime.timedelta(days=1)).strftime('%%Y-%%m-%%d 23:59:59'))]" /> domain="[('end_time','&gt;', (context_today() - datetime.timedelta(days=1)).strftime('%%Y-%%m-%%d 00:00:00')), ('start_time','&lt;', (context_today() - datetime.timedelta(days=1)).strftime('%%Y-%%m-%%d 23:59:59'))]" />

2
beesdoo_shift/wizard/instanciate_planning.py

@ -14,7 +14,7 @@ class InstanciatePlanning(models.TransientModel):
@api.multi @api.multi
def generate_task(self): def generate_task(self):
self.ensure_one() self.ensure_one()
self = self.with_context(visualize_date=self.date_start)
self = self.with_context(visualize_date=self.date_start, tracking_disable=True)
shifts = self.planning_id.task_template_ids._generate_task_day() shifts = self.planning_id.task_template_ids._generate_task_day()
return { return {
'name': _('Generated Shift'), 'name': _('Generated Shift'),

Loading…
Cancel
Save