From 760fdebf9737b33e4d4db53e3d90577453602482 Mon Sep 17 00:00:00 2001 From: Elouan Le Bars Date: Thu, 31 Oct 2019 18:10:35 +0100 Subject: [PATCH] [ADD] b_shift : attendance sheet validation wizard --- beesdoo_shift/__openerp__.py | 1 + beesdoo_shift/views/attendance_sheet.xml | 4 +++ beesdoo_shift/wizard/__init__.py | 1 + .../wizard/validate_attendance_sheet.py | 31 +++++++++++++++++++ .../wizard/validate_attendance_sheet.xml | 21 +++++++++++++ 5 files changed, 58 insertions(+) create mode 100644 beesdoo_shift/wizard/validate_attendance_sheet.py create mode 100644 beesdoo_shift/wizard/validate_attendance_sheet.xml diff --git a/beesdoo_shift/__openerp__.py b/beesdoo_shift/__openerp__.py index 27faeac..f732eff 100644 --- a/beesdoo_shift/__openerp__.py +++ b/beesdoo_shift/__openerp__.py @@ -28,6 +28,7 @@ "views/planning.xml", "views/cooperative_status.xml", "views/exempt_reason.xml", + "wizard/validate_attendance_sheet.xml", "views/attendance_sheet.xml", "views/attendance_sheet_admin.xml", "wizard/instanciate_planning.xml", diff --git a/beesdoo_shift/views/attendance_sheet.xml b/beesdoo_shift/views/attendance_sheet.xml index c816ff5..1c3e433 100644 --- a/beesdoo_shift/views/attendance_sheet.xml +++ b/beesdoo_shift/views/attendance_sheet.xml @@ -64,6 +64,10 @@
+
diff --git a/beesdoo_shift/wizard/__init__.py b/beesdoo_shift/wizard/__init__.py index 7f92f15..91f5444 100644 --- a/beesdoo_shift/wizard/__init__.py +++ b/beesdoo_shift/wizard/__init__.py @@ -6,3 +6,4 @@ import subscribe import extension import holiday import temporary_exemption +import validate_attendance_sheet diff --git a/beesdoo_shift/wizard/validate_attendance_sheet.py b/beesdoo_shift/wizard/validate_attendance_sheet.py new file mode 100644 index 0000000..dc81004 --- /dev/null +++ b/beesdoo_shift/wizard/validate_attendance_sheet.py @@ -0,0 +1,31 @@ +# -*- coding: utf-8 -*- +from openerp import models, fields, api, exceptions, _ +from openerp.exceptions import UserError, ValidationError + + +class ValidateAttendanceSheet(models.TransientModel): + _name = "beesdoo.shift.sheet.validate" + _description = """Check the user name and validate sheet. + Useless for users in group_cooperative_admin""" + + def _get_sheet(self): + return self._context.get("active_id") + + # current user as default value ! + user = fields.Many2one("res.partner", string="User Name", required=True,) + + # Is the "@api.multi" correct here ? + @api.multi + def validate_sheet(self): + sheet_id = self._context.get("active_id") + sheet_model = self._context.get("active_model") + sheet = self.env[sheet_model].browse(sheet_id) + sheet.ensure_one() + if not self.user.super: + raise UserError( + "You must be super-coop or admin to validate the sheet." + ) + sheet.validated_by = self.user + sheet.validate() + + return diff --git a/beesdoo_shift/wizard/validate_attendance_sheet.xml b/beesdoo_shift/wizard/validate_attendance_sheet.xml new file mode 100644 index 0000000..d68de37 --- /dev/null +++ b/beesdoo_shift/wizard/validate_attendance_sheet.xml @@ -0,0 +1,21 @@ + + + Validate Attendance Sheet + beesdoo.shift.sheet.validate + + + + +