Compare commits
2 Commits
8.0
...
8-sheet-wi
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0ba12b8812 | ||
|
|
c867b1d76f |
74
web_sheet_width_custom/README.rst
Normal file
74
web_sheet_width_custom/README.rst
Normal file
@@ -0,0 +1,74 @@
|
||||
|
||||
.. 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
|
||||
======================
|
||||
|
||||
Allow to modify form width with a field selection in the form view.
|
||||
|
||||
|
||||
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
|
||||
|
||||
|
||||
|
||||
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
|
||||
<https://github.com/akretion/odoo-usability/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 <david.beal@akretion.com>
|
||||
|
||||
|
||||
Idea
|
||||
----
|
||||
|
||||
Idea comes from module web_sheet_full_width (Luc De Meyer)
|
||||
1
web_sheet_width_custom/__init__.py
Executable file
1
web_sheet_width_custom/__init__.py
Executable file
@@ -0,0 +1 @@
|
||||
from . import models
|
||||
20
web_sheet_width_custom/__openerp__.py
Executable file
20
web_sheet_width_custom/__openerp__.py
Executable file
@@ -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,
|
||||
}
|
||||
1
web_sheet_width_custom/models/__init__.py
Executable file
1
web_sheet_width_custom/models/__init__.py
Executable file
@@ -0,0 +1 @@
|
||||
from . import model
|
||||
73
web_sheet_width_custom/models/model.py
Normal file
73
web_sheet_width_custom/models/model.py
Normal file
@@ -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)
|
||||
BIN
web_sheet_width_custom/static/description/icon.png
Executable file
BIN
web_sheet_width_custom/static/description/icon.png
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 411 B |
BIN
web_sheet_width_custom/static/description/img1.png
Normal file
BIN
web_sheet_width_custom/static/description/img1.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 132 KiB |
4
web_sheet_width_custom/static/src/css/sheet.css
Executable file
4
web_sheet_width_custom/static/src/css/sheet.css
Executable file
@@ -0,0 +1,4 @@
|
||||
.openerp .oe_form_sheet_full_screen {
|
||||
max-width: none;
|
||||
margin: 0 auto;
|
||||
}
|
||||
12
web_sheet_width_custom/views/sheet.xml
Executable file
12
web_sheet_width_custom/views/sheet.xml
Executable file
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<template id="assets_backend" name="form_sheet_full_screen assets" inherit_id="web.assets_backend">
|
||||
<xpath expr="." position="inside">
|
||||
<link rel="stylesheet" href="/web_sheet_width_custom/static/src/css/sheet.css"/>
|
||||
</xpath>
|
||||
</template>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
17
web_sheet_width_custom/views/ui_view.xml
Normal file
17
web_sheet_width_custom/views/ui_view.xml
Normal file
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<record id="view_view_form" model="ir.ui.view">
|
||||
<field name="model">ir.ui.view</field>
|
||||
<field name="inherit_id" ref="base.view_view_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="priority" position="after">
|
||||
<field name="form_width"
|
||||
attrs="{'invisible': [('type', '!=', 'form')]}"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
Reference in New Issue
Block a user