Browse Source

[ADD] b_shift : attendance sheet validation wizard

pull/125/head
Elouan Le Bars 5 years ago
parent
commit
760fdebf97
  1. 1
      beesdoo_shift/__openerp__.py
  2. 4
      beesdoo_shift/views/attendance_sheet.xml
  3. 1
      beesdoo_shift/wizard/__init__.py
  4. 31
      beesdoo_shift/wizard/validate_attendance_sheet.py
  5. 21
      beesdoo_shift/wizard/validate_attendance_sheet.xml

1
beesdoo_shift/__openerp__.py

@ -28,6 +28,7 @@
"views/planning.xml", "views/planning.xml",
"views/cooperative_status.xml", "views/cooperative_status.xml",
"views/exempt_reason.xml", "views/exempt_reason.xml",
"wizard/validate_attendance_sheet.xml",
"views/attendance_sheet.xml", "views/attendance_sheet.xml",
"views/attendance_sheet_admin.xml", "views/attendance_sheet_admin.xml",
"wizard/instanciate_planning.xml", "wizard/instanciate_planning.xml",

4
beesdoo_shift/views/attendance_sheet.xml

@ -64,6 +64,10 @@
<form create="false" delete="false"> <form create="false" delete="false">
<header> <header>
<field name="state" widget="statusbar" readonly="True" /> <field name="state" widget="statusbar" readonly="True" />
<button type="object"
name="validate_via_wizard"
string="Validate Sheet"
/>
</header> </header>
<sheet> <sheet>
<div class="oe_title"> <div class="oe_title">

1
beesdoo_shift/wizard/__init__.py

@ -6,3 +6,4 @@ import subscribe
import extension import extension
import holiday import holiday
import temporary_exemption import temporary_exemption
import validate_attendance_sheet

31
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

21
beesdoo_shift/wizard/validate_attendance_sheet.xml

@ -0,0 +1,21 @@
<odoo>
<record model="ir.ui.view" id="validate_attendance_sheet_form">
<field name="name">Validate Attendance Sheet</field>
<field name="model">beesdoo.shift.sheet.validate</field>
<field name="arch" type="xml">
<form>
<label string="Beware : a validated sheet cannot be edited anymore and you won't be able to add any latecomers.
Emails will be sent to workers who did not attend their shift." />
<group>
<field name="user" />
</group>
<footer>
<button type="object" name="validate_sheet"
string="Confirm" class="oe_highlight" />
or
<button special="cancel" string="Cancel" />
</footer>
</form>
</field>
</record>
</odoo>
Loading…
Cancel
Save