[IMP] web,base_setup: add option to disable special effects

Some people prefer not to be disturbed by any flashy information.  In
this commit, we add an option to do just that.  When the 'show_effect'
option is set to false, then the messages that would be displayed by an
effect will be displayed in a notification.

Task #37712

Co-authored-by: Mohammed Shekha <msh@openerp.com>
This commit is contained in:
Pankaj Kamani
2018-05-28 11:14:20 +02:00
committed by Géry Debongnie
co-authored by Mohammed Shekha
parent f65528a74e
commit 1a7815f8b7
9 changed files with 54 additions and 7 deletions
@@ -7,6 +7,7 @@ var relational_fields = require('web.relational_fields');
var basic_fields = require('web.basic_fields');
var core = require('web.core');
var time = require('web.time');
var session = require('web.session');
var qweb = core.qweb;
var _t = core._t;
@@ -121,12 +122,16 @@ var StatementRenderer = Widget.extend(FieldManagerMixin, {
$done.find('.button_back_to_statement').click(this._onGoToBankStatement.bind(this));
this.$el.children().hide();
// display rainbowman after full reconciliation
this.trigger_up('show_effect', {
type: 'rainbow_man',
fadeout: 'no',
message: $done,
});
this.$el.css('min-height', '450px');
if (session.show_effect) {
this.trigger_up('show_effect', {
type: 'rainbow_man',
fadeout: 'no',
message: $done,
});
this.$el.css('min-height', '450px');
} else {
$done.appendTo(this.$el);
}
}
if (state.notifications) {
+1
View File
@@ -13,6 +13,7 @@ Shows you a list of applications features to install from.
""",
'depends': ['base', 'web'],
'data': [
'data/base_setup_data.xml',
'views/res_config_settings_views.xml',
'views/res_partner_views.xml',
],
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data noupdate="1">
<record model="ir.config_parameter" id="show_effect">
<field name="key">base_setup.show_effect</field>
<field name="value">True</field>
</record>
</data>
</odoo>
+1
View File
@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from . import ir_http
from . import res_config_settings
+13
View File
@@ -0,0 +1,13 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import models
from odoo.http import request
class IrHttp(models.AbstractModel):
_inherit = 'ir.http'
def session_info(self):
result = super(IrHttp, self).session_info()
result['show_effect'] = request.env['ir.config_parameter'].sudo().get_param('base_setup.show_effect')
return result
@@ -40,6 +40,7 @@ class ResConfigSettings(models.TransientModel):
help="Allows to work in a multi currency environment")
paperformat_id = fields.Many2one(related="company_id.paperformat_id", string='Paper format')
external_report_layout = fields.Selection(related="company_id.external_report_layout")
show_effect = fields.Boolean(string="Show Effect", config_parameter='base_setup.show_effect')
@api.model
def get_values(self):
@@ -78,6 +78,17 @@
</div>
</div>
</div>
<div class="col-xs-12 col-md-6 o_setting_box" groups="base.group_no_one">
<div class="o_setting_left_pane">
<field name="show_effect"/>
</div>
<div class="o_setting_right_pane">
<label for="show_effect"/>
<div class="text-muted">
Add fun feedback and motivate your employees
</div>
</div>
</div>
</div>
<div id="multi_company">
<field name="company_id" invisible="1"/>
+1
View File
@@ -39,6 +39,7 @@ class Http(models.AbstractModel):
"user_companies": {'current_company': (user.company_id.id, user.company_id.name), 'allowed_companies': [(comp.id, comp.name) for comp in user.company_ids]} if display_switch_company_menu else False,
"currencies": self.get_currencies(),
"web.base.url": self.env['ir.config_parameter'].sudo().get_param('web.base.url', default=''),
"show_effect": True
}
def get_currencies(self):
@@ -437,7 +437,12 @@ var AbstractWebClient = Widget.extend(ServiceProviderMixin, KeyboardNavigationMi
var data = e.data || {};
var type = data.type || 'rainbow_man';
if (type === 'rainbow_man') {
new RainbowMan(data).appendTo(this.$el);
if (session.show_effect) {
new RainbowMan(data).appendTo(this.$el);
} else {
// For instance keep title blank, as we don't have title in data
this.notification_manager.notify('', data.message, true);
}
} else {
throw new Error('Unknown effect type: ' + type);
}