Browse Source

[FIX] b_worker_status

pull/133/head
Rémy Taymans 5 years ago
parent
commit
d860bab58e
  1. 1
      beesdoo_worker_status/__init__.py
  2. 1
      beesdoo_worker_status/models/__init__.py
  3. 12
      beesdoo_worker_status/models/cooperative_status.py
  4. 8
      beesdoo_worker_status/models/task.py

1
beesdoo_worker_status/__init__.py

@ -0,0 +1 @@
from . import models

1
beesdoo_worker_status/models/__init__.py

@ -1 +1,2 @@
from . import cooperative_status
from . import task

12
beesdoo_worker_status/models/cooperative_status.py

@ -122,9 +122,11 @@ class CooperativeStatus(models.Model):
#####################################
# Status Change implementation #
#####################################
def _set_regular_status(self, grace_delay, alert_delay):
def _get_regular_status(self):
self.ensure_one()
counter_unsubscribe = int(self.env['ir.config_parameter'].get_param('regular_counter_to_unsubscribe', -4))
counter_unsubscribe = int(self.env['ir.config_parameter'].sudo().get_param('regular_counter_to_unsubscribe', -4))
alert_delay = int(self.env['ir.config_parameter'].sudo().get_param('alert_delay', 28))
grace_delay = int(self.env['ir.config_parameter'].sudo().get_param('default_grace_delay', 10))
ok = self.sr >= 0 and self.sc >= 0
grace_delay = grace_delay + self.time_extension
@ -156,9 +158,11 @@ class CooperativeStatus(models.Model):
elif ok or (not self.alert_start_time and self.sr >= 0):
return 'ok'
def _set_irregular_status(self, grace_delay, alert_delay):
counter_unsubscribe = int(self.env['ir.config_parameter'].get_param('irregular_counter_to_unsubscribe', -3))
def _get_irregular_status(self):
self.ensure_one()
counter_unsubscribe = int(self.env['ir.config_parameter'].sudo().get_param('irregular_counter_to_unsubscribe', -3))
alert_delay = int(self.env['ir.config_parameter'].sudo().get_param('alert_delay', 28))
grace_delay = int(self.env['ir.config_parameter'].sudo().get_param('default_grace_delay', 10))
ok = self.sr >= 0
grace_delay = grace_delay + self.time_extension
if self.sr <= counter_unsubscribe or self.unsubscribed:

8
beesdoo_worker_status/models/task.py

@ -5,7 +5,6 @@ from odoo import _, api, fields, models
from odoo.exceptions import UserError, ValidationError
class Task(models.Model):
_inherit = 'beesdoo.shift.shift'
@ -23,7 +22,7 @@ class Task(models.Model):
("cancel","Cancelled")
]
def _get_color_mapping(state):
def _get_color_mapping(self, state):
return {
"draft": 0,
"open": 1,
@ -34,9 +33,10 @@ class Task(models.Model):
"cancel": 9,
}[state]
def _get_final_state():
def _get_final_state(self):
return ["done", "absent_2", "absent_1", "absent_0"]
state = fields.Selection(selection=_get_selection_status)
##############################################
# Change counter when state change #
@ -78,4 +78,4 @@ class Task(models.Model):
data['sr'] = -1
data['irregular_absence_date'] = self.start_time.date()
data['irregular_absence_counter'] = -1
return data
return data, status
Loading…
Cancel
Save