diff --git a/web_sheet_width_custom/README.rst b/web_sheet_width_custom/README.rst new file mode 100644 index 0000000..ac6deff --- /dev/null +++ b/web_sheet_width_custom/README.rst @@ -0,0 +1,90 @@ + +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 + +====================== +Web Sheet Width Custom +====================== + +This module adds a css class to change a Form Sheet view +to cover the full screen. + +You can apply this css class either in the arch xml view +either by configuration in the view form. + + +Configuration +============= + +To configure this module, you need to: + +#. Apply 'Technical Features' rights to your user + +#. Go to the form view of your choice with the menu + (Settings > Technical > User Interface > Views) + +#. Apply a value in the 'Form Width' field. + +.. figure:: web_sheet_width_custom/static/description/img1.png + :alt: Set full width + :width: 600 px + +| + +Alternative way is to define the css class directly in your view. + +You can activate the Full Screen view by the creation of an +inherited view with the following content: +:: + + + oe_form_sheet_full_screen + + + +Install the 'web_sheet_full_width' module if you want to have a full screen +behaviour in all sheets. + + +Usage +===== + +To use this module, you need to configure the form view of your choice +as explained above. + + + +Known issues / Roadmap +====================== + +* add other css styles to have more choice on width. + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues +`_. In case of trouble, please +check there if your issue has already been reported. If you spotted it first, +help us smashing it by providing a detailed and welcomed feedback. + +Credits +======= + +Images +------ + +Icon courtesy of http://www.picol.org/ (size_width.svg) + + +Contributors +------------ + +* David Béal + + +Idea +---- + +Idea comes from module web_sheet_full_width (Luc De Meyer) + diff --git a/web_sheet_width_custom/__init__.py b/web_sheet_width_custom/__init__.py new file mode 100755 index 0000000..0650744 --- /dev/null +++ b/web_sheet_width_custom/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/web_sheet_width_custom/__openerp__.py b/web_sheet_width_custom/__openerp__.py new file mode 100755 index 0000000..05a6c02 --- /dev/null +++ b/web_sheet_width_custom/__openerp__.py @@ -0,0 +1,20 @@ +# coding: utf-8 +# © 2016 David BEAL @ Akretion +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +{ + 'name': 'Web Sheet width Custom', + 'summary': 'Choose a dedicated width for your form view', + 'version': '8.0.1.0.0', + 'license': 'AGPL-3', + 'author': 'Akretion', + 'category': 'web', + 'depends': [ + 'web', + ], + 'data': [ + 'views/sheet.xml', + 'views/ui_view.xml', + ], + 'installable': True, + } diff --git a/web_sheet_width_custom/models/__init__.py b/web_sheet_width_custom/models/__init__.py new file mode 100755 index 0000000..9186ee3 --- /dev/null +++ b/web_sheet_width_custom/models/__init__.py @@ -0,0 +1 @@ +from . import model diff --git a/web_sheet_width_custom/models/model.py b/web_sheet_width_custom/models/model.py new file mode 100644 index 0000000..1ff97c9 --- /dev/null +++ b/web_sheet_width_custom/models/model.py @@ -0,0 +1,73 @@ +# coding: utf-8 +# © 2016 David BEAL @ Akretion +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from lxml import etree + +from openerp import models, api, fields +from openerp.osv import orm +from openerp import SUPERUSER_ID + + +class IrUiView(models.Model): + _inherit = 'ir.ui.view' + + def _get_form_width(self): + return [('oe_form_sheet_full_screen', 'Full Screen'), ] + + form_width = fields.Selection( + string='Form Width', selection='_get_form_width', + help="Allow to set the form view to the max width " + "to have a better usability on data entry") + + +class ModelExtended(models.Model): + _inherit = 'ir.model' + + def _css_class_to_apply(self, node, css_class): + """ Complete class if exist """ + existing_class = [ + x[1] for x in node.items() + if x[0] == 'class'] + if existing_class: + css_class = '%s %s' % ( + css_class, existing_class[0]) + return css_class + + def _register_hook(self, cr, ids=None): + + def make_fields_view_get(): + + @api.model + def fields_view_get(self, view_id=None, view_type='form', + toolbar=False, submenu=False): + # Perform standard fields_view_get + res = fields_view_get.origin( + self, view_id=view_id, view_type=view_type, + toolbar=toolbar, submenu=submenu) + # customize xml output + if view_type == 'form' and res.get('view_id'): + view = self.env['ir.ui.view'].browse(res.get('view_id')) + if view.form_width: + model_m = self.env['ir.model'] + doc = etree.XML(res['arch']) + node = doc.xpath('//sheet') + if node: + css_class = view.form_width + for current_node in node: + new_css = model_m._css_class_to_apply( + current_node, css_class) + current_node.set('class', new_css) + orm.setup_modifiers(current_node) + res['arch'] = etree.tostring(doc, pretty_print=True) + return res + + return fields_view_get + + if ids is None: + ids = self.search(cr, SUPERUSER_ID, []) + for model in self.browse(cr, SUPERUSER_ID, ids): + Model = self.pool.get(model.model) + if Model: + Model._patch_method('fields_view_get', make_fields_view_get()) + return super(ModelExtended, self)._register_hook(cr) diff --git a/web_sheet_width_custom/static/description/icon.png b/web_sheet_width_custom/static/description/icon.png new file mode 100755 index 0000000..18295d8 Binary files /dev/null and b/web_sheet_width_custom/static/description/icon.png differ diff --git a/web_sheet_width_custom/static/description/img1.png b/web_sheet_width_custom/static/description/img1.png new file mode 100644 index 0000000..2c5afe8 Binary files /dev/null and b/web_sheet_width_custom/static/description/img1.png differ diff --git a/web_sheet_width_custom/static/src/css/sheet.css b/web_sheet_width_custom/static/src/css/sheet.css new file mode 100755 index 0000000..50027d5 --- /dev/null +++ b/web_sheet_width_custom/static/src/css/sheet.css @@ -0,0 +1,4 @@ +.openerp .oe_form_sheet_full_screen { + max-width: none; + margin: 0 auto; +} diff --git a/web_sheet_width_custom/views/sheet.xml b/web_sheet_width_custom/views/sheet.xml new file mode 100755 index 0000000..b0c2ca7 --- /dev/null +++ b/web_sheet_width_custom/views/sheet.xml @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/web_sheet_width_custom/views/ui_view.xml b/web_sheet_width_custom/views/ui_view.xml new file mode 100644 index 0000000..aa2e6f4 --- /dev/null +++ b/web_sheet_width_custom/views/ui_view.xml @@ -0,0 +1,17 @@ + + + + + + ir.ui.view + + + + + + + + + +