Browse Source

[IMP] b_shift : attendance sheet validation wizard

pull/125/head
Elouan Le Bars 5 years ago
parent
commit
18655ab744
  1. 46
      beesdoo_shift/wizard/validate_attendance_sheet.py
  2. 5
      beesdoo_shift/wizard/validate_attendance_sheet.xml

46
beesdoo_shift/wizard/validate_attendance_sheet.py

@ -34,7 +34,7 @@ class ValidateAttendanceSheet(models.TransientModel):
but should be doing their regular shifts. This warning is added but should be doing their regular shifts. This warning is added
to sheet's notes at validation. to sheet's notes at validation.
""" """
sheet = self._get_active_sheet()
sheet = self.active_sheet
warning_message = "" warning_message = ""
if sheet: if sheet:
for added_shift in sheet.added_shift_ids: for added_shift in sheet.added_shift_ids:
@ -53,21 +53,9 @@ class ValidateAttendanceSheet(models.TransientModel):
) )
return warning_message return warning_message
@api.multi
def _get_default_notes(self):
if self._get_active_sheet():
return self._get_active_sheet().notes
@api.multi
def _get_default_feedback(self):
if self._get_active_sheet():
return self._get_active_sheet().feedback
@api.multi
def _get_default_worker_nb_feedback(self):
if self._get_active_sheet():
return self._get_active_sheet().worker_nb_feedback
active_sheet = fields.Many2one(
"beesdoo.shift.sheet", default=_get_active_sheet
)
card_support = fields.Boolean(default=_get_card_support_setting) card_support = fields.Boolean(default=_get_card_support_setting)
login = fields.Char(string="Login") login = fields.Char(string="Login")
password = fields.Char(string="Password") password = fields.Char(string="Password")
@ -77,22 +65,10 @@ class ValidateAttendanceSheet(models.TransientModel):
default=_get_warning_regular_workers, default=_get_warning_regular_workers,
help="Is any regular worker doing its regular shift as an added one ?", help="Is any regular worker doing its regular shift as an added one ?",
) )
notes = fields.Text(
"Notes about the attendance for Members Office",
default=_get_default_notes,
)
feedback = fields.Text(
"Comments about the shift", default=_get_default_feedback
)
notes = fields.Text(related="active_sheet.notes")
feedback = fields.Text(related="active_sheet.feedback")
worker_nb_feedback = fields.Selection( worker_nb_feedback = fields.Selection(
[
("not_enough", "Not enough"),
("enough", "Enough"),
("too_many", "Too many"),
],
string="Was your team big enough?",
default=_get_default_worker_nb_feedback,
required=True,
related="active_sheet.worker_nb_feedback", required=True
) )
def on_barcode_scanned(self, barcode): def on_barcode_scanned(self, barcode):
@ -100,18 +76,14 @@ class ValidateAttendanceSheet(models.TransientModel):
@api.multi @api.multi
def save(self): def save(self):
"""
Save modifications onto attendance sheet.
"""
sheet = self._get_active_sheet()
sheet = self.active_sheet
sheet.notes = self.notes sheet.notes = self.notes
sheet.feedback = self.feedback sheet.feedback = self.feedback
sheet.worker_nb_feedback = self.worker_nb_feedback sheet.worker_nb_feedback = self.worker_nb_feedback
@api.multi @api.multi
def validate_sheet(self): def validate_sheet(self):
sheet = self._get_active_sheet()
sheet = self.active_sheet
if self.card_support: if self.card_support:
# Login with barcode # Login with barcode

5
beesdoo_shift/wizard/validate_attendance_sheet.xml

@ -5,8 +5,10 @@
<field name="arch" type="xml"> <field name="arch" type="xml">
<form> <form>
<sheet> <sheet>
<separator string="Validation"/>
<field name="card_support" invisible="1" />
<field name="active_sheet" invisible="1" />
<field name="_barcode_scanned" widget="barcode_handler"/> <field name="_barcode_scanned" widget="barcode_handler"/>
<separator string="Validation"/>
<field name="warning_regular_workers" <field name="warning_regular_workers"
readonly="1" readonly="1"
attrs="{'invisible': [('warning_regular_workers', '=', False)]}" attrs="{'invisible': [('warning_regular_workers', '=', False)]}"
@ -18,7 +20,6 @@
<group> <group>
<field name="worker_nb_feedback"/> <field name="worker_nb_feedback"/>
</group> </group>
<field name="card_support" invisible="1" />
<group string="Login" <group string="Login"
attrs="{'invisible': [('card_support', '=', True)]}" attrs="{'invisible': [('card_support', '=', True)]}"
> >

Loading…
Cancel
Save