Browse Source

[ADD] b_shift : default task type configuration

pull/143/head
Elouan Le Bars 5 years ago
parent
commit
aec6d12a02
  1. 1
      beesdoo_shift/__openerp__.py
  2. 8
      beesdoo_shift/data/system_parameter.xml
  3. 1
      beesdoo_shift/models/__init__.py
  4. 9
      beesdoo_shift/models/attendance_sheet.py
  5. 34
      beesdoo_shift/models/res_config.py
  6. 1
      beesdoo_shift/security/ir.model.access.csv

1
beesdoo_shift/__openerp__.py

@ -24,6 +24,7 @@
"security/group.xml", "security/group.xml",
"security/ir.model.access.csv", "security/ir.model.access.csv",
"views/task_template.xml", "views/task_template.xml",
"views/res_config_view.xml",
"views/task.xml", "views/task.xml",
"views/planning.xml", "views/planning.xml",
"views/cooperative_status.xml", "views/cooperative_status.xml",

8
beesdoo_shift/data/system_parameter.xml

@ -31,4 +31,12 @@
<field name="key">regular_counter_to_unsubscribe</field> <field name="key">regular_counter_to_unsubscribe</field>
<field name="value">-4</field> <field name="value">-4</field>
</record> </record>
<record id="beesdoo_shift.attendance_sheet_generation_interval" model="ir.config_parameter">
<field name="key">beesdoo_shift.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>
<field name="value">1</field>
</record>
</odoo> </odoo>

1
beesdoo_shift/models/__init__.py

@ -1,5 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import attendance_sheet import attendance_sheet
import planning import planning
import res_config
import task import task
import cooperative_status import cooperative_status

9
beesdoo_shift/models/attendance_sheet.py

@ -13,6 +13,13 @@ class AttendanceSheetShift(models.Model):
_name = "beesdoo.shift.sheet.shift" _name = "beesdoo.shift.sheet.shift"
_description = "Copy of an actual shift into an attendance sheet" _description = "Copy of an actual shift into an attendance sheet"
@api.model
def _default_task_type_id(self):
parameters = self.env['ir.config_parameter']
id = int(parameters.get_param('beesdoo_shift.default_task_type_id'))
task_types = self.env["beesdoo.shift.type"]
return task_types.browse(id)
# Related actual shift, not required because doesn't exist for added shift before validation # Related actual shift, not required because doesn't exist for added shift before validation
# To update after validation # To update after validation
task_id = fields.Many2one("beesdoo.shift.shift", string="Task") task_id = fields.Many2one("beesdoo.shift.shift", string="Task")
@ -42,7 +49,7 @@ class AttendanceSheetShift(models.Model):
], ],
required=True, required=True,
) )
task_type_id = fields.Many2one("beesdoo.shift.type", string="Task Type")
task_type_id = fields.Many2one("beesdoo.shift.type", string="Task Type", default=_default_task_type_id)
working_mode = fields.Selection( working_mode = fields.Selection(
related="worker_id.working_mode", string="Working Mode", store=True related="worker_id.working_mode", string="Working Mode", store=True
) )

34
beesdoo_shift/models/res_config.py

@ -0,0 +1,34 @@
# -*- coding: utf-8 -*-
# Copyright 2019-2020 Elouan Le Bars <elouan@coopiteasy.be>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from openerp import fields, models, api
class ShiftConfigSettings(models.TransientModel):
_name = "beesdoo.shift.config.settings"
_inherit = "res.config.settings"
default_task_type_id = fields.Many2one(
"beesdoo.shift.type",
string="Default Task Type",
help="Default task type for shifts added on an attendance sheet.",
)
@api.multi
def set_params(self):
self.ensure_one()
value = self.default_task_type_id.id
parameters = self.env["ir.config_parameter"]
parameters.set_param("beesdoo_shift.default_task_type_id", value)
@api.multi
def get_default_task_type_id(self):
return {
"default_task_type_id": int(
self.env["ir.config_parameter"].get_param(
"beesdoo_shift.default_task_type_id"
)
)
}

1
beesdoo_shift/security/ir.model.access.csv

@ -18,6 +18,7 @@ access_coopplanning_task_full,Shift Management all Shift,model_beesdoo_shift_shi
admin_access_attendance_sheet,Attendance Sheet Shift Read Abstract,model_beesdoo_shift_sheet_shift,group_cooperative_admin,1,1,1,1 admin_access_attendance_sheet,Attendance Sheet Shift Read Abstract,model_beesdoo_shift_sheet_shift,group_cooperative_admin,1,1,1,1
admin_access_attendance_sheet_expected,Attendance Sheet Shift Read Expected,model_beesdoo_shift_sheet_expected,group_cooperative_admin,1,1,1,1 admin_access_attendance_sheet_expected,Attendance Sheet Shift Read Expected,model_beesdoo_shift_sheet_expected,group_cooperative_admin,1,1,1,1
access_coop_status,Coop Status Read for all,model_cooperative_status,,1,0,0,0 access_coop_status,Coop Status Read for all,model_cooperative_status,,1,0,0,0
access_coop_status_all,Coop Status Admin,model_cooperative_status,group_cooperative_admin,1,1,1,1 access_coop_status_all,Coop Status Admin,model_cooperative_status,group_cooperative_admin,1,1,1,1
all_config_coopplanning_task_type,Attendance Read Type,model_beesdoo_shift_type,group_planning_management,1,1,1,1 all_config_coopplanning_task_type,Attendance Read Type,model_beesdoo_shift_type,group_planning_management,1,1,1,1

Loading…
Cancel
Save