diff --git a/beesdoo_shift/data/system_parameter.xml b/beesdoo_shift/data/system_parameter.xml
index 1b7fede..0a4a676 100644
--- a/beesdoo_shift/data/system_parameter.xml
+++ b/beesdoo_shift/data/system_parameter.xml
@@ -31,6 +31,10 @@
regular_counter_to_unsubscribe
-4
+
+ beesdoo_shift.card_support
+ False
+
beesdoo_shift.attendance_sheet_generation_interval
15
diff --git a/beesdoo_shift/models/res_config.py b/beesdoo_shift/models/res_config.py
index 1f82528..aed6d87 100644
--- a/beesdoo_shift/models/res_config.py
+++ b/beesdoo_shift/models/res_config.py
@@ -10,21 +10,29 @@ class ShiftConfigSettings(models.TransientModel):
_name = "beesdoo.shift.config.settings"
_inherit = "res.config.settings"
+ card_support = fields.Boolean(
+ string="Scan cooperators cards instead of login for sheets validation",
+ default=False
+ )
default_task_type_id = fields.Many2one(
"beesdoo.shift.type",
string="Default Task Type",
- help="Default task type for attendance sheet pre-filling.",
+ help="Default task type for attendance sheet pre-filling",
+ required=True,
)
attendance_sheet_generation_interval = fields.Integer(
string="Time interval for attendance sheet generation",
help="Time interval expressed in minutes",
+ required=True,
)
@api.multi
def set_params(self):
self.ensure_one()
-
parameters = self.env["ir.config_parameter"]
+ parameters.set_param(
+ "beesdoo_shift.card_support", str(self.card_support),
+ )
parameters.set_param(
"beesdoo_shift.default_task_type_id",
str(self.default_task_type_id.id),
@@ -34,6 +42,17 @@ class ShiftConfigSettings(models.TransientModel):
str(self.attendance_sheet_generation_interval),
)
+ @api.multi
+ def get_default_card_support(self):
+ return {
+ "card_support": (
+ self.env["ir.config_parameter"].get_param(
+ "beesdoo_shift.card_support"
+ )
+ == "True"
+ )
+ }
+
@api.multi
def get_default_task_type_id(self):
return {
diff --git a/beesdoo_shift/views/res_config_view.xml b/beesdoo_shift/views/res_config_view.xml
index ef30fc3..73d6e7a 100644
--- a/beesdoo_shift/views/res_config_view.xml
+++ b/beesdoo_shift/views/res_config_view.xml
@@ -40,6 +40,7 @@
+
diff --git a/beesdoo_shift/wizard/validate_attendance_sheet.py b/beesdoo_shift/wizard/validate_attendance_sheet.py
index e16a86c..b7aefea 100644
--- a/beesdoo_shift/wizard/validate_attendance_sheet.py
+++ b/beesdoo_shift/wizard/validate_attendance_sheet.py
@@ -9,6 +9,11 @@ class ValidateAttendanceSheet(models.TransientModel):
Useless for users in group_cooperative_admin"""
_inherit = ["barcodes.barcode_events_mixin"]
+ def _get_card_support_setting(self):
+ return self.env["ir.config_parameter"].get_param(
+ "beesdoo_shift.card_support"
+ ) == "True"
+
@api.multi
def _default_annotation(self):
"""
@@ -35,7 +40,10 @@ class ValidateAttendanceSheet(models.TransientModel):
)
return warning_message
- barcode = fields.Char(string="Barcode", required=True)
+ card_support = fields.Boolean(default=_get_card_support_setting)
+ user_id = fields.Many2one("res.users", string="Login")
+ password = fields.Char(string="Password")
+ barcode = fields.Char(string="Barcode")
annotation = fields.Text(
"Important information requiring permanent member assistance",
default=_default_annotation,
@@ -59,13 +67,24 @@ class ValidateAttendanceSheet(models.TransientModel):
sheet_id = self._context.get("active_id")
sheet_model = self._context.get("active_model")
sheet = self.env[sheet_model].browse(sheet_id)
- 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
+
+ if self.card_support:
+ # Login with 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
+ else:
+ # Login with credentials
+ if not self.user_id:
+ raise UserError(_("Please enter an user name."))
+ self.user_id.sudo(self.user_id.id).check_credentials(self.password)
+ partner = self.user_id.partner_id
+
is_admin = partner.user_ids.has_group(
"beesdoo_shift.group_cooperative_admin"
)
+
if not partner.super and not is_admin:
raise UserError(
_(
diff --git a/beesdoo_shift/wizard/validate_attendance_sheet.xml b/beesdoo_shift/wizard/validate_attendance_sheet.xml
index 3256124..1d8a1c0 100644
--- a/beesdoo_shift/wizard/validate_attendance_sheet.xml
+++ b/beesdoo_shift/wizard/validate_attendance_sheet.xml
@@ -17,7 +17,16 @@
-
+
+
+
+
+
+