Browse Source

[ADD] b_shift : attendance sheet default super cooperator

pull/125/head
Elouan Le Bars 5 years ago
parent
commit
423d51027f
  1. 33
      beesdoo_shift/models/attendance_sheet.py
  2. 10
      beesdoo_shift/views/attendance_sheet.xml

33
beesdoo_shift/models/attendance_sheet.py

@ -55,6 +55,11 @@ class AttendanceSheetShift(models.AbstractModel):
task_type_id = fields.Many2one(
"beesdoo.shift.type", string="Task Type", default=default_task_type_id
)
super_coop_id = fields.Many2one(
"res.users",
string="Super Cooperative",
domain=[("partner_id.super", "=", True)],
)
working_mode = fields.Selection(
related="worker_id.working_mode", string="Working Mode", store=True
)
@ -159,6 +164,14 @@ class AttendanceSheet(models.Model):
)
end_time = fields.Datetime(string="End Time", required=True, readonly=True)
default_super_coop_id = fields.Many2one(
"res.users",
string="Default Super Cooperative",
help="Super Cooperative for default Task Type",
domain=[("partner_id.super", "=", True)],
compute="_compute_default_super_coop_id",
store=True,
)
expected_shift_ids = fields.One2many(
"beesdoo.shift.sheet.expected",
"attendance_sheet_id",
@ -208,7 +221,6 @@ class AttendanceSheet(models.Model):
string="Validated by",
domain=[
("eater", "=", "worker_eater"),
("super", "=", True),
("working_mode", "=", "regular"),
("state", "not in", ("unsubscribed", "resigning")),
],
@ -277,6 +289,24 @@ class AttendanceSheet(models.Model):
+ end_time_dt.strftime("%H:%M")
)
@api.depends("expected_shift_ids")
def _compute_default_super_coop_id(self):
"""
Look for the super cooperator of a shift
with default Task Type
"""
default_task_type = self.env[
"beesdoo.shift.sheet.expected"
].default_task_type_id()
shift = self.expected_shift_ids.search(
[
("task_type_id", "=", default_task_type.id),
("super_coop_id", "!=", False),
],
limit=1,
)
self.default_super_coop_id = shift.super_coop_id
# Is this method necessary ?
@api.depends("annotation")
def _compute_is_annotated(self):
@ -312,6 +342,7 @@ class AttendanceSheet(models.Model):
"worker_id": task.worker_id.id,
"replacement_worker_id": task.replaced_id.id,
"task_type_id": task.task_type_id.id,
"super_coop_id": task.super_coop_id.id,
"stage": stage,
"working_mode": task.working_mode,
}

10
beesdoo_shift/views/attendance_sheet.xml

@ -10,6 +10,7 @@
decoration-danger="stage == 'absent_0' or stage == 'absent_1' or stage == 'absent_2'"
decoration-success="stage == 'present'">
<field name="task_type_id" readonly="True" options="{'no_open': True}"/>
<field name="super_coop_id" readonly="True" options="{'no_open': True}"/>
<field name="worker_id" readonly="True" options="{'no_open': True}"/>
<field name="working_mode" />
<field name="replacement_worker_id"
@ -81,10 +82,12 @@
<field name="name">Attendance Sheet List</field>
<field name="model">beesdoo.shift.sheet</field>
<field name="arch" type="xml">
<!-- <tree create="false" delete="false" decoration-danger="stage == 'absent'"> -->
<tree create="false" decoration-danger="state == 'not_validated'">
<field name="name"/>
<tree create="false" delete="false" default_order="start_time desc"
decoration-danger="state == 'not_validated'">
<field name="day" />
<field name="time_slot" />
<field name="max_worker_no" type="char"/>
<field name="default_super_coop_id" />
<field name="state" />
<field name="validated_by" />
<field name="is_annotated" />
@ -134,6 +137,7 @@
<separator string="Added workers" />
<field name="added_shift_ids"/>
<group string="Informations">
<field name="default_super_coop_id" />
<field name="max_worker_no" />
</group>
<br/>

Loading…
Cancel
Save