Browse Source

[REF] b_shift : code cleaning

pull/125/head
Elouan Le Bars 5 years ago
parent
commit
55a0ab5646
  1. 25
      beesdoo_shift/models/attendance_sheet.py
  2. 1
      beesdoo_shift/security/group.xml

25
beesdoo_shift/models/attendance_sheet.py

@ -246,7 +246,7 @@ class AttendanceSheet(models.Model):
start_time_dt = fields.Datetime.context_timestamp( start_time_dt = fields.Datetime.context_timestamp(
rec, start_time_dt rec, start_time_dt
) )
name = "[%s] " % (fields.Date.to_string(start_time_dt),)
name = "[%s] " % fields.Date.to_string(start_time_dt)
if rec.week: if rec.week:
name += rec.week + " " name += rec.week + " "
if rec.day_abbrevation: if rec.day_abbrevation:
@ -277,7 +277,7 @@ class AttendanceSheet(models.Model):
def _compute_week(self): def _compute_week(self):
""" """
Compute Week Name from Planning Name Compute Week Name from Planning Name
of first expected shift with one
of first expected shift with one.
""" """
for rec in self: for rec in self:
for shift in rec.expected_shift_ids: for shift in rec.expected_shift_ids:
@ -337,22 +337,31 @@ class AttendanceSheet(models.Model):
) )
if worker.state == "unsubscribed": if worker.state == "unsubscribed":
shift_counter = worker.cooperative_status_ids.sc + worker.cooperative_status_ids.sr
raise UserError(_(
shift_counter = (
worker.cooperative_status_ids.sc
+ worker.cooperative_status_ids.sr
)
raise UserError(
_(
"Beware, your account is frozen because your shift counter " "Beware, your account is frozen because your shift counter "
"is at %s. Please contact Members Office to unfreeze it. " "is at %s. Please contact Members Office to unfreeze it. "
"If you want to attend this shift, your supercoop " "If you want to attend this shift, your supercoop "
"can write your name in the notes field during validation." "can write your name in the notes field during validation."
) % shift_counter)
)
% shift_counter
)
if worker.state == "resigning": if worker.state == "resigning":
raise UserError(_(
raise UserError(
_(
"Beware, you are recorded as resigning. " "Beware, you are recorded as resigning. "
"Please contact member's office if this is incorrect. Thank you." "Please contact member's office if this is incorrect. Thank you."
))
)
)
if worker.working_mode not in ("regular", "irregular"): if worker.working_mode not in ("regular", "irregular"):
raise UserError( raise UserError(
_("%s is %s and should be regular or irregular.") _("%s is %s and should be regular or irregular.")
% worker.name, worker.working_mode
% worker.name,
worker.working_mode,
) )
# expected shifts status update # expected shifts status update

1
beesdoo_shift/security/group.xml

@ -26,6 +26,7 @@
/> />
<field name="users" eval="[(4, ref('base.user_root'))]"/> <field name="users" eval="[(4, ref('base.user_root'))]"/>
</record> </record>
<!-- Could the following be removed ? -->
<record model="ir.ui.menu" id="base.menu_board_root"> <record model="ir.ui.menu" id="base.menu_board_root">
<field name="groups_id" eval="[(6,0,[ref('group_shift_attendance_sheet')])]"/> <field name="groups_id" eval="[(6,0,[ref('group_shift_attendance_sheet')])]"/>
</record> </record>

Loading…
Cancel
Save