Browse Source

[FIX] b_shift : attendance sheet, validated by

pull/125/head
Elouan Le Bars 5 years ago
parent
commit
52557761bc
  1. 15
      beesdoo_shift/models/attendance_sheet.py
  2. 5
      beesdoo_shift/wizard/validate_attendance_sheet.py
  3. 4
      beesdoo_shift/wizard/validate_attendance_sheet.xml

15
beesdoo_shift/models/attendance_sheet.py

@ -73,7 +73,7 @@ class AttendanceSheetShift(models.AbstractModel):
"""
if not self.working_mode or not self.stage:
raise UserError(
_("Impossible to map task status, all values are not set.")
_("Impossible to map task stage, all values are not set.")
)
if self.working_mode == "regular":
if self.stage == "present":
@ -157,7 +157,7 @@ class AttendanceSheet(models.Model):
active = fields.Boolean(string="Active", default=1)
state = fields.Selection(
[("not_validated", "Not Validated"), ("validated", "Validated"),],
string="Status",
string="State",
readonly=True,
index=True,
default="not_validated",
@ -213,13 +213,7 @@ class AttendanceSheet(models.Model):
("enough", "Enough"),
("too_many", "Too many"),
],
string="Number of workers.",
)
attended_worker_nb = fields.Integer(
string="Number of attended workers",
default=0,
help="Number of workers who attended the session.",
readonly=True,
string="Number of workers",
)
validated_by = fields.Many2one(
"res.partner",
@ -385,7 +379,7 @@ class AttendanceSheet(models.Model):
return self.search_count(domain)
return
def validate(self):
def validate(self, user):
self.ensure_one()
if self.state == "validated":
raise UserError("The sheet has already been validated.")
@ -500,6 +494,7 @@ class AttendanceSheet(models.Model):
)
added_shift.task_id = actual_shift.id
self.validated_by = user
self.state = "validated"
return

5
beesdoo_shift/wizard/validate_attendance_sheet.py

@ -34,7 +34,7 @@ class ValidateAttendanceSheet(models.TransientModel):
if not len(card):
raise UserError(_("Please set a correct barcode."))
user = card[0].partner_id
if not user:
if not user.super:
raise UserError(
_(
"Only super-cooperators and administrators can validate attendance sheets."
@ -43,8 +43,7 @@ class ValidateAttendanceSheet(models.TransientModel):
sheet.annotation = self.annotation
sheet.feedback = self.feedback
sheet.worker_nb_feedback = self.worker_nb_feedback
sheet.validated_by = user
sheet.validate()
sheet.validate(user or self.env.user.partner_id)
def on_barcode_scanned(self, barcode):
self.barcode = barcode

4
beesdoo_shift/wizard/validate_attendance_sheet.xml

@ -10,14 +10,14 @@
and you won't be able to add any latecomers.
Emails will be sent to workers who did not attend their shift." />
<field name="_barcode_scanned" widget="barcode_handler"/>
<group col="1" string="Additionnal informations" >
<group col="1" string="Additional informations" >
<field name="annotation" />
<field name="feedback" />
</group>
<group>
<field name="worker_nb_feedback" />
</group>
<group string="Scan your barcode">
<group string="Scan your card">
<field name="barcode" />
</group>
</sheet>

Loading…
Cancel
Save