[IMP] account: better redirection warning messages.
authoryti <yti@odoo.com>
Thu, 4 Sep 2014 06:38:56 +0000 (08:38 +0200)
committerThibault Delavallée <tde@openerp.com>
Mon, 8 Sep 2014 10:40:44 +0000 (12:40 +0200)
[IMP] web: better display of redirection warnings ('Go to Config' or Cancel, like other
wizards in odoo)

addons/account/account.py
addons/web/static/src/js/chrome.js
addons/web/static/src/xml/base.xml

index 5d7f36d..4e0fd78 100644 (file)
@@ -944,8 +944,8 @@ class account_fiscalyear(osv.osv):
         if not ids:
             if exception:
                 model, action_id = self.pool['ir.model.data'].get_object_reference(cr, uid, 'account', 'action_account_fiscalyear')
-                msg = _('There is no period defined for this date: %s.\nPlease go to Configuration/Periods and configure a fiscal year.') % dt
-                raise openerp.exceptions.RedirectWarning(msg, action_id, _('Go to the configuration panel'))
+                msg = _('No accounting period is covering this date: %s.') % dt
+                raise openerp.exceptions.RedirectWarning(msg, action_id, _(' Configure Fiscal Year Now'))
             else:
                 return []
         return ids
@@ -1037,8 +1037,8 @@ class account_period(osv.osv):
             result = self.search(cr, uid, args, context=context)
         if not result:
             model, action_id = self.pool['ir.model.data'].get_object_reference(cr, uid, 'account', 'action_account_period')
-            msg = _('There is no period defined for this date: %s.\nPlease go to Configuration/Periods.') % dt
-            raise openerp.exceptions.RedirectWarning(msg, action_id, _('Go to the configuration panel'))
+            msg = _('No accounting period is covering this date: %s.') % dt
+            raise openerp.exceptions.RedirectWarning(msg, action_id, _('Configure Periods Now'))
         return result
 
     def action_draft(self, cr, uid, ids, context=None):
index 8fa16a9..99ec280 100644 (file)
@@ -125,14 +125,16 @@ instance.web.Dialog = instance.web.Widget.extend({
         var $customButons = this.$buttons.find('.oe_dialog_custom_buttons').empty();
         _.each(buttons, function(fn, text) {
             // buttons can be object or array
+            var pre_text  = fn.pre_text || "";
+            var post_text = fn.post_text || "";
             var oe_link_class = fn.oe_link_class;
             if (!_.isFunction(fn)) {
                 text = fn.text;
                 fn = fn.click;
             }
-            var $but = $(QWeb.render('WidgetButton', { widget : { string: text, node: { attrs: {'class': oe_link_class} }}}));
+            var $but = $(QWeb.render('WidgetButton', { widget : { pre_text: pre_text, post_text: post_text, string: text, node: { attrs: {'class': oe_link_class} }}}));
             $customButons.append($but);
-            $but.on('click', function(ev) {
+            $but.filter('button').on('click', function(ev) {
                 fn.call(self.$el, ev);
             });
         });
@@ -151,7 +153,6 @@ instance.web.Dialog = instance.web.Widget.extend({
             delete(options.buttons);
         }
         this.renderElement();
-
         this.$dialog_box = $(QWeb.render('Dialog', options)).appendTo("body");
         this.$el.modal({
             'backdrop': false,
@@ -343,13 +344,14 @@ instance.web.RedirectWarningHandler = instance.web.Dialog.extend(instance.web.Ex
             size: 'medium',
             title: "Odoo " + (_.str.capitalize(error.type) || "Warning"),
             buttons: [
-                {text: _t("Ok"), click: function() { self.$el.parents('.modal').modal('hide');  self.destroy();}},
-                {text: error.data.arguments[2],
-                 oe_link_class: 'oe_link',
-                 click: function() {
-                    window.location.href='#action='+error.data.arguments[1];
-                    self.destroy();
-                }}
+                {text: error.data.arguments[2], 
+                    oe_link_class : 'oe_highlight',
+                    post_text : _t("or"),
+                    click: function() {
+                        window.location.href='#action='+error.data.arguments[1]
+                        self.destroy();
+                    }},
+                {text: _t("Cancel"), oe_link_class: 'oe_link', click: function() { self.$el.parents('.modal').modal('hide');  self.destroy();}}
             ],
         }, QWeb.render('CrashManager.warning', {error: error})).open();
     }
index 93269fe..47fcca8 100644 (file)
@@ -49,7 +49,6 @@
 <t t-name="CrashManager.warning">
     <table cellspacing="0" cellpadding="0" border="0" class="oe_dialog_warning">
     <tr>
-        <td class="oe_dialog_icon"><img t-att-src='_s + "/web/static/src/img/warning.png"'/></td>
         <td>
             <p>
                 <t t-js="d">
     </div>
 </t>
 <t t-name="WidgetButton">
+    <span t-if="widget.pre_text"> <t t-esc="widget.pre_text"/> </span>
     <button type="button" t-att-class="widget.is_stat_button ? 'oe_stat_button btn btn-default' : 'oe_button oe_form_button ' + (widget.node.attrs.class ? widget.node.attrs.class : '')"
         t-att-style="widget.node.attrs.style"
         t-att-tabindex="widget.node.attrs.tabindex"
         <span t-if="widget.string and !widget.is_stat_button"><t t-esc="widget.string"/></span>
         <div t-if="widget.string and widget.is_stat_button"><t t-esc="widget.string"/></div>
     </button>
+    <span t-if="widget.post_text"> <t t-esc="widget.post_text"/> </span>
 </t>
 <t t-name="WidgetButton.tooltip" t-extend="WidgetLabel.tooltip">
     <t t-jquery="div.oe_tooltip_string" t-operation="replace">