Browse Source

[CHG] b_shift : attendance sheets terminology

pull/125/head
Elouan Le Bars 5 years ago
parent
commit
57875ff299
  1. 5
      beesdoo_shift/data/mail_template.xml
  2. 47
      beesdoo_shift/models/attendance_sheet.py
  3. 2
      beesdoo_shift/tests/test_attendance_sheet.py
  4. 16
      beesdoo_shift/views/attendance_sheet.xml
  5. 20
      beesdoo_shift/wizard/validate_attendance_sheet.py
  6. 2
      beesdoo_shift/wizard/validate_attendance_sheet.xml

5
beesdoo_shift/data/mail_template.xml

@ -38,10 +38,11 @@
% endif % endif
<br/><br/>Your status have been updated to "${object.worker_id.state}". <br/><br/>Your status have been updated to "${object.worker_id.state}".
<br/><br/>If you have any question regarding this non-attendance, feel free to contact us.
<br/><br/>If you have any question regarding this non-attendance, just answer this e-mail.
</p> </p>
<br/> <br/>
<p>Sustainably yours,</p>
<p>Cooperatively yours,<br/>
The Members' office volunteers</p>
<p>${object.worker_id.company_id.name}.</p> <p>${object.worker_id.company_id.name}.</p>
% if object.worker_id.company_id.street: % if object.worker_id.company_id.street:

47
beesdoo_shift/models/attendance_sheet.py

@ -181,27 +181,27 @@ class AttendanceSheet(models.Model):
readonly=True, readonly=True,
help="Indicative maximum number of workers.", help="Indicative maximum number of workers.",
) )
annotation = fields.Text("Annotation", default="")
notes = fields.Text("Notes", default="")
is_annotated = fields.Boolean( is_annotated = fields.Boolean(
compute="_compute_is_annotated", compute="_compute_is_annotated",
string="Annotation",
string="Is annotated",
readonly=True, readonly=True,
store=True, store=True,
) )
is_read = fields.Boolean( is_read = fields.Boolean(
string="Mark as read", string="Mark as read",
help="Has annotation been read by an administrator ?",
help="Has notes been read by an administrator ?",
default=False, default=False,
track_visibility="onchange", track_visibility="onchange",
) )
feedback = fields.Text("Feedback")
feedback = fields.Text("Comments about the shift")
worker_nb_feedback = fields.Selection( worker_nb_feedback = fields.Selection(
[ [
("not_enough", "Not enough"),
("enough", "Enough"),
("too_many", "Too many"),
("not_enough", "Not enough workers"),
("enough", "Enough workers"),
("too_many", "Too many workers"),
], ],
string="Feedback on number of workers",
string="Was your team big enough ?",
) )
validated_by = fields.Many2one( validated_by = fields.Many2one(
"res.partner", "res.partner",
@ -218,7 +218,7 @@ class AttendanceSheet(models.Model):
_sql_constraints = [ _sql_constraints = [
( (
"check_no_annotation_mark_read",
"check_not_annotated_mark_as_read",
"CHECK ((is_annotated=FALSE AND is_read=FALSE) OR is_annotated=TRUE)", "CHECK ((is_annotated=FALSE AND is_read=FALSE) OR is_annotated=TRUE)",
_("Non-annotated sheets can't be marked as read."), _("Non-annotated sheets can't be marked as read."),
) )
@ -284,11 +284,11 @@ class AttendanceSheet(models.Model):
if shift.task_id.planning_id.name: if shift.task_id.planning_id.name:
rec.week = shift.task_id.planning_id.name rec.week = shift.task_id.planning_id.name
@api.depends("annotation")
@api.depends("notes")
def _compute_is_annotated(self): def _compute_is_annotated(self):
for rec in self: for rec in self:
if rec.annotation:
return bool(rec.annotation.strip())
if rec.notes:
return bool(rec.notes.strip())
return False return False
@api.constrains("expected_shift_ids", "added_shift_ids") @api.constrains("expected_shift_ids", "added_shift_ids")
@ -312,7 +312,7 @@ class AttendanceSheet(models.Model):
@api.constrains( @api.constrains(
"expected_shift_ids", "expected_shift_ids",
"added_shift_ids", "added_shift_ids",
"annotation",
"notes",
"feedback", "feedback",
"worker_nb_feedback", "worker_nb_feedback",
) )
@ -336,14 +336,26 @@ class AttendanceSheet(models.Model):
_("Multiple workers are corresponding this barcode.") _("Multiple workers are corresponding this barcode.")
) )
if worker.state in ("unsubscribed", "resigning"):
raise UserError(_("Worker is %s.") % worker.state)
if worker.state == "unsubscribed":
shift_counter = worker.cooperative_status_ids.sc + worker.cooperative_status_ids.sr
raise UserError(_(
"Beware, your account is frozen because your shift counter "
"is at %s. Please contact Members Office to unfreeze it. "
"If you want to attend this shift, your supercoop "
"can write your name in the notes field during validation."
) % shift_counter)
if worker.state == "resigning":
raise UserError(_(
"Beware, you are recorded as resigning. "
"Please contact member's office if this is incorrect. Thank you."
))
if worker.working_mode not in ("regular", "irregular"): if worker.working_mode not in ("regular", "irregular"):
raise UserError( raise UserError(
_("Worker is %s and should be regular or irregular.")
% worker.working_mode
_("%s is %s and should be regular or irregular.")
% worker.name, worker.working_mode
) )
# expected shifts status update
for id in self.expected_shift_ids.ids: for id in self.expected_shift_ids.ids:
shift = self.env["beesdoo.shift.sheet.expected"].browse(id) shift = self.env["beesdoo.shift.sheet.expected"].browse(id)
if ( if (
@ -363,6 +375,7 @@ class AttendanceSheet(models.Model):
if worker.id in added_ids: if worker.id in added_ids:
return return
# added shift creation
self.added_shift_ids |= self.added_shift_ids.new( self.added_shift_ids |= self.added_shift_ids.new(
{ {
"task_type_id": self.added_shift_ids.default_task_type_id(), "task_type_id": self.added_shift_ids.default_task_type_id(),

2
beesdoo_shift/tests/test_attendance_sheet.py

@ -247,7 +247,7 @@ class TestAttendanceSheet(TransactionCase):
self.assertEquals(sheet_1.day_abbrevation, "Lundi") self.assertEquals(sheet_1.day_abbrevation, "Lundi")
self.assertEquals(sheet_1.week, "Semaine A") self.assertEquals(sheet_1.week, "Semaine A")
self.assertTrue(sheet_1.name) self.assertTrue(sheet_1.name)
self.assertFalse(sheet_1.annotation)
self.assertFalse(sheet_1.notes)
self.assertFalse(sheet_1.is_annotated) self.assertFalse(sheet_1.is_annotated)
def test_attendance_sheet_barcode_scan(self): def test_attendance_sheet_barcode_scan(self):

16
beesdoo_shift/views/attendance_sheet.xml

@ -140,8 +140,9 @@
name="validate_with_checks" name="validate_with_checks"
string="Validate Sheet" string="Validate Sheet"
confirm="Beware : a validated sheet cannot be edited anymore confirm="Beware : a validated sheet cannot be edited anymore
and you won't be able to add any latecomers.
Emails will be sent to workers who did not attend their shift."
and you won't be able to add any latecomers.
The counters of those who didn't attend will be updated
and they will get warning emails."
attrs="{'invisible': [('state', '=', 'validated')]}" attrs="{'invisible': [('state', '=', 'validated')]}"
/> />
</div> </div>
@ -170,8 +171,9 @@
<group> <group>
<field name="max_worker_no" /> <field name="max_worker_no" />
</group> </group>
<label string="If you encounter any issues, you can add an
annotation during validation to notify permanent members."
<label string="You will be able to write notes
about what you cannot encode here
when clicking on 'validate'."
/> />
<separator string="Added workers" /> <separator string="Added workers" />
<field name="added_shift_ids"/> <field name="added_shift_ids"/>
@ -180,7 +182,7 @@
<br/> <br/>
<group col="1" string="Feedback" <group col="1" string="Feedback"
groups="beesdoo_shift.group_cooperative_admin"> groups="beesdoo_shift.group_cooperative_admin">
<field name="annotation" />
<field name="notes" />
<br/> <br/>
<field name="feedback" /> <field name="feedback" />
<br/> <br/>
@ -211,7 +213,7 @@
/> />
<!-- Annotated sheets should display only the both annotated and validated ones--> <!-- Annotated sheets should display only the both annotated and validated ones-->
<act_window id="action_sheet_admin_annotated" <act_window id="action_sheet_admin_annotated"
name="Unread annotations"
name="Unread notes"
res_model="beesdoo.shift.sheet" res_model="beesdoo.shift.sheet"
view_mode="tree,form" view_mode="tree,form"
domain="[('is_annotated','=',True), domain="[('is_annotated','=',True),
@ -252,7 +254,7 @@
groups="beesdoo_shift.group_cooperative_admin" groups="beesdoo_shift.group_cooperative_admin"
/> />
<menuitem id="menu_sheet_admin_annotated" <menuitem id="menu_sheet_admin_annotated"
name="Unread annotations"
name="Unread notes"
parent="menu_sheet_top" parent="menu_sheet_top"
action="action_sheet_admin_annotated" action="action_sheet_admin_annotated"
groups="beesdoo_shift.group_cooperative_admin" groups="beesdoo_shift.group_cooperative_admin"

20
beesdoo_shift/wizard/validate_attendance_sheet.py

@ -30,7 +30,7 @@ class ValidateAttendanceSheet(models.TransientModel):
""" """
A warning is shown if some regular workers were not expected A warning is shown if some regular workers were not expected
but should be doing their regular shifts. This warning is added but should be doing their regular shifts. This warning is added
to sheet's annotation at validation.
to sheet's notes at validation.
""" """
sheet = self._get_active_sheet() sheet = self._get_active_sheet()
warning_message = "" warning_message = ""
@ -50,9 +50,9 @@ class ValidateAttendanceSheet(models.TransientModel):
return warning_message return warning_message
@api.multi @api.multi
def _get_default_annotation(self):
def _get_default_notes(self):
if self._get_active_sheet(): if self._get_active_sheet():
return self._get_active_sheet().annotation
return self._get_active_sheet().notes
@api.multi @api.multi
def _get_default_feedback(self): def _get_default_feedback(self):
@ -72,18 +72,18 @@ class ValidateAttendanceSheet(models.TransientModel):
default=_get_warning_regular_workers, default=_get_warning_regular_workers,
help="Is any regular worker doing its regular shift as an added one ?" help="Is any regular worker doing its regular shift as an added one ?"
) )
annotation = fields.Text(
"Important information requiring permanent member assistance",
default=_get_default_annotation,
notes = fields.Text(
"Notes about the attendance for Members Office",
default=_get_default_notes,
) )
feedback = fields.Text("General feedback", default=_get_default_feedback)
feedback = fields.Text("Comments about the shift", default=_get_default_feedback)
worker_nb_feedback = fields.Selection( worker_nb_feedback = fields.Selection(
[ [
("not_enough", "Not enough"), ("not_enough", "Not enough"),
("enough", "Enough"), ("enough", "Enough"),
("too_many", "Too many"), ("too_many", "Too many"),
], ],
string="Number of workers",
string="Was your team big enough?",
default=_get_default_worker_nb_feedback, default=_get_default_worker_nb_feedback,
required=True, required=True,
) )
@ -98,7 +98,7 @@ class ValidateAttendanceSheet(models.TransientModel):
""" """
sheet = self._get_active_sheet() sheet = self._get_active_sheet()
sheet.annotation = self.annotation
sheet.notes = self.notes
sheet.feedback = self.feedback sheet.feedback = self.feedback
sheet.worker_nb_feedback = self.worker_nb_feedback sheet.worker_nb_feedback = self.worker_nb_feedback
@ -133,6 +133,6 @@ class ValidateAttendanceSheet(models.TransientModel):
) )
) )
self.annotation += self.warning_regular_workers
self.notes += self.warning_regular_workers
self.save() self.save()
sheet._validate(partner or self.env.user.partner_id) sheet._validate(partner or self.env.user.partner_id)

2
beesdoo_shift/wizard/validate_attendance_sheet.xml

@ -12,7 +12,7 @@
attrs="{'invisible': [('warning_regular_workers', '=', False)]}" attrs="{'invisible': [('warning_regular_workers', '=', False)]}"
/> />
<group col="1" string="Additional informations" > <group col="1" string="Additional informations" >
<field name="annotation" />
<field name="notes" />
<field name="feedback" /> <field name="feedback" />
</group> </group>
<group> <group>

Loading…
Cancel
Save