Browse Source

[FIX] web_dialog_size: Fix usage for non-admins and reduce calls (#954)

This addon had 2 problems after migrating to v11:

1. One call to backend's `ir.config_parameter.get_param` was done for
   each instantiated dialog, while the setting served for the whole
   session equally.
2. That model is now readable only by admin users, so non-admins
   couldn't use the default at all.

Fixed now.
pull/880/head
Jairo Llopis 7 years ago
committed by GitHub
parent
commit
2810ad33f3
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 67
      web_dialog_size/README.rst
  2. 3
      web_dialog_size/__init__.py
  3. 4
      web_dialog_size/__manifest__.py
  4. 1
      web_dialog_size/models/__init__.py
  5. 17
      web_dialog_size/models/ir_config_parameter.py
  6. 3
      web_dialog_size/readme/CONFIGURATION.rst
  7. 14
      web_dialog_size/readme/CONTRIBUTORS.rst
  8. 3
      web_dialog_size/readme/DESCRIPTION.rst
  9. 15
      web_dialog_size/static/src/js/web_dialog_size.js

67
web_dialog_size/README.rst

@ -1,67 +0,0 @@
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
:target: https://www.gnu.org/licenses/agpl
:alt: License: AGPL-3
=============
Expand Dialog
=============
A module that lets the user expand/restore the dialog box size through a button
in the upper right corner (mimicking most windows managers).
It does also add draggable support to the dialogs.
Configuration
=============
By default, the module respects the caller's `dialog_size` option. If you want
to override this and have all dialogs maximized by default, set the configuration
parameter `web_dialog_size.default_maximize` to `1`.
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/162/11.0
Bug Tracker
===========
Bugs are tracked on `GitHub Issues
<https://github.com/OCA/web/issues>`_. In case of trouble, please
check there if your issue has already been reported. If you spotted it first,
help us smash it by providing detailed and welcomed feedback.
Credits
=======
Images
------
* Odoo Community Association: `Icon <https://github.com/OCA/maintainer-tools/blob/master/template/module/static/description/icon.svg>`_.
Contributors
------------
* Anthony Muschang <anthony.muschang@acsone.eu>
* Stéphane Bidoul <stephane.bidoul@acsone.eu>
* Pedro M. Baeza <pedro.baeza@tecnativa.com>
* Holger Brunn <hbrunn@therp.nl>
* Siddharth Bhalgami <siddharth.bhalgami@gmail.com>
* Wolfgang Pichler <wpichler@callino.at>
* David Vidal <david.vidal@tecnativa.com>
* Quentin Theuret <quentin.theuret@amaris.com>
Do not contact contributors directly about support or help with technical issues.
Maintainer
----------
.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org
This module is maintained by the OCA.
OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.
To contribute to this module, please visit https://odoo-community.org.

3
web_dialog_size/__init__.py

@ -1,2 +1 @@
# Copyright 2018 Quentin Theuret <quentin.theuret@amaris.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from . import models

4
web_dialog_size/__manifest__.py

@ -13,9 +13,9 @@
"Tecnativa, " "Tecnativa, "
"Amaris, " "Amaris, "
"Odoo Community Association (OCA)", "Odoo Community Association (OCA)",
'website': "http://acsone.eu",
'website': "http://github.com/OCA/web",
'category': 'web', 'category': 'web',
'version': '11.0.1.0.2',
'version': '11.0.1.0.3',
'license': 'AGPL-3', 'license': 'AGPL-3',
'depends': [ 'depends': [
'web', 'web',

1
web_dialog_size/models/__init__.py

@ -0,0 +1 @@
from . import ir_config_parameter

17
web_dialog_size/models/ir_config_parameter.py

@ -0,0 +1,17 @@
# Copyright 2018 Tecnativa - Jairo Llopis
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo.models import api, Model
from odoo.tools.safe_eval import const_eval
class IrConfigParameter(Model):
_inherit = "ir.config_parameter"
@api.model
def get_web_dialog_size_config(self):
get_param = self.sudo().get_param
return {
key: const_eval(get_param("web_dialog_size.%s" % key, "False"))
for key in ["default_maximize"]
}

3
web_dialog_size/readme/CONFIGURATION.rst

@ -0,0 +1,3 @@
By default, the module respects the caller's ``dialog_size`` option.
If you want to override this and have all dialogs maximized by default,
set the configuration parameter ``web_dialog_size.default_maximize`` to ``1``.

14
web_dialog_size/readme/CONTRIBUTORS.rst

@ -0,0 +1,14 @@
Contributors
------------
* Anthony Muschang <anthony.muschang@acsone.eu>
* Stéphane Bidoul <stephane.bidoul@acsone.eu>
* Holger Brunn <hbrunn@therp.nl>
* Siddharth Bhalgami <siddharth.bhalgami@gmail.com>
* Wolfgang Pichler <wpichler@callino.at>
* David Vidal <david.vidal@tecnativa.com>
* Quentin Theuret <quentin.theuret@amaris.com>
* `Tecnativa <https://www.tecnativa.com>`_:
* Pedro M. Baeza <pedro.baeza@tecnativa.com>
* Jairo Llopis <jairo.llopis@tecnativa.com>

3
web_dialog_size/readme/DESCRIPTION.rst

@ -0,0 +1,3 @@
A module that lets the user expand/restore the dialog box size through a button
in the upper right corner (imitating most windows managers).
It also adds draggable support to the dialogs.

15
web_dialog_size/static/src/js/web_dialog_size.js

@ -4,6 +4,11 @@ odoo.define('web_dialog_size.web_dialog_size', function (require) {
var rpc = require('web.rpc'); var rpc = require('web.rpc');
var Dialog = require('web.Dialog'); var Dialog = require('web.Dialog');
var config = rpc.query({
model: 'ir.config_parameter',
method: 'get_web_dialog_size_config',
});
Dialog.include({ Dialog.include({
willStart: function () { willStart: function () {
@ -11,12 +16,8 @@ Dialog.include({
return this._super.apply(this, arguments).then(function () { return this._super.apply(this, arguments).then(function () {
self.$modal.find('.dialog_button_extend').on('click', self.proxy('_extending')); self.$modal.find('.dialog_button_extend').on('click', self.proxy('_extending'));
self.$modal.find('.dialog_button_restore').on('click', self.proxy('_restore')); self.$modal.find('.dialog_button_restore').on('click', self.proxy('_restore'));
return rpc.query({
model: 'ir.config_parameter',
method: 'get_param',
args: ['web_dialog_size.default_maximize',],
}).then(function(default_maximize) {
if (default_maximize === "True" || default_maximize === 1) {
return config.done(function(default_maximize) {
if (default_maximize) {
self._extending(); self._extending();
} else { } else {
self._restore(); self._restore();
@ -32,7 +33,7 @@ Dialog.include({
handle: '.modal-header', handle: '.modal-header',
helper: false helper: false
}); });
};
}
return this; return this;
}, },

Loading…
Cancel
Save