Rémy Taymans
5 years ago
10 changed files with 895 additions and 1320 deletions
-
34beesdoo_website_shift/__manifest__.py
-
67beesdoo_website_shift/controllers/main.py
-
32beesdoo_website_shift/data/res_config_data.xml
-
11beesdoo_website_shift/migrations/9.0.2.1.1/post-migrate.py
-
1beesdoo_website_shift/models/__init__.py
-
125beesdoo_website_shift/models/res_config.py
-
47beesdoo_website_shift/models/website.py
-
593beesdoo_website_shift/views/my_shift_website_templates.xml
-
128beesdoo_website_shift/views/res_config_views.xml
-
183beesdoo_website_shift/views/shift_website_templates.xml
@ -1,11 +0,0 @@ |
|||
# coding: utf-8 |
|||
|
|||
|
|||
def migrate(cr, version): |
|||
"""Create a sequence for beesdoo_website_shift_config_settings.""" |
|||
cr.execute( |
|||
""" |
|||
CREATE SEQUENCE IF NOT EXISTS |
|||
beesdoo_website_shift_config_settings_id_seq |
|||
""" |
|||
) |
@ -1 +1,2 @@ |
|||
from . import website |
|||
from . import res_config |
@ -1,136 +1,45 @@ |
|||
# -*- coding: utf-8 -*- |
|||
|
|||
# Copyright 2017-2018 Rémy Taymans <remytaymans@gmail.com> |
|||
# Copyright 2017-2020 Rémy Taymans <remytaymans@gmail.com> |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
|||
|
|||
from ast import literal_eval |
|||
from odoo import fields, models, api |
|||
|
|||
PARAMS = [ |
|||
('irregular_shift_limit', 'beesdoo_website_shift.irregular_shift_limit'), |
|||
('highlight_rule_pc', 'beesdoo_website_shift.highlight_rule_pc'), |
|||
('hide_rule', 'beesdoo_website_shift.hide_rule'), |
|||
('irregular_enable_sign_up', |
|||
'beesdoo_website_shift.irregular_enable_sign_up'), |
|||
('irregular_past_shift_limit', |
|||
'beesdoo_website_shift.irregular_past_shift_limit'), |
|||
('regular_past_shift_limit', |
|||
'beesdoo_website_shift.regular_past_shift_limit'), |
|||
('regular_next_shift_limit', |
|||
'beesdoo_website_shift.regular_next_shift_limit'), |
|||
('regular_highlight_rule', |
|||
'beesdoo_website_shift.regular_highlight_rule'), |
|||
] |
|||
|
|||
|
|||
class WebsiteShiftConfigSettings(models.TransientModel): |
|||
_name = 'beesdoo.website.shift.config.settings' |
|||
_inherit = 'res.config.settings' |
|||
|
|||
# Irregular worker settings |
|||
irregular_shift_limit = fields.Integer( |
|||
help="Maximum shift that will be shown" |
|||
related='website_id.irregular_shift_limit', |
|||
readonly=False, |
|||
) |
|||
highlight_rule_pc = fields.Integer( |
|||
help="Treshold (in %) of available space in a shift that trigger the " |
|||
"highlight of the shift" |
|||
related='website_id.highlight_rule_pc', |
|||
readonly=False, |
|||
) |
|||
hide_rule = fields.Integer( |
|||
help="Treshold ((available space)/(max space)) in percentage of " |
|||
"available space under wich the shift is hidden" |
|||
related='website_id.highlight_rule_pc', |
|||
readonly=False, |
|||
) |
|||
irregular_enable_sign_up = fields.Boolean( |
|||
help="Enable shift sign up for irregular worker" |
|||
related='website_id.irregular_enable_sign_up', |
|||
readonly=False, |
|||
) |
|||
irregular_past_shift_limit = fields.Integer( |
|||
help="Maximum past shift that will be shown for irregular worker" |
|||
related='website_id.irregular_past_shift_limit', |
|||
readonly=False, |
|||
) |
|||
|
|||
# Regular worker settings |
|||
regular_past_shift_limit = fields.Integer( |
|||
help="Maximum past shift that will be shown for regular worker" |
|||
related='website_id.regular_past_shift_limit', |
|||
readonly=False, |
|||
) |
|||
regular_next_shift_limit = fields.Integer( |
|||
help="Maximun number of next shift that will be shown" |
|||
related='website_id.regular_next_shift_limit', |
|||
readonly=False, |
|||
) |
|||
regular_highlight_rule = fields.Integer( |
|||
help="Treshold (in %) of available space in a shift that trigger the " |
|||
"the highlight of a shift template." |
|||
) |
|||
|
|||
@api.multi |
|||
def set_params(self): |
|||
self.ensure_one() |
|||
|
|||
for field_name, key_name in PARAMS: |
|||
value = getattr(self, field_name) |
|||
self.env['ir.config_parameter'].set_param(key_name, str(value)) |
|||
|
|||
@api.multi |
|||
def get_default_irregular_shift_limit(self): |
|||
return { |
|||
'irregular_shift_limit': int( |
|||
self.env['ir.config_parameter'] |
|||
.get_param("beesdoo_website_shift.irregular_shift_limit") |
|||
) |
|||
} |
|||
|
|||
@api.multi |
|||
def get_default_highlight_rule_pc(self): |
|||
return { |
|||
'highlight_rule_pc': int( |
|||
self.env['ir.config_parameter'] |
|||
.get_param("beesdoo_website_shift.highlight_rule_pc") |
|||
) |
|||
} |
|||
|
|||
@api.multi |
|||
def get_default_hide_rule(self): |
|||
return { |
|||
'hide_rule': int(self.env['ir.config_parameter'].get_param( |
|||
'beesdoo_website_shift.hide_rule')) |
|||
} |
|||
|
|||
@api.multi |
|||
def get_default_irregular_shift_sign_up(self): |
|||
return { |
|||
'irregular_enable_sign_up': |
|||
literal_eval(self.env['ir.config_parameter'].get_param( |
|||
'beesdoo_website_shift.irregular_enable_sign_up')) |
|||
} |
|||
|
|||
@api.multi |
|||
def get_default_irregular_past_shift_limit(self): |
|||
return { |
|||
'irregular_past_shift_limit': int( |
|||
self.env['ir.config_parameter'] |
|||
.get_param("beesdoo_website_shift.irregular_past_shift_limit") |
|||
) |
|||
} |
|||
|
|||
@api.multi |
|||
def get_default_regular_past_shift_limit(self): |
|||
return { |
|||
'regular_past_shift_limit': int( |
|||
self.env['ir.config_parameter'] |
|||
.get_param('beesdoo_website_shift.regular_past_shift_limit') |
|||
) |
|||
} |
|||
|
|||
@api.multi |
|||
def get_default_regular_next_shift_limit(self): |
|||
return { |
|||
'regular_next_shift_limit': int( |
|||
self.env['ir.config_parameter'] |
|||
.get_param('beesdoo_website_shift.regular_next_shift_limit') |
|||
) |
|||
} |
|||
|
|||
@api.multi |
|||
def get_default_regular_highlight_rule(self): |
|||
return { |
|||
'regular_highlight_rule': int( |
|||
self.env['ir.config_parameter'] |
|||
.get_param('beesdoo_website_shift.regular_highlight_rule') |
|||
related='website_id.regular_highlight_rule', |
|||
readonly=False, |
|||
) |
|||
} |
@ -0,0 +1,47 @@ |
|||
# Copyright 2017-2020 Rémy Taymans <remytaymans@gmail.com> |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
|||
|
|||
from odoo import fields, models |
|||
|
|||
|
|||
class Website(models.Model): |
|||
_inherit = 'website' |
|||
|
|||
# Irregular worker settings |
|||
irregular_shift_limit = fields.Integer( |
|||
default=0, |
|||
help="Maximum shift that will be shown" |
|||
) |
|||
highlight_rule_pc = fields.Integer( |
|||
default=30, |
|||
help="Treshold (in %) of available space in a shift that trigger the " |
|||
"highlight of the shift" |
|||
) |
|||
hide_rule = fields.Integer( |
|||
default=20, |
|||
help="Treshold ((available space)/(max space)) in percentage of " |
|||
"available space under wich the shift is hidden" |
|||
) |
|||
irregular_enable_sign_up = fields.Boolean( |
|||
default=True, |
|||
help="Enable shift sign up for irregular worker" |
|||
) |
|||
irregular_past_shift_limit = fields.Integer( |
|||
default=10, |
|||
help="Maximum past shift that will be shown for irregular worker" |
|||
) |
|||
|
|||
# Regular worker settings |
|||
regular_past_shift_limit = fields.Integer( |
|||
default=10, |
|||
help="Maximum past shift that will be shown for regular worker" |
|||
) |
|||
regular_next_shift_limit = fields.Integer( |
|||
default=13, |
|||
help="Maximun number of next shift that will be shown" |
|||
) |
|||
regular_highlight_rule = fields.Integer( |
|||
default=20, |
|||
help="Treshold (in %) of available space in a shift that trigger the " |
|||
"the highlight of a shift template." |
|||
) |
593
beesdoo_website_shift/views/my_shift_website_templates.xml
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
Write
Preview
Loading…
Cancel
Save
Reference in new issue