diff --git a/beesdoo_shift/data/cron.xml b/beesdoo_shift/data/cron.xml index bb72fe1..2e5dd72 100644 --- a/beesdoo_shift/data/cron.xml +++ b/beesdoo_shift/data/cron.xml @@ -24,8 +24,8 @@ - Generate Attendance Sheet - 20 + Generate Attendance Sheets + 1 minutes -1 diff --git a/beesdoo_shift/models/attendance_sheet.py b/beesdoo_shift/models/attendance_sheet.py index 0e7aa99..b787206 100644 --- a/beesdoo_shift/models/attendance_sheet.py +++ b/beesdoo_shift/models/attendance_sheet.py @@ -176,7 +176,6 @@ class AttendanceSheet(models.Model): default=0, readonly=True, help="Indicative maximum number of workers.", - ) annotation = fields.Text("Annotation", default="") is_annotated = fields.Boolean( @@ -539,16 +538,19 @@ class AttendanceSheet(models.Model): @api.model 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() tasks = self.env["beesdoo.shift.shift"] sheets = self.env["beesdoo.shift.sheet"] 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( [ diff --git a/beesdoo_shift/models/res_config.py b/beesdoo_shift/models/res_config.py index fa2695c..1f82528 100644 --- a/beesdoo_shift/models/res_config.py +++ b/beesdoo_shift/models/res_config.py @@ -15,13 +15,24 @@ class ShiftConfigSettings(models.TransientModel): string="Default Task Type", 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 def set_params(self): self.ensure_one() - value = self.default_task_type_id.id + 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 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" + ) + ) + } diff --git a/beesdoo_shift/views/res_config_view.xml b/beesdoo_shift/views/res_config_view.xml index 3d8dbcb..ef30fc3 100644 --- a/beesdoo_shift/views/res_config_view.xml +++ b/beesdoo_shift/views/res_config_view.xml @@ -40,6 +40,7 @@ +