Browse Source

[ADD] b_shift : day_abbreviation for attendance sheets

pull/125/head
Elouan Le Bars 5 years ago
parent
commit
35cc1485d8
  1. 36
      beesdoo_shift/models/attendance_sheet.py
  2. 3
      beesdoo_shift/security/ir.model.access.csv

36
beesdoo_shift/models/attendance_sheet.py

@ -98,6 +98,7 @@ class AttendanceSheetShiftExpected(models.Model):
if not self.compensation_no:
raise UserError(_("You must choose a compensation number."))
class AttendanceSheetShiftAdded(models.Model):
"""
Added shifts are necessarily 'Present'
@ -146,6 +147,9 @@ class AttendanceSheet(models.Model):
)
end_time = fields.Datetime(string="End Time", required=True, readonly=True)
day = fields.Date(string="Day", compute="_compute_day", store=True)
day_abbrevation = fields.Char(
string="Day Abbrevation", compute="_compute_day_abbrevation"
)
week = fields.Char(
string="Week",
help="Computed from planning names",
@ -227,19 +231,20 @@ class AttendanceSheet(models.Model):
+ end_time_dt.strftime("%H:%M")
)
@api.depends("start_time", "end_time", "week")
@api.depends("start_time", "end_time", "week", "day_abbrevation")
def _compute_name(self):
for rec in self:
start_time_dt = fields.Datetime.from_string(rec.start_time)
start_time_dt = fields.Datetime.context_timestamp(
rec, start_time_dt
)
name = "%s - " % (fields.Date.to_string(start_time_dt),)
name = "[%s] " % (fields.Date.to_string(start_time_dt),)
if rec.week:
name += rec.week + "_"
name += "%s_" % (start_time_dt.strftime("%a"),)
name += rec.week + " "
if rec.day_abbrevation:
name += rec.day_abbrevation + " "
if rec.time_slot:
name += rec.time_slot
name += "(%s)" % rec.time_slot
rec.name = name
@api.depends("start_time")
@ -247,14 +252,29 @@ class AttendanceSheet(models.Model):
for rec in self:
rec.day = fields.Date.from_string(rec.start_time)
@api.depends("expected_shift_ids")
def _compute_day_abbrevation(self):
"""
Compute Day Abbrevation from Planning Name
of first expected shift with one.
"""
for rec in self:
for shift in rec.expected_shift_ids:
if shift.task_id.task_template_id.day_nb_id.name:
rec.day_abbrevation = (
shift.task_id.task_template_id.day_nb_id.name
)
@api.depends("expected_shift_ids")
def _compute_week(self):
"""
Compute Week Name from Planning Name of first expected shift
Compute Week Name from Planning Name
of first expected shift with one
"""
for rec in self:
if rec.expected_shift_ids:
rec.week = rec.expected_shift_ids[0].task_id.planning_id.name
for shift in rec.expected_shift_ids:
if shift.task_id.planning_id.name:
rec.week = shift.task_id.planning_id.name
@api.depends("annotation")
def _compute_is_annotated(self):

3
beesdoo_shift/security/ir.model.access.csv

@ -7,7 +7,7 @@ manage_beesdoo_shift_sheet_added,manage_beesdoo_shift_sheet_added,model_beesdoo_
create_beesdoo_shift_sheet,create_beesdoo_shift_sheet,model_beesdoo_shift_sheet,group_shift_attendance_sheet,1,1,1,0
sheet_access_beesdoo_shift_template,sheet_access_beesdoo_shift_template,model_beesdoo_shift_template,group_shift_attendance_sheet,1,0,0,0
sheet_access_beesdoo_shift_type,sheet_access_beesdoo_shift_type,model_beesdoo_shift_type,group_shift_attendance_sheet,1,0,0,0
access_beesdoo_shift_daynumber,access_beesdoo_shift_daynumber,model_beesdoo_shift_daynumber,group_shift_attendance,1,0,0,0
access_beesdoo_shift_daynumber,access_beesdoo_shift_daynumber,model_beesdoo_shift_daynumber,group_shift_attendance_sheet,1,0,0,0
read_beesdoo_shift_planning,read_beesdoo_shift_planning,model_beesdoo_shift_planning,,1,0,0,0
access_beesdoo_shift_template,access_beesdoo_shift_template,model_beesdoo_shift_template,group_shift_attendance,1,0,0,0
write_beesdoo_shift_shift,write_beesdoo_shift_shift,model_beesdoo_shift_shift,group_shift_attendance,1,1,0,0
@ -25,4 +25,5 @@ access_cooperative_status,access_cooperative_status,model_cooperative_status,,1,
read_cooperative_exempt_reason,read_cooperative_exempt_reason,model_cooperative_exempt_reason,,1,0,0,0
read_cooperative_status_history,read_cooperative_status_history,model_cooperative_status_history,,1,0,0,0
access_beesdoo_shift_type,access_beesdoo_shift_type,model_beesdoo_shift_type,group_shift_attendance,1,0,0,0
access_beesdoo_shift_type,access_beesdoo_shift_type,model_beesdoo_shift_daynumber,group_shift_attendance,1,0,0,0
access_beesdoo_shift_template,access_beesdoo_shift_template,model_beesdoo_shift_template,group_shift_attendance,1,0,0,0
Loading…
Cancel
Save