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
-
1399beesdoo_website_shift/views/my_shift_website_templates.xml
-
180beesdoo_website_shift/views/res_config_views.xml
-
319beesdoo_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." |
|||
related='website_id.regular_highlight_rule', |
|||
readonly=False, |
|||
) |
|||
|
|||
@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') |
|||
) |
|||
} |
@ -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." |
|||
) |
1399
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
@ -1,211 +1,158 @@ |
|||
<?xml version="1.0" encoding="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). |
|||
--> |
|||
<odoo> |
|||
|
|||
<!-- Add menu entries --> |
|||
<data noupdate="1"> |
|||
<record id="menu_work_irregular" model="website.menu"> |
|||
<field name="name">Shifts Irregular</field> |
|||
<field name="url">/shift_irregular_worker</field> |
|||
<field name="parent_id" ref="website.main_menu"/> |
|||
<field name="sequence">50</field> |
|||
</record> |
|||
<record id="menu_work_regular" model="website.menu"> |
|||
<field name="name">Shifts Regular</field> |
|||
<field name="url">/shift_template_regular_worker</field> |
|||
<field name="parent_id" ref="website.main_menu"/> |
|||
<field name="sequence">51</field> |
|||
</record> |
|||
</data> |
|||
|
|||
<template |
|||
id="public_shift_template_regular_worker" |
|||
name="Available Tasks Templates for Regular Workers" |
|||
<!-- Add menu entries --> |
|||
<data noupdate="1"> |
|||
<record id="menu_work_irregular" model="website.menu"> |
|||
<field name="name">Shifts Irregular</field> |
|||
<field name="url">/shift_irregular_worker</field> |
|||
<field name="parent_id" ref="website.main_menu"/> |
|||
<field name="sequence">50</field> |
|||
</record> |
|||
<record id="menu_work_regular" model="website.menu"> |
|||
<field name="name">Shifts Regular</field> |
|||
<field name="url">/shift_template_regular_worker</field> |
|||
<field name="parent_id" ref="website.main_menu"/> |
|||
<field name="sequence">51</field> |
|||
</record> |
|||
</data> |
|||
|
|||
|
|||
<!-- Help texts --> |
|||
<template |
|||
id="help_text_public_shift_template_regular_worker" |
|||
name="Help text for public available shifts template for irregular worker" |
|||
> |
|||
<t t-call="website.layout"> |
|||
<p class="text-center"> |
|||
Help text or information text. |
|||
</p> |
|||
</template> |
|||
|
|||
<div class="oe_structure"/> |
|||
|
|||
<section class="wrap"> |
|||
<div class="container"> |
|||
<div class="row"> |
|||
<div class="col-md-12"> |
|||
<h1 class="text-center"> |
|||
Available Tasks Templates for Regular Workers |
|||
</h1> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
</section> |
|||
|
|||
<div class="oe_structure"/> |
|||
|
|||
<section class="wrap"> |
|||
<div class="container"> |
|||
<div class="row"> |
|||
<div class="col-md-12"> |
|||
<p class="text-center"> |
|||
Subscribe via the member office or via |
|||
<a href="mailto:membre@bees-coop.be">membre@bees-coop.be</a> |
|||
</p> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
</section> |
|||
|
|||
<section class="wrap"> |
|||
<div class="container"> |
|||
<div class="row"> |
|||
<div class="col-md-12"> |
|||
|
|||
<div class="oe_structure"/> |
|||
|
|||
<div class="visible-xs" t-foreach="task_tpls_data" t-as="template_data"> |
|||
<t t-set="template" t-value="template_data[0]"/> |
|||
<t t-set="has_enough_workers" t-value="template_data[1]"/> |
|||
<t t-set="highlight_class" t-value="'panel-warning' if not has_enough_workers else 'panel-default'"/> |
|||
<div t-att-class="'panel %s' % highlight_class"> |
|||
<div class="panel-heading clearfix"> |
|||
<div class="panel-title pull-left"> |
|||
<t t-esc="template.planning_id.name"/> : |
|||
<t t-esc="template.day_nb_id.name"/> |
|||
<t t-esc='float_to_time(template.start_time)' /> - |
|||
<t t-esc='float_to_time(template.end_time)'/> |
|||
</div> |
|||
<div class="label label-default pull-right" |
|||
t-if="template.remaining_worker > 0"> |
|||
<t t-esc="template.remaining_worker"/> space(s) |
|||
</div> |
|||
<div class="label label-default pull-right" |
|||
t-if="template.remaining_worker == 0"> |
|||
full |
|||
<template |
|||
id="help_text_public_shift_irregular_worker" |
|||
name="Help text for public Available Shifts for Irregular Worker" |
|||
> |
|||
<p class="text-center"> |
|||
Help text or information text. |
|||
</p> |
|||
</template> |
|||
|
|||
|
|||
<!-- Public Available Tasks Templates for Regular Workers --> |
|||
<template |
|||
id="public_shift_template_regular_worker" |
|||
name="Available Tasks Templates for Regular Workers" |
|||
> |
|||
<t t-call="portal.portal_layout"> |
|||
|
|||
<div class="o_regular_shift_template"> |
|||
|
|||
<div class="container mt32"> |
|||
<div class="row mt4"> |
|||
<div class="col"> |
|||
<h1 class="text-center"> |
|||
Available Tasks Templates for Regular Workers |
|||
</h1> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
<div class="panel-body clearfix"> |
|||
<t t-esc="template.task_type_id.name"/> |
|||
<div class="label label-warning pull-right" |
|||
t-if="not template.super_coop_id"> |
|||
Need Super Co-operator |
|||
|
|||
<div class="row mt4"> |
|||
<div class="col"> |
|||
<t t-call="beesdoo_website_shift.help_text_public_shift_template_regular_worker"/> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
|
|||
<table class="hidden-xs table table-striped"> |
|||
<thead> |
|||
<tr> |
|||
<th>Week</th> |
|||
<th>Day</th> |
|||
<th>Time</th> |
|||
<th>Type of Task</th> |
|||
<th>Super Co-operator</th> |
|||
<th class="text-center">Available Spaces</th> |
|||
</tr> |
|||
</thead> |
|||
<tbody> |
|||
<t t-foreach="task_tpls_data" t-as="template_data"> |
|||
<t t-set="template" t-value="template_data[0]"/> |
|||
<t t-set="has_enough_workers" t-value="template_data[1]"/> |
|||
<!-- Row with no super coop will be shown in color --> |
|||
<tr t-attf-class="{{ 'warning' if not has_enough_workers else '' }}"> |
|||
<td> |
|||
<t t-esc="template.planning_id.name"/> |
|||
</td> |
|||
<td> |
|||
<t t-esc="template.day_nb_id.name"/> |
|||
</td> |
|||
<td> |
|||
<t t-esc='float_to_time(template.start_time)' /> - |
|||
<t t-esc='float_to_time(template.end_time)'/> |
|||
</td> |
|||
<td> |
|||
<t t-esc="template.task_type_id.name"/> |
|||
</td> |
|||
<td> |
|||
<t t-if="template.super_coop_id"> |
|||
Yes |
|||
</t> |
|||
<t t-if="not template.super_coop_id"> |
|||
Not yet |
|||
</t> |
|||
</td> |
|||
<td class="text-center"> |
|||
<t t-esc="template.remaining_worker"/> |
|||
</td> |
|||
</tr> |
|||
</t> |
|||
</tbody> |
|||
</table> |
|||
|
|||
</div> <!-- col-md --> |
|||
</div> <!-- row --> |
|||
</div> <!-- container --> |
|||
</section> |
|||
|
|||
<div class="oe_structure"/> |
|||
|
|||
</t> |
|||
</template> |
|||
|
|||
|
|||
<!-- Public Available Shifts for Irregular Workers --> |
|||
<template |
|||
id="public_shift_irregular_worker" |
|||
name="Available Shifts for Irregular Workers" |
|||
> |
|||
<t t-call="website.layout"> |
|||
|
|||
<div class="oe_structure"/> |
|||
<div class="container mb64"> |
|||
<div class="row mt4 justify-content-center"> |
|||
<div class="col-12 col-lg-6"> |
|||
|
|||
<t t-foreach="task_tpls_data" t-as="template_data"> |
|||
<t t-set="template" t-value="template_data[0]"/> |
|||
<t t-set="has_enough_workers" t-value="template_data[1]"/> |
|||
<t t-set="highlight_header_class" t-value="'bg-warning' if not has_enough_workers else ''"/> |
|||
<t t-set="highlight_class" t-value="'border-warning' if not has_enough_workers else ''"/> |
|||
<div t-att-class="'card mt-4 %s' % highlight_class"> |
|||
<div t-att-class="'card-header %s clearfix' % highlight_header_class"> |
|||
<div class="pull-left"> |
|||
<t t-esc="template.planning_id.name"/> : |
|||
<t t-esc="template.day_nb_id.name"/> |
|||
<t t-esc='float_to_time(template.start_time)' /> - |
|||
<t t-esc='float_to_time(template.end_time)'/> |
|||
</div> |
|||
<div class="badge badge-secondary pull-right" |
|||
t-if="template.remaining_worker > 0"> |
|||
<t t-esc="template.remaining_worker"/> space(s) |
|||
</div> |
|||
<div class="badge badge-secondary pull-right" |
|||
t-if="template.remaining_worker == 0"> |
|||
full |
|||
</div> |
|||
</div> |
|||
<div class="card-body clearfix"> |
|||
<t t-esc="template.task_type_id.name"/> |
|||
<div class="badge badge-warning pull-right" |
|||
t-if="not template.super_coop_id"> |
|||
Need Super Co-operator |
|||
</div> |
|||
</div> |
|||
</div> |
|||
</t> |
|||
|
|||
</div> |
|||
</div> |
|||
</div> |
|||
|
|||
<section class="wrap"> |
|||
<div class="container"> |
|||
<div class="row"> |
|||
<div class="col-md-12"> |
|||
<h1 class="text-center"> |
|||
Available Shifts for Irregular Workers |
|||
</h1> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
</section> |
|||
|
|||
<div class="oe_structure"/> |
|||
|
|||
<section class="wrap"> |
|||
<div class="container"> |
|||
<div class="row"> |
|||
<div class="col-md-12"> |
|||
<p class="text-center"> |
|||
Subscribe via <a href="mailto:volant@bees-coop.be">volant@bees-coop.be</a> |
|||
</p> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
</section> |
|||
|
|||
<div class="oe_structure"/> |
|||
</t> |
|||
</template> |
|||
|
|||
|
|||
<section class="wrap"> |
|||
<div class="container"> |
|||
<div class="row"> |
|||
<div class="col-md-12"> |
|||
<!-- Public Available Shifts for Irregular Workers --> |
|||
<template |
|||
id="public_shift_irregular_worker" |
|||
name="Available Shifts for Irregular Workers" |
|||
> |
|||
<t t-call="portal.portal_layout"> |
|||
<t t-set="no_breadcrumbs" t-value="True"/> |
|||
|
|||
<div class="o_regular_shift_template"> |
|||
|
|||
<div class="container mt32"> |
|||
<div class="row mt4"> |
|||
<div class="col"> |
|||
<h1 class="text-center"> |
|||
Available Shifts for Irregular Workers |
|||
</h1> |
|||
</div> |
|||
</div> |
|||
|
|||
<t t-call="beesdoo_website_shift.available_shift_irregular_worker"/> |
|||
<div class="row mt4"> |
|||
<div class="col"> |
|||
<t t-call="beesdoo_website_shift.help_text_public_shift_irregular_worker "/> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
|
|||
</div> <!-- col-md --> |
|||
</div> <!-- row --> |
|||
</div> <!-- container --> |
|||
</section> |
|||
<div class="container mb64"> |
|||
<div class="row mt4 justify-content-center"> |
|||
<div class="col-12 col-lg-6"> |
|||
|
|||
<div class="oe_structure"/> |
|||
<t t-call="beesdoo_website_shift.available_shift_irregular_worker"/> |
|||
|
|||
</t> |
|||
</template> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
|
|||
</div> |
|||
|
|||
|
|||
</t> |
|||
</template> |
|||
|
|||
</odoo> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue