Browse Source

[ADD] b_shift : constrains on future attendance sheets validation

pull/125/head
Elouan Le Bars 5 years ago
parent
commit
e86b18ee7d
  1. 6
      beesdoo_shift/models/attendance_sheet.py
  2. 11
      beesdoo_shift/wizard/validate_attendance_sheet.py

6
beesdoo_shift/models/attendance_sheet.py

@ -477,8 +477,14 @@ class AttendanceSheet(models.Model):
@api.multi
def validate_with_checks(self):
self.ensure_one()
start_time_dt = fields.Datetime.from_string(self.start_time)
if self.state == "validated":
raise UserError("The sheet has already been validated.")
if start_time_dt > datetime.now():
raise UserError(
_("You must wait for the shifts to begin to validate sheet.")
)
# Fields validation
for added_shift in self.added_shift_ids:

11
beesdoo_shift/wizard/validate_attendance_sheet.py

@ -10,9 +10,12 @@ class ValidateAttendanceSheet(models.TransientModel):
_inherit = ["barcodes.barcode_events_mixin"]
def _get_card_support_setting(self):
return self.env["ir.config_parameter"].get_param(
return (
self.env["ir.config_parameter"].get_param(
"beesdoo_shift.card_support"
) == "True"
)
== "True"
)
@api.multi
def _default_annotation(self):
@ -70,7 +73,9 @@ class ValidateAttendanceSheet(models.TransientModel):
if self.card_support:
# Login with barcode
card = self.env["member.card"].search([("barcode", "=", self.barcode)])
card = self.env["member.card"].search(
[("barcode", "=", self.barcode)]
)
if not len(card):
raise UserError(_("Please set a correct barcode."))
partner = card[0].partner_id

Loading…
Cancel
Save