Browse Source

[FIX] beesdoo_shift_attendance: Installation

Test does not succeed yet.
pull/133/head
Rémy Taymans 5 years ago
parent
commit
226e4addd1
  1. 61
      beesdoo_shift/models/res_config_settings.py
  2. 1
      beesdoo_shift/security/group.xml
  3. 9
      beesdoo_shift_attendance/__manifest__.py
  4. 3
      beesdoo_shift_attendance/data/mail_template.xml
  5. 12
      beesdoo_shift_attendance/data/system_parameter.xml
  6. 55
      beesdoo_shift_attendance/demo/users.xml
  7. 22
      beesdoo_shift_attendance/models/attendance_sheet.py
  8. 22
      beesdoo_shift_attendance/models/res_config_settings.py
  9. 21
      beesdoo_shift_attendance/security/group.xml
  10. 12
      beesdoo_shift_attendance/security/ir.model.access.csv
  11. 20
      beesdoo_shift_attendance/tests/test_beesdoo_shift.py
  12. 4
      beesdoo_shift_attendance/views/attendance_sheet.xml
  13. 2
      beesdoo_shift_attendance/views/res_config_settings_view.xml
  14. 4
      beesdoo_shift_attendance/wizard/validate_attendance_sheet.py

61
beesdoo_shift/models/res_config_settings.py

@ -1,61 +0,0 @@
# Copyright 2019-2020 Elouan Le Bars <elouan@coopiteasy.be>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
import ast
from odoo import fields, models, api
class ResConfigSettings(models.TransientModel):
_inherit = "res.config.settings"
card_support = fields.Boolean(
string="Scan cooperators cards instead of login for sheets validation",
config_parameter="beesdoo_shift.card_support",
)
pre_filled_task_type_id = fields.Many2one(
"beesdoo.shift.type",
string="Default Task Type",
help="Default task type for attendance sheet pre-filling",
required=True,
default=False,
)
attendance_sheet_generation_interval = fields.Integer(
string="Time interval for attendance sheet generation",
help="Time interval expressed in minutes",
required=True,
config_parameter="beesdoo_shift.attendance_sheet_generation_interval",
)
@api.multi
def set_values(self):
super(ResConfigSettings, self).set_values()
parameters = self.env["ir.config_parameter"].sudo()
parameters.set_param(
"beesdoo_shift.card_support", str(self.card_support),
)
parameters.set_param(
"beesdoo_shift.pre_filled_task_type_id",
str(self.pre_filled_task_type_id.id),
)
parameters.set_param(
"beesdoo_shift.attendance_sheet_generation_interval",
str(self.attendance_sheet_generation_interval),
)
@api.multi
def get_values(self):
res = super(ResConfigSettings, self).get_values()
res.update(
card_support=ast.literal_eval(
self.env["ir.config_parameter"].get_param(
"beesdoo_shift.card_support"
),
),
pre_filled_task_type_id=int(
self.env["ir.config_parameter"].get_param(
"beesdoo_shift.pre_filled_task_type_id"
)
),
)
return res

1
beesdoo_shift/security/group.xml

@ -2,7 +2,6 @@
<record id="group_shift_attendance" model="res.groups">
<field name="name">Shift and Worker Read Access</field>
<field name="category_id" ref="base.module_category_cooperative_management"/>
<!-- <field name="implied_ids" eval="[(4, ref('group_shift_attendance_sheet'))]"/> FIXME this group has been moved to beesdoo_shift_attendance-->
</record>
<record id="group_shift_management" model="res.groups">
<field name="name">Shifts and Attendance Sheets Management</field>

9
beesdoo_shift_attendance/__manifest__.py

@ -1,9 +1,14 @@
# This module is, for now, specific to the BEES coop.
# Therefore, this module depends on `beesdo_worker_status`.
# If someone needs this module but has another worker_status rules
# this module can be splitted into a generic part, and a specific part
# that implement the worker_status rules.
{
'name': "Beescoop Shift Attendance Sheet",
'summary': """
Volonteer Timetable Management
Attendance Sheet""",
Attendance Sheet for BEES coop""",
'description': """
@ -17,7 +22,7 @@
'depends': [
'beesdoo_shift',
'beesdoo_worker_status', #TODO move the part that require beesdoo_worker_status in beesdoo_worker status or another module
'beesdoo_worker_status',
'mail',
'barcodes',
],

3
beesdoo_shift_attendance/data/mail_template.xml

@ -7,7 +7,7 @@
<field name="name">Shift Non-attendance</field>
<field name="subject">Non-attendance to your last shift.</field>
<field name="partner_to">${object.replaced_id.id or object.worker_id.id|safe}</field>
<field name="model_id" ref="model_beesdoo_shift_shift"/>
<field name="model_id" ref="beesdoo_shift.model_beesdoo_shift_shift"/>
<field name="auto_delete" eval="True"/>
<field name="lang">${object.worker_id.lang}</field>
<field name="body_html"><![CDATA[
@ -97,6 +97,7 @@
</div>
]]></field>
</record>
<record id="email_template_non_validated_sheet" model="mail.template">
<field name="name">Non-validated sheet</field>
<field name="subject">[${object.day}] Non-validated sheet ${object.time_slot}</field>

12
beesdoo_shift_attendance/data/system_parameter.xml

@ -1,14 +1,14 @@
<odoo noupdate="1">
<record id="beesdoo_shift.card_support" model="ir.config_parameter">
<field name="key">beesdoo_shift.card_support</field>
<record id="card_support" model="ir.config_parameter">
<field name="key">beesdoo_shift_attendance.card_support</field>
<field name="value">False</field>
</record>
<record id="beesdoo_shift.attendance_sheet_generation_interval" model="ir.config_parameter">
<field name="key">beesdoo_shift.attendance_sheet_generation_interval</field>
<record id="attendance_sheet_generation_interval" model="ir.config_parameter">
<field name="key">beesdoo_shift_attendance.attendance_sheet_generation_interval</field>
<field name="value">15</field>
</record>
<record id="beesdoo_shift.default_task_type_id" model="ir.config_parameter">
<field name="key">beesdoo_shift.default_task_type_id</field>
<record id="default_task_type_id" model="ir.config_parameter">
<field name="key">beesdoo_shift_attendance.default_task_type_id</field>
<field name="value">1</field>
</record>
</odoo>

55
beesdoo_shift_attendance/demo/users.xml

@ -4,36 +4,37 @@
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-->
<odoo>
<!-- Generic and permanent account -->
<!-- Generic and permanent account -->
<record id="beesdoo_shift_partner_1_demo" model="res.partner">
<field name="firstname">Generic Account</field>
<field name="lastname">Demo</field>
<field name="email">generic@demo.net</field>
</record>
<record id="beesdoo_shift_partner_1_demo" model="res.partner">
<field name="firstname">Generic Account</field>
<field name="lastname">Demo</field>
<field name="email">generic@demo.net</field>
</record>
<record id="beesdoo_shift_partner_2_demo" model="res.partner">
<field name="firstname">Permanent Member</field>
<field name="lastname">Demo</field>
<field name="is_company" eval="False"/>
<field name="email">permanent@demo.net</field>
<field name="city">Ixelles</field>
<field name="zip">1050</field>
<field name="country_id" ref="base.be"/>
</record>
<record id="beesdoo_shift_partner_2_demo" model="res.partner">
<field name="firstname">Permanent Member</field>
<field name="lastname">Demo</field>
<field name="is_company" eval="False"/>
<field name="email">permanent@demo.net</field>
<field name="city">Ixelles</field>
<field name="zip">1050</field>
<field name="country_id" ref="base.be"/>
</record>
<record id="beesdoo_shift_user_1_demo" model="res.users">
<field name="partner_id" ref="beesdoo_shift_partner_1_demo"/>
<field name="login">generic</field>
<field name="password">demo</field>
<field name="groups_id" eval="[(4,ref('beesdoo_shift.group_shift_attendance_sheet'))]"/>
</record>
<record id="beesdoo_shift_user_1_demo" model="res.users">
<field name="partner_id" ref="beesdoo_shift_partner_1_demo"/>
<field name="login">generic</field>
<field name="password">demo</field>
<field name="groups_id" eval="[(4,ref('beesdoo_shift_attendance.group_shift_attendance_sheet'))]"/>
<field name="groups_id" eval="[(4,ref('base.group_user'))]"/>
</record>
<record id="beesdoo_shift_user_2_demo" model="res.users">
<field name="partner_id" ref="beesdoo_shift_partner_2_demo"/>
<field name="login">permanent</field>
<field name="password">demo</field>
<field name="groups_id" eval="[(4,ref('beesdoo_shift.group_shift_management'))]"/>
</record>
<record id="beesdoo_shift_user_2_demo" model="res.users">
<field name="partner_id" ref="beesdoo_shift_partner_2_demo"/>
<field name="login">permanent</field>
<field name="password">demo</field>
<field name="groups_id" eval="[(4,ref('beesdoo_shift.group_shift_management'))]"/>
</record>
</odoo>

22
beesdoo_shift_attendance/models/attendance_sheet.py

@ -1,4 +1,3 @@
from datetime import date, datetime, timedelta
from lxml import etree
@ -24,13 +23,13 @@ class AttendanceSheetShift(models.Model):
@api.model
def pre_filled_task_type_id(self):
parameters = self.env["ir.config_parameter"].sudo()
id = int(
tasktype_id = int(
parameters.get_param(
"beesdoo_shift.pre_filled_task_type_id", default=1
"beesdoo_shift_attendance.pre_filled_task_type_id", default=1
)
)
task_types = self.env["beesdoo.shift.type"]
return task_types.browse(default_task_type_id)
return task_types.browse(tasktype_id)
# Related actual shift
task_id = fields.Many2one("beesdoo.shift.shift", string="Task")
@ -320,7 +319,7 @@ class AttendanceSheet(models.Model):
)
def on_barcode_scanned(self, barcode):
if self.env.user.has_group("beesdoo_shift.group_shift_attendance"):
if self.env.user.has_group("beesdoo_shift_attendance.group_shift_attendance"):
raise UserError(
_("You must be logged as 'Attendance Sheet Generic Access' "
" if you want to scan cards.")
@ -469,7 +468,7 @@ class AttendanceSheet(models.Model):
if expected_shift.state != "done":
mail_template = self.env.ref(
"beesdoo_shift.email_template_non_attendance", False
"beesdoo_shift_attendance.email_template_non_attendance", False
)
mail_template.send_mail(expected_shift.task_id.id, True)
@ -584,7 +583,9 @@ class AttendanceSheet(models.Model):
)
# Open a validation wizard only if not admin
if self.env.user.has_group("beesdoo_shift.group_shift_attendance_sheet_validation"):
if self.env.user.has_group(
"beesdoo_shift_attendance.group_shift_attendance_sheet_validation"
):
if not self.worker_nb_feedback:
raise UserError(
_("Please give your feedback about the number of workers.")
@ -611,7 +612,7 @@ class AttendanceSheet(models.Model):
current_time = datetime.now()
generation_interval_setting = int(
self.env["ir.config_parameter"].sudo().get_param(
"beesdoo_shift.attendance_sheet_generation_interval"
"beesdoo_shift_attendance.attendance_sheet_generation_interval"
)
)
@ -628,7 +629,7 @@ class AttendanceSheet(models.Model):
start_time = task.start_time
end_time = task.end_time
sheets = sheets.search(
[("start_time", "=", start_time), ("end_time", "=", end_time),]
[("start_time", "=", start_time), ("end_time", "=", end_time)]
)
if not sheets:
@ -648,7 +649,8 @@ class AttendanceSheet(models.Model):
if non_validated_sheets:
mail_template = self.env.ref(
"beesdoo_shift.email_template_non_validated_sheet", False
"beesdoo_shift_attendance.email_template_non_validated_sheet",
False,
)
for rec in non_validated_sheets:
mail_template.send_mail(rec.id, True)

22
beesdoo_shift_attendance/models/res_config_settings.py

@ -11,9 +11,9 @@ class ResConfigSettings(models.TransientModel):
card_support = fields.Boolean(
string="Scan cooperators cards instead of login for sheets validation",
config_parameter="beesdoo_shift.card_support",
config_parameter="beesdoo_shift_attendance.card_support",
)
task_type_default_id = fields.Many2one(
pre_filled_task_type_id = fields.Many2one(
"beesdoo.shift.type",
string="Default Task Type",
help="Default task type for attendance sheet pre-filling",
@ -24,7 +24,9 @@ class ResConfigSettings(models.TransientModel):
string="Time interval for attendance sheet generation",
help="Time interval expressed in minutes",
required=True,
config_parameter="beesdoo_shift.attendance_sheet_generation_interval",
config_parameter=(
"beesdoo_shift_attendance.attendance_sheet_generation_interval"
),
)
@api.multi
@ -32,14 +34,14 @@ class ResConfigSettings(models.TransientModel):
super(ResConfigSettings, self).set_values()
parameters = self.env["ir.config_parameter"].sudo()
parameters.set_param(
"beesdoo_shift.card_support", str(self.card_support),
"beesdoo_shift_attendance.card_support", str(self.card_support),
)
parameters.set_param(
"beesdoo_shift.task_type_default_id",
str(self.task_type_default_id.id),
"beesdoo_shift_attendance.pre_filled_task_type_id",
str(self.pre_filled_task_type_id.id),
)
parameters.set_param(
"beesdoo_shift.attendance_sheet_generation_interval",
"beesdoo_shift_attendance.attendance_sheet_generation_interval",
str(self.attendance_sheet_generation_interval),
)
@ -49,12 +51,12 @@ class ResConfigSettings(models.TransientModel):
res.update(
card_support=ast.literal_eval(
self.env["ir.config_parameter"].get_param(
"beesdoo_shift.card_support"
"beesdoo_shift_attendance.card_support"
),
),
task_type_default_id=int(
pre_filled_task_type_id=int(
self.env["ir.config_parameter"].get_param(
"beesdoo_shift.task_type_default_id"
"beesdoo_shift_attendance.pre_filled_task_type_id"
)
),
)

21
beesdoo_shift_attendance/security/group.xml

@ -1,11 +1,14 @@
<odoo>
<record id="group_shift_attendance_sheet" model="res.groups">
<field name="name">Attendance Sheet Generic Access</field>
<field name="category_id"
ref="base.module_category_cooperative_management"/>
</record>
<record id="beesdoo_shift.group_shift_attendance" model="res.groups">
<field name="implied_ids"
eval="[(4, ref('group_shift_attendance_sheet'))]"/>
</record>
<record id="group_shift_attendance_sheet" model="res.groups">
<field name="name">Attendance Sheet Generic Access</field>
<field name="category_id" ref="base.module_category_cooperative_management"/>
</record>
<record id="group_shift_attendance_sheet_validation" model="res.groups">
<field name="name">Attendance Sheet Validation</field>
<field name="category_id" ref="base.module_category_cooperative_management"/>
<field name="implied_ids" eval="[(4, ref('group_shift_attendance_sheet'))]"/>
</record>
<record id="beesdoo_shift.group_shift_attendance" model="res.groups">
<field name="implied_ids" eval="[(4, ref('group_shift_attendance_sheet'))]"/>
</record>
</odoo>

12
beesdoo_shift_attendance/security/ir.model.access.csv

@ -1,12 +1,12 @@
id,name,model_id/id,group_id/id,perm_read,perm_write,perm_create,perm_unlink
create_beesdoo_shift_shift,create_edit_beesdoo_shift_shift,model_beesdoo_shift_shift,group_shift_attendance_sheet,1,1,1,0
create_beesdoo_shift_shift,create_edit_beesdoo_shift_shift,beesdoo_shift.model_beesdoo_shift_shift,group_shift_attendance_sheet,1,1,1,0
read_beesdoo_shift_sheet_shift,read_beesdoo_shift_sheet_shift,model_beesdoo_shift_sheet_shift,group_shift_attendance_sheet,1,0,0,0
create_beesdoo_shift_sheet_shift,create_beesdoo_shift_sheet_shift,model_beesdoo_shift_sheet_shift,group_shift_attendance_sheet,1,1,1,0
create_beesdoo_shift_sheet_expected,create_beesdoo_shift_sheet_expected,model_beesdoo_shift_sheet_expected,group_shift_attendance_sheet,1,1,1,0
manage_beesdoo_shift_sheet_added,manage_beesdoo_shift_sheet_added,model_beesdoo_shift_sheet_added,group_shift_attendance_sheet,1,1,1,1
create_beesdoo_shift_sheet,create_beesdoo_shift_sheet,model_beesdoo_shift_sheet,group_shift_attendance_sheet,1,1,1,0
sheet_access_beesdoo_shift_template,sheet_access_beesdoo_shift_template,model_beesdoo_shift_template,group_shift_attendance_sheet,1,0,0,0
sheet_access_beesdoo_shift_type,sheet_access_beesdoo_shift_type,model_beesdoo_shift_type,group_shift_attendance_sheet,1,0,0,0
access_beesdoo_shift_daynumber,access_beesdoo_shift_daynumber,model_beesdoo_shift_daynumber,group_shift_attendance_sheet,1,0,0,0
manage_beesdoo_shift_sheet_shift,beesdoo_shift_sheet_shift,model_beesdoo_shift_sheet_shift,group_shift_attendance,1,1,1,1
manage_beesdoo_shift_sheet_expected,manage_beesdoo_shift_sheet_expected,model_beesdoo_shift_sheet_expected,group_shift_attendance,1,1,1,1
sheet_access_beesdoo_shift_template,sheet_access_beesdoo_shift_template,beesdoo_shift.model_beesdoo_shift_template,group_shift_attendance_sheet,1,0,0,0
sheet_access_beesdoo_shift_type,sheet_access_beesdoo_shift_type,beesdoo_shift.model_beesdoo_shift_type,group_shift_attendance_sheet,1,0,0,0
access_beesdoo_shift_daynumber,access_beesdoo_shift_daynumber,beesdoo_shift.model_beesdoo_shift_daynumber,group_shift_attendance_sheet,1,0,0,0
manage_beesdoo_shift_sheet_shift,beesdoo_shift_sheet_shift,model_beesdoo_shift_sheet_shift,beesdoo_shift.group_shift_attendance,1,1,1,1
manage_beesdoo_shift_sheet_expected,manage_beesdoo_shift_sheet_expected,model_beesdoo_shift_sheet_expected,beesdoo_shift.group_shift_attendance,1,1,1,1

20
beesdoo_shift_attendance/tests/test_beesdoo_shift.py

@ -27,10 +27,10 @@ class TestBeesdooShift(TransactionCase):
self.current_time = datetime.now()
self.user_admin = self.env.ref("base.user_root")
self.user_generic = self.env.ref(
"beesdoo_base.beesdoo_shift_user_1_demo"
"beesdoo_shift_attendance.beesdoo_shift_user_1_demo"
)
self.user_permanent = self.env.ref(
"beesdoo_base.beesdoo_shift_user_2_demo"
"beesdoo_shift_attendance.beesdoo_shift_user_2_demo"
)
self.setting_wizard = self.env["res.config.settings"].sudo(
@ -38,22 +38,22 @@ class TestBeesdooShift(TransactionCase):
)
self.worker_regular_1 = self.env.ref(
"beesdoo_base.res_partner_cooperator_6_demo"
"beesdoo_shift.res_partner_cooperator_6_demo"
)
self.worker_regular_2 = self.env.ref(
"beesdoo_base.res_partner_cooperator_5_demo"
"beesdoo_shift.res_partner_cooperator_5_demo"
)
self.worker_regular_3 = self.env.ref(
"beesdoo_base.res_partner_cooperator_3_demo"
"beesdoo_shift.res_partner_cooperator_3_demo"
)
self.worker_regular_super_1 = self.env.ref(
"beesdoo_base.res_partner_cooperator_1_demo"
"beesdoo_shift.res_partner_cooperator_1_demo"
)
self.worker_irregular_1 = self.env.ref(
"beesdoo_base.res_partner_cooperator_2_demo"
"beesdoo_shift.res_partner_cooperator_2_demo"
)
self.worker_irregular_2 = self.env.ref(
"beesdoo_base.res_partner_cooperator_4_demo"
"beesdoo_shift.res_partner_cooperator_4_demo"
)
self.task_type_1 = self.env.ref(
@ -116,7 +116,7 @@ class TestBeesdooShift(TransactionCase):
"replaced_id": self.worker_regular_2.id,
}
)
future_shift_regular = self.shift_model.create(
self.future_shift_regular = self.shift_model.create(
{
"task_template_id": self.task_template_2.id,
"task_type_id": self.task_type_1.id,
@ -388,4 +388,4 @@ class TestBeesdooShift(TransactionCase):
sheet_1.added_shift_ids[0].task_id, self.shift_empty_1
)
# sheet_1.expected_shift_ids[0].worker_id
# sheet_1.expected_shift_ids[0].worker_id

4
beesdoo_shift_attendance/views/attendance_sheet.xml

@ -230,8 +230,8 @@
<!-- Top menu item -->
<menuitem id="menu_sheet_top"
name="Attendance Sheets"
parent="menu_root"
groups="beesdoo_shift.group_shift_attendance_sheet"
parent="beesdoo_shift.menu_root"
groups="beesdoo_shift_attendance.group_shift_attendance_sheet"
sequence="1"
/>

2
beesdoo_shift_attendance/views/res_config_settings_view.xml

@ -91,7 +91,7 @@
<menuitem name="Configuration"
id="menu_configuration_top"
parent="menu_root"
parent="beesdoo_shift.menu_root"
groups="beesdoo_shift.group_planning_management"
sequence="21"
/>

4
beesdoo_shift_attendance/wizard/validate_attendance_sheet.py

@ -22,7 +22,7 @@ class ValidateAttendanceSheet(models.TransientModel):
def _get_card_support_setting(self):
return ast.literal_eval(
self.env["ir.config_parameter"].sudo().get_param(
"beesdoo_shift.card_support"
"beesdoo_shift_attendance.card_support"
)
)
@ -119,7 +119,7 @@ class ValidateAttendanceSheet(models.TransientModel):
partner = user.partner_id
can_validate = partner.user_ids.has_group(
"beesdoo_shift.group_shift_attendance_sheet_validation"
"beesdoo_shift_attendance.group_shift_attendance_sheet_validation"
)
if not partner.super and not can_validate:

Loading…
Cancel
Save