Browse Source

[ADD] b_shift : week name on attendance sheet

pull/143/head
Elouan Le Bars 5 years ago
parent
commit
c4d96cc31d
  1. 18
      beesdoo_shift/models/attendance_sheet.py
  2. 2
      beesdoo_shift/security/ir.model.access.csv
  3. 1
      beesdoo_shift/views/attendance_sheet.xml

18
beesdoo_shift/models/attendance_sheet.py

@ -154,6 +154,11 @@ class AttendanceSheet(models.Model):
) )
end_time = fields.Datetime(string="End Time", required=True, readonly=True) end_time = fields.Datetime(string="End Time", required=True, readonly=True)
day = fields.Date(string="Day", compute="_compute_day", store=True) day = fields.Date(string="Day", compute="_compute_day", store=True)
week = fields.Char(
string="Week",
help="Computed from planning names",
compute="_compute_week",
)
expected_shift_ids = fields.One2many( expected_shift_ids = fields.One2many(
"beesdoo.shift.sheet.expected", "beesdoo.shift.sheet.expected",
@ -215,17 +220,19 @@ class AttendanceSheet(models.Model):
) )
] ]
@api.depends("start_time", "end_time")
@api.depends("start_time", "end_time", "week")
def _compute_name(self): def _compute_name(self):
for rec in self: for rec in self:
start_time_dt = fields.Datetime.from_string(rec.start_time) start_time_dt = fields.Datetime.from_string(rec.start_time)
start_time_dt = fields.Datetime.context_timestamp( start_time_dt = fields.Datetime.context_timestamp(
rec, start_time_dt rec, start_time_dt
) )
name = "[%s] - " % fields.Date.to_string(start_time_dt)
if rec.week:
name += rec.week + " - "
if rec.time_slot: if rec.time_slot:
rec.name = (
fields.Date.to_string(start_time_dt) + " " + rec.time_slot
)
name += rec.time_slot
rec.name = name
@api.depends("start_time", "end_time") @api.depends("start_time", "end_time")
def _compute_time_slot(self): def _compute_time_slot(self):
@ -253,7 +260,8 @@ class AttendanceSheet(models.Model):
Compute Week Name from Planning Name of first expected shift Compute Week Name from Planning Name of first expected shift
""" """
for rec in self: for rec in self:
rec.week = rec.expected_shift_ids.task_id.planning_id.name
if rec.expected_shift_ids:
rec.week = rec.expected_shift_ids[0].task_id.planning_id.name
@api.depends("annotation") @api.depends("annotation")
def _compute_is_annotated(self): def _compute_is_annotated(self):

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

@ -8,7 +8,7 @@ create_beesdoo_shift_sheet,create_beesdoo_shift_sheet,model_beesdoo_shift_sheet,
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_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 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,1,0,0,0
read_beesdoo_shift_planning,read_beesdoo_shift_planning,model_beesdoo_shift_planning,group_shift_attendance,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 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 write_beesdoo_shift_shift,write_beesdoo_shift_shift,model_beesdoo_shift_shift,group_shift_attendance,1,1,0,0
manage_beesdoo_shift_shift,manage_beesdoo_shift_shift,model_beesdoo_shift_shift,group_shift_management,1,1,1,1 manage_beesdoo_shift_shift,manage_beesdoo_shift_shift,model_beesdoo_shift_shift,group_shift_management,1,1,1,1

1
beesdoo_shift/views/attendance_sheet.xml

@ -115,6 +115,7 @@
<field name="model">beesdoo.shift.sheet</field> <field name="model">beesdoo.shift.sheet</field>
<field name="arch" type="xml"> <field name="arch" type="xml">
<tree create="false" delete="false" decoration-danger="state == 'not_validated'"> <tree create="false" delete="false" decoration-danger="state == 'not_validated'">
<field name="week" />
<field name="day" /> <field name="day" />
<field name="time_slot" /> <field name="time_slot" />
<field name="max_worker_no" type="char"/> <field name="max_worker_no" type="char"/>

Loading…
Cancel
Save