Browse Source

[ADD] b_shift : attendance shift validation barcode field

pull/143/head
Elouan Le Bars 5 years ago
parent
commit
6fc398ed67
  1. 15
      beesdoo_shift/wizard/validate_attendance_sheet.py
  2. 1
      beesdoo_shift/wizard/validate_attendance_sheet.xml

15
beesdoo_shift/wizard/validate_attendance_sheet.py

@ -12,11 +12,24 @@ class ValidateAttendanceSheet(models.TransientModel):
return self._context.get("active_id") return self._context.get("active_id")
# current user as default value ! # current user as default value !
user = fields.Many2one("res.partner", string="User Name", required=True,)
#card = fields.Many2one("member.card", string="MemberCard")
barcode = fields.Char(string="Barcode", required=True)
user = fields.Many2one("res.partner", compute="_compute_user", string="User Name", readonly=True)
@api.depends("barcode")
def _compute_user(self):
if self.barcode:
card = self.env["member.card"].search([("barcode", "=", self.barcode)])
if card:
self.user = card[0].partner_id
else:
self.user = False
# Is the "@api.multi" correct here ? # Is the "@api.multi" correct here ?
@api.multi @api.multi
def validate_sheet(self): def validate_sheet(self):
if not self.user:
raise UserError("Please set a correct barcode.")
sheet_id = self._context.get("active_id") sheet_id = self._context.get("active_id")
sheet_model = self._context.get("active_model") sheet_model = self._context.get("active_model")
sheet = self.env[sheet_model].browse(sheet_id) sheet = self.env[sheet_model].browse(sheet_id)

1
beesdoo_shift/wizard/validate_attendance_sheet.xml

@ -8,6 +8,7 @@
Emails will be sent to workers who did not attend their shift." /> Emails will be sent to workers who did not attend their shift." />
<group> <group>
<field name="user" /> <field name="user" />
<field name="barcode" />
</group> </group>
<footer> <footer>
<button type="object" name="validate_sheet" <button type="object" name="validate_sheet"

Loading…
Cancel
Save