Browse Source

[FIX] b_shift : attendance sheet, validated by

pull/143/head
Elouan Le Bars 5 years ago
parent
commit
418a5d1423
  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: if not self.working_mode or not self.stage:
raise UserError( 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.working_mode == "regular":
if self.stage == "present": if self.stage == "present":
@ -157,7 +157,7 @@ class AttendanceSheet(models.Model):
active = fields.Boolean(string="Active", default=1) active = fields.Boolean(string="Active", default=1)
state = fields.Selection( state = fields.Selection(
[("not_validated", "Not Validated"), ("validated", "Validated"),], [("not_validated", "Not Validated"), ("validated", "Validated"),],
string="Status",
string="State",
readonly=True, readonly=True,
index=True, index=True,
default="not_validated", default="not_validated",
@ -213,13 +213,7 @@ class AttendanceSheet(models.Model):
("enough", "Enough"), ("enough", "Enough"),
("too_many", "Too many"), ("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( validated_by = fields.Many2one(
"res.partner", "res.partner",
@ -385,7 +379,7 @@ class AttendanceSheet(models.Model):
return self.search_count(domain) return self.search_count(domain)
return return
def validate(self):
def validate(self, user):
self.ensure_one() self.ensure_one()
if self.state == "validated": if self.state == "validated":
raise UserError("The sheet has already been validated.") raise UserError("The sheet has already been validated.")
@ -500,6 +494,7 @@ class AttendanceSheet(models.Model):
) )
added_shift.task_id = actual_shift.id added_shift.task_id = actual_shift.id
self.validated_by = user
self.state = "validated" self.state = "validated"
return return

5
beesdoo_shift/wizard/validate_attendance_sheet.py

@ -34,7 +34,7 @@ class ValidateAttendanceSheet(models.TransientModel):
if not len(card): if not len(card):
raise UserError(_("Please set a correct barcode.")) raise UserError(_("Please set a correct barcode."))
user = card[0].partner_id user = card[0].partner_id
if not user:
if not user.super:
raise UserError( raise UserError(
_( _(
"Only super-cooperators and administrators can validate attendance sheets." "Only super-cooperators and administrators can validate attendance sheets."
@ -43,8 +43,7 @@ class ValidateAttendanceSheet(models.TransientModel):
sheet.annotation = self.annotation sheet.annotation = self.annotation
sheet.feedback = self.feedback sheet.feedback = self.feedback
sheet.worker_nb_feedback = self.worker_nb_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): def on_barcode_scanned(self, barcode):
self.barcode = 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. and you won't be able to add any latecomers.
Emails will be sent to workers who did not attend their shift." /> Emails will be sent to workers who did not attend their shift." />
<field name="_barcode_scanned" widget="barcode_handler"/> <field name="_barcode_scanned" widget="barcode_handler"/>
<group col="1" string="Additionnal informations" >
<group col="1" string="Additional informations" >
<field name="annotation" /> <field name="annotation" />
<field name="feedback" /> <field name="feedback" />
</group> </group>
<group> <group>
<field name="worker_nb_feedback" /> <field name="worker_nb_feedback" />
</group> </group>
<group string="Scan your barcode">
<group string="Scan your card">
<field name="barcode" /> <field name="barcode" />
</group> </group>
</sheet> </sheet>

Loading…
Cancel
Save