Browse Source

[FIX] b_shift : barcode scan to attendance sheet validation

pull/143/head
Elouan Le Bars 5 years ago
parent
commit
95269a192a
  1. 20
      beesdoo_shift/wizard/validate_attendance_sheet.py
  2. 2
      beesdoo_shift/wizard/validate_attendance_sheet.xml

20
beesdoo_shift/wizard/validate_attendance_sheet.py

@ -9,23 +9,25 @@ class ValidateAttendanceSheet(models.TransientModel):
Useless for users in group_cooperative_admin""" Useless for users in group_cooperative_admin"""
_inherit = ["barcodes.barcode_events_mixin"] _inherit = ["barcodes.barcode_events_mixin"]
barcode = fields.Char("Barcode Scanned", required=True)
@api.multi @api.multi
def validate_sheet(self, user):
def validate_sheet(self):
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)
if not user.super:
card = self.env["member.card"].search(
[("barcode", "=", self.barcode)]
)
if not len(card):
raise UserError("Please set a correct barcode.")
user = card[0].partner_id
if not user:
raise UserError( raise UserError(
"Only super-cooperators and administrators can validate attendance sheets." "Only super-cooperators and administrators can validate attendance sheets."
) )
# Following methods call not working
sheet.validated_by = user sheet.validated_by = user
sheet.validate() sheet.validate()
def on_barcode_scanned(self, barcode): def on_barcode_scanned(self, barcode):
card = self.env["member.card"].search(
[("barcode", "=", barcode)]
)
if not len(card):
raise UserError("Please set a correct barcode.")
self.validate_sheet(card[0].partner_id)
self.barcode = barcode

2
beesdoo_shift/wizard/validate_attendance_sheet.xml

@ -9,7 +9,7 @@
<field name="_barcode_scanned" widget="barcode_handler"/> <field name="_barcode_scanned" widget="barcode_handler"/>
<group> <group>
<!--<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