[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.
This commit is contained in:
Jairo Llopis
2018-06-13 08:54:46 +02:00
committed by Mantux11
parent 8b9d514241
commit f7b883c4c3
10 changed files with 536 additions and 43 deletions

View File

@@ -4,6 +4,11 @@ odoo.define('web_dialog_size.web_dialog_size', function (require) {
var rpc = require('web.rpc');
var Dialog = require('web.Dialog');
var config = rpc.query({
model: 'ir.config_parameter',
method: 'get_web_dialog_size_config',
});
Dialog.include({
willStart: function () {
@@ -11,12 +16,8 @@ Dialog.include({
return this._super.apply(this, arguments).then(function () {
self.$modal.find('.dialog_button_extend').on('click', self.proxy('_extending'));
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();
} else {
self._restore();
@@ -32,7 +33,7 @@ Dialog.include({
handle: '.modal-header',
helper: false
});
};
}
return this;
},