Browse Source
[ADD] website_shift: Add configuration
[ADD] website_shift: Add configuration
irregular_shift_limit: Maximum shift that will be shown highlight_rule: Treshold of available space in a shift that trigger the highlight of the shift hide_rule: Treshold ((available space)/(max space)) in percentage of available space under wich the shift is hidden The last one replaces the old hide filter.pull/33/head
Rémy Taymans
7 years ago
8 changed files with 151 additions and 17 deletions
-
1beesdoo_website_shift/__init__.py
-
2beesdoo_website_shift/__openerp__.py
-
28beesdoo_website_shift/controllers/main.py
-
17beesdoo_website_shift/data/res_config_data.xml
-
1beesdoo_website_shift/models/__init__.py
-
51beesdoo_website_shift/models/res_config.py
-
52beesdoo_website_shift/views/res_config_views.xml
-
16beesdoo_website_shift/views/shift_website_templates.xml
@ -1 +1,2 @@ |
|||||
from . import controllers |
from . import controllers |
||||
|
from . import models |
@ -0,0 +1,17 @@ |
|||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||
|
<openerp> |
||||
|
<data noupdate="1"> |
||||
|
<record id="beesdoo_website_shift.irregular_shift_limit" model="ir.config_parameter"> |
||||
|
<field name="key">beesdoo_website_shift.irregular_shift_limit</field> |
||||
|
<field name="value">0</field> |
||||
|
</record> |
||||
|
<record id="beesdoo_website_shift.highlight_rule" model="ir.config_parameter"> |
||||
|
<field name="key">beesdoo_website_shift.highlight_rule</field> |
||||
|
<field name="value">3</field> |
||||
|
</record> |
||||
|
<record id="beesdoo_website_shift.hide_rule" model="ir.config_parameter"> |
||||
|
<field name="key">beesdoo_website_shift.hide_rule</field> |
||||
|
<field name="value">20</field> |
||||
|
</record> |
||||
|
</data> |
||||
|
</openerp> |
@ -0,0 +1 @@ |
|||||
|
from . import res_config |
@ -0,0 +1,51 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
|
||||
|
from openerp import fields, models, api |
||||
|
|
||||
|
PARAMS = [ |
||||
|
('irregular_shift_limit', 'beesdoo_website_shift.irregular_shift_limit'), |
||||
|
('highlight_rule', 'beesdoo_website_shift.highlight_rule'), |
||||
|
('hide_rule', 'beesdoo_website_shift.hide_rule'), |
||||
|
] |
||||
|
|
||||
|
class WebsiteShiftConfigSettings(models.TransientModel): |
||||
|
|
||||
|
_name = 'beesdoo.website.shift.config.settings' |
||||
|
_inherit = 'res.config.settings' |
||||
|
|
||||
|
irregular_shift_limit = fields.Integer( |
||||
|
help="Maximum shift that will be shown" |
||||
|
) |
||||
|
highlight_rule = fields.Integer( |
||||
|
help="Treshold of available space in a shift that trigger the highlight of the shift" |
||||
|
) |
||||
|
hide_rule = fields.Integer( |
||||
|
help="Treshold ((available space)/(max space)) in percentage of available space under wich the shift is hidden" |
||||
|
) |
||||
|
|
||||
|
@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(self): |
||||
|
return { |
||||
|
'highlight_rule': int(self.env['ir.config_parameter'].get_param('beesdoo_website_shift.highlight_rule')) |
||||
|
} |
||||
|
|
||||
|
@api.multi |
||||
|
def get_default_hide_rule(self): |
||||
|
return { |
||||
|
'hide_rule': int(self.env['ir.config_parameter'].get_param('beesdoo_website_shift.hide_rule')) |
||||
|
} |
@ -0,0 +1,52 @@ |
|||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||
|
<openerp> |
||||
|
<data> |
||||
|
|
||||
|
<record id="view_website_shift_config_irregular" model="ir.ui.view"> |
||||
|
<field name="name">Website Shift Settings</field> |
||||
|
<field name="model">beesdoo.website.shift.config.settings</field> |
||||
|
<field name="arch" type="xml"> |
||||
|
<form string="Configure Website Shift" class="oe_form_configuration"> |
||||
|
<header> |
||||
|
<button string="Apply" type="object" name="execute" class="oe_highlight"/> |
||||
|
<button string="Cancel" type="object" name="cancel" class="oe_link" special="cancel"/> |
||||
|
</header> |
||||
|
<div> |
||||
|
<label for="irregular_shift_limit"/> |
||||
|
<field name="irregular_shift_limit"/> |
||||
|
</div> |
||||
|
<div> |
||||
|
<label for="highlight_rule"/> |
||||
|
<field name="highlight_rule"/> |
||||
|
</div> |
||||
|
<div> |
||||
|
<label for="hide_rule"/> |
||||
|
<field name="hide_rule"/> |
||||
|
</div> |
||||
|
</form> |
||||
|
</field> |
||||
|
</record> |
||||
|
|
||||
|
<record id="action_website_shift_configuration" model="ir.actions.act_window"> |
||||
|
<field name="name">Website Shift Settings</field> |
||||
|
<field name="res_model">beesdoo.website.shift.config.settings</field> |
||||
|
<field name="view_id" ref="view_website_shift_config_irregular"/> |
||||
|
<field name="view_mode">form</field> |
||||
|
<field name="target">inline</field> |
||||
|
</record> |
||||
|
|
||||
|
<menuitem |
||||
|
id="menu_website_shift_root" |
||||
|
name="Shift" |
||||
|
parent="website.menu_website_configuration" |
||||
|
sequence="20"/> |
||||
|
|
||||
|
<menuitem |
||||
|
id="menu_website_shift_irregular" |
||||
|
name="Irregular Shift" |
||||
|
action="action_website_shift_configuration" |
||||
|
parent="menu_website_shift_root" |
||||
|
sequence="1"/> |
||||
|
|
||||
|
</data> |
||||
|
</openerp> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue