Browse Source

[IMP] b_shift : attendance sheet generation time configurable

Generation CRON is running every minute and check for sheets
in the configurable time interval. Workers can't subscribe
to a shift on intranet if its start time is in this interval.
pull/143/head
Elouan Le Bars 5 years ago
parent
commit
986cea6e29
  1. 4
      beesdoo_shift/data/cron.xml
  2. 12
      beesdoo_shift/models/attendance_sheet.py
  3. 25
      beesdoo_shift/models/res_config.py
  4. 1
      beesdoo_shift/views/res_config_view.xml

4
beesdoo_shift/data/cron.xml

@ -24,8 +24,8 @@
</record> </record>
<record id="ir_cron_generate_attendance_sheet" model="ir.cron"> <record id="ir_cron_generate_attendance_sheet" model="ir.cron">
<field name="name">Generate Attendance Sheet</field>
<field name="interval_number">20</field>
<field name="name">Generate Attendance Sheets</field>
<field name="interval_number">1</field>
<field name="interval_type">minutes</field> <field name="interval_type">minutes</field>
<field name="numbercall">-1</field> <field name="numbercall">-1</field>
<field name="doall" eval="False" /> <field name="doall" eval="False" />

12
beesdoo_shift/models/attendance_sheet.py

@ -176,7 +176,6 @@ class AttendanceSheet(models.Model):
default=0, default=0,
readonly=True, readonly=True,
help="Indicative maximum number of workers.", help="Indicative maximum number of workers.",
) )
annotation = fields.Text("Annotation", default="") annotation = fields.Text("Annotation", default="")
is_annotated = fields.Boolean( is_annotated = fields.Boolean(
@ -539,16 +538,19 @@ class AttendanceSheet(models.Model):
@api.model @api.model
def _generate_attendance_sheet(self): def _generate_attendance_sheet(self):
""" """
Generate sheets 20 minutes before their start time.
Corresponding CRON intervall time must be the same.
Check if any task exists in the time intervall.
Generate sheets with shifts in the time interval
defined from corresponding CRON time interval.
""" """
time_ranges = set() time_ranges = set()
tasks = self.env["beesdoo.shift.shift"] tasks = self.env["beesdoo.shift.shift"]
sheets = self.env["beesdoo.shift.sheet"] sheets = self.env["beesdoo.shift.sheet"]
current_time = datetime.now() current_time = datetime.now()
allowed_time_range = timedelta(minutes=20)
generation_interval_setting = int(self.env["ir.config_parameter"].get_param(
"beesdoo_shift.attendance_sheet_generation_interval"
))
allowed_time_range = timedelta(minutes=generation_interval_setting)
tasks = tasks.search( tasks = tasks.search(
[ [

25
beesdoo_shift/models/res_config.py

@ -15,13 +15,24 @@ class ShiftConfigSettings(models.TransientModel):
string="Default Task Type", string="Default Task Type",
help="Default task type for attendance sheet pre-filling.", help="Default task type for attendance sheet pre-filling.",
) )
attendance_sheet_generation_interval = fields.Integer(
string="Time interval for attendance sheet generation",
help="Time interval expressed in minutes",
)
@api.multi @api.multi
def set_params(self): def set_params(self):
self.ensure_one() self.ensure_one()
value = self.default_task_type_id.id
parameters = self.env["ir.config_parameter"] parameters = self.env["ir.config_parameter"]
parameters.set_param("beesdoo_shift.default_task_type_id", value)
parameters.set_param(
"beesdoo_shift.default_task_type_id",
str(self.default_task_type_id.id),
)
parameters.set_param(
"beesdoo_shift.attendance_sheet_generation_interval",
str(self.attendance_sheet_generation_interval),
)
@api.multi @api.multi
def get_default_task_type_id(self): def get_default_task_type_id(self):
@ -32,3 +43,13 @@ class ShiftConfigSettings(models.TransientModel):
) )
) )
} }
@api.multi
def get_default_attendance_sheet_generation_interval(self):
return {
"attendance_sheet_generation_interval": int(
self.env["ir.config_parameter"].get_param(
"beesdoo_shift.attendance_sheet_generation_interval"
)
)
}

1
beesdoo_shift/views/res_config_view.xml

@ -40,6 +40,7 @@
</header> </header>
<separator string="General Settings"/> <separator string="General Settings"/>
<group name="Attendance Sheets"> <group name="Attendance Sheets">
<field name="attendance_sheet_generation_interval"/>
<field name="default_task_type_id"/> <field name="default_task_type_id"/>
</group> </group>
</form> </form>

Loading…
Cancel
Save