From 6cc4bd431220f4dea75a14b8a21f45cc77eda097 Mon Sep 17 00:00:00 2001 From: ssh-odoo Date: Wed, 25 Jun 2014 11:39:36 +0530 Subject: [PATCH] [Imp]:Improve configuration warning msg [imp]:remove space [rem]:remove code [imp]:remove changes [imp]:remove changes [rem]:remove unused changes --- addons/account/account.py | 9 +++++---- addons/account/account_invoice.py | 22 +++++++++++++--------- addons/account/account_move_line.py | 5 ++++- addons/account_voucher/account_voucher.py | 9 +++++++-- addons/google_drive/google_drive.py | 11 ++++++++--- addons/hr_timesheet/hr_timesheet.py | 5 ++++- addons/mail/res_users.py | 5 ++++- addons/web/static/src/css/base.css | 10 ++++++++++ addons/web/static/src/css/base.sass | 8 ++++++++ addons/web/static/src/js/chrome.js | 13 ++++++++----- addons/web/static/src/xml/base.xml | 2 +- 11 files changed, 72 insertions(+), 27 deletions(-) diff --git a/addons/account/account.py b/addons/account/account.py index fcb4c783e12..98ebcb54224 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -932,7 +932,9 @@ class account_fiscalyear(osv.osv): ids = self.search(cr, uid, args, context=context) if not ids: if exception: - raise osv.except_osv(_('Error!'), _('There is no fiscal year defined for this date.\nPlease create one from the configuration of the accounting menu.')) + 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')) else: return [] return ids @@ -1021,10 +1023,9 @@ class account_period(osv.osv): if not result: 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_fiscalyear') - msg = _('There is no period defined for this date: %s.\nPlease, go to Configuration/Periods and configure a fiscal year.') % dt + 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')) - return result def action_draft(self, cr, uid, ids, *args): diff --git a/addons/account/account_invoice.py b/addons/account/account_invoice.py index dd825f59f0e..72e3ed2be59 100644 --- a/addons/account/account_invoice.py +++ b/addons/account/account_invoice.py @@ -471,7 +471,7 @@ class account_invoice(osv.osv): return True def onchange_partner_id(self, cr, uid, ids, type, partner_id,\ - date_invoice=False, payment_term=False, partner_bank_id=False, company_id=False): + date_invoice=False, payment_term=False, partner_bank_id=False, company_id=False, context=None): partner_payment_term = False acc_id = False bank_id = False @@ -496,8 +496,9 @@ class account_invoice(osv.osv): rec_res_id = rec_line_data and rec_line_data[0].get('value_reference',False) and int(rec_line_data[0]['value_reference'].split(',')[1]) or False pay_res_id = pay_line_data and pay_line_data[0].get('value_reference',False) and int(pay_line_data[0]['value_reference'].split(',')[1]) or False if not rec_res_id and not pay_res_id: - raise osv.except_osv(_('Configuration Error!'), - _('Cannot find a chart of accounts for this company, you should create one.')) + model, action_id = self.pool['ir.model.data'].get_object_reference(cr, uid, 'account', 'action_account_config') + msg = _('Cannot find a chart of accounts for this company, You should configure it. \nPlease go to Account Configuration.') + raise openerp.exceptions.RedirectWarning(msg, action_id, _('Go to the configuration panel')) account_obj = self.pool.get('account.account') rec_obj_acc = account_obj.browse(cr, uid, [rec_res_id]) pay_obj_acc = account_obj.browse(cr, uid, [pay_res_id]) @@ -607,8 +608,9 @@ class account_invoice(osv.osv): pay_res_id = pay_line_data and pay_line_data[0].get('value_reference',False) and int(pay_line_data[0]['value_reference'].split(',')[1]) or False if not rec_res_id and not pay_res_id: - raise self.pool.get('res.config.settings').get_config_warning(cr, _('Cannot find any chart of account: you can create a new one from %(menu:account.menu_account_config)s.'), context=context) - + model, action_id = self.pool['ir.model.data'].get_object_reference(cr, uid, 'account', 'action_account_config') + msg = _('Cannot find a chart of accounts for this company, You should configure it. \nPlease go to Account Configuration.') + raise openerp.exceptions.RedirectWarning(msg, action_id, _('Go to the configuration panel')) if type in ('out_invoice', 'out_refund'): acc_id = rec_res_id else: @@ -623,8 +625,9 @@ class account_invoice(osv.osv): if line.account_id.company_id.id != company_id: result_id = account_obj.search(cr, uid, [('name','=',line.account_id.name),('company_id','=',company_id)]) if not result_id: - raise osv.except_osv(_('Configuration Error!'), - _('Cannot find a chart of account, you should create one from Settings\Configuration\Accounting menu.')) + model, action_id = self.pool['ir.model.data'].get_object_reference(cr, uid, 'account', 'action_account_config') + msg = _('Cannot find a chart of accounts for this company, You should configure it. \nPlease go to Account Configuration.') + raise openerp.exceptions.RedirectWarning(msg, action_id, _('Go to the configuration panel')) inv_line_obj.write(cr, uid, [line.id], {'account_id': result_id[-1]}) else: if invoice_line: @@ -656,8 +659,9 @@ class account_invoice(osv.osv): journal_type_label = self.pool['ir.translation']._get_source(cr, uid, None, ('code','selection'), context.get('lang'), journal_type_map.get(journal_type)) - raise osv.except_osv(_('Configuration Error!'), - _('Cannot find any account journal of %s type for this company.\n\nYou can create one in the menu: \nConfiguration\Journals\Journals.') % ('"%s"' % journal_type_label)) + model, action_id = self.pool['ir.model.data'].get_object_reference(cr, uid, 'account', 'action_account_journal_form') + msg = _("""Cannot find any account journal of type "%s" for this company, You should create one.\n Please go to Journal Configuration""") % journal_type_label + raise openerp.exceptions.RedirectWarning(msg, action_id, _('Go to the configuration panel')) dom = {'journal_id': [('id', 'in', journal_ids)]} else: journal_ids = obj_journal.search(cr, uid, []) diff --git a/addons/account/account_move_line.py b/addons/account/account_move_line.py index cff0c2efa8c..444e14a715a 100644 --- a/addons/account/account_move_line.py +++ b/addons/account/account_move_line.py @@ -31,6 +31,7 @@ from openerp.osv import fields, osv, orm from openerp.tools.translate import _ import openerp.addons.decimal_precision as dp from openerp import tools +import openerp class account_move_line(osv.osv): _name = "account.move.line" @@ -548,7 +549,9 @@ class account_move_line(osv.osv): if context.get('journal_type', False): jids = journal_pool.search(cr, uid, [('type','=', context.get('journal_type'))]) if not jids: - raise osv.except_osv(_('Configuration Error!'), _('Cannot find any account journal of %s type for this company.\n\nYou can create one in the menu: \nConfiguration/Journals/Journals.') % context.get('journal_type')) + model, action_id = self.pool['ir.model.data'].get_object_reference(cr, uid, 'account', 'action_account_journal_form') + msg = _("""Cannot find any account journal of "%s" type for this company, You should create one.\n Please go to Journal Configuration""") % context.get('journal_type').replace('_', ' ').title() + raise openerp.exceptions.RedirectWarning(msg, action_id, _('Go to the configuration panel')) journal_id = jids[0] return journal_id diff --git a/addons/account_voucher/account_voucher.py b/addons/account_voucher/account_voucher.py index 870869ee3dc..9fde90231b2 100644 --- a/addons/account_voucher/account_voucher.py +++ b/addons/account_voucher/account_voucher.py @@ -27,6 +27,7 @@ import openerp.addons.decimal_precision as dp from openerp.tools.translate import _ from openerp.tools import float_compare from openerp.report import report_sxw +import openerp class res_currency(osv.osv): _inherit = "res.currency" @@ -1096,11 +1097,15 @@ class account_voucher(osv.osv): if amount_residual > 0: account_id = line.voucher_id.company_id.expense_currency_exchange_account_id if not account_id: - raise osv.except_osv(_('Insufficient Configuration!'),_("You should configure the 'Loss Exchange Rate Account' in the accounting settings, to manage automatically the booking of accounting entries related to differences between exchange rates.")) + model, action_id = self.pool['ir.model.data'].get_object_reference(cr, uid, 'account', 'action_account_form') + msg = _("You should configure the 'Loss Exchange Rate Account' to manage automatically the booking of accounting entries related to differences between exchange rates.") + raise openerp.exceptions.RedirectWarning(msg, action_id, _('Go to the configuration panel')) else: account_id = line.voucher_id.company_id.income_currency_exchange_account_id if not account_id: - raise osv.except_osv(_('Insufficient Configuration!'),_("You should configure the 'Gain Exchange Rate Account' in the accounting settings, to manage automatically the booking of accounting entries related to differences between exchange rates.")) + model, action_id = self.pool['ir.model.data'].get_object_reference(cr, uid, 'account', 'action_account_form') + msg = _("You should configure the 'Gain Exchange Rate Account' to manage automatically the booking of accounting entries related to differences between exchange rates.") + raise openerp.exceptions.RedirectWarning(msg, action_id, _('Go to the configuration panel')) # Even if the amount_currency is never filled, we need to pass the foreign currency because otherwise # the receivable/payable account may have a secondary currency, which render this field mandatory if line.account_id.currency_id: diff --git a/addons/google_drive/google_drive.py b/addons/google_drive/google_drive.py index cd8fc486a89..779b0231540 100644 --- a/addons/google_drive/google_drive.py +++ b/addons/google_drive/google_drive.py @@ -27,6 +27,7 @@ import werkzeug.urls import urllib2 import json import re +import openerp _logger = logging.getLogger(__name__) @@ -63,7 +64,9 @@ class config(osv.Model): user_is_admin = self.pool['res.users'].has_group(cr, uid, 'base.group_erp_manager') if not google_drive_refresh_token: if user_is_admin: - raise self.pool.get('res.config.settings').get_config_warning(cr, _("You haven't configured 'Authorization Code' generated from google, Please generate and configure it in %(menu:base_setup.menu_general_configuration)s."), context=context) + model, action_id = self.pool['ir.model.data'].get_object_reference(cr, uid, 'base_setup', 'action_general_configuration') + msg = _("You haven't configured 'Authorization Code' generated from google, Please generate and configure it .") + raise openerp.exceptions.RedirectWarning(msg, action_id, _('Go to the configuration panel')) else: raise osv.except_osv(_('Error!'), _("Google Drive is not yet configured. Please contact your administrator.")) google_drive_client_id = ir_config.get_param(cr, SUPERUSER_ID, 'google_drive_client_id') @@ -81,7 +84,9 @@ class config(osv.Model): content = urllib2.urlopen(req).read() except urllib2.HTTPError: if user_is_admin: - raise self.pool.get('res.config.settings').get_config_warning(cr, _("Something went wrong during the token generation. Please request again an authorization code in %(menu:base_setup.menu_general_configuration)s."), context=context) + model, action_id = self.pool['ir.model.data'].get_object_reference(cr, uid, 'base_setup', 'action_general_configuration') + msg = _("Something went wrong during the token generation. Please request again an authorization code .") + raise openerp.exceptions.RedirectWarning(msg, action_id, _('Go to the configuration panel')) else: raise osv.except_osv(_('Error!'), _("Google Drive is not yet configured. Please contact your administrator.")) content = json.loads(content) @@ -98,7 +103,7 @@ class config(osv.Model): req = urllib2.Request(request_url, None, headers) parents = urllib2.urlopen(req).read() except urllib2.HTTPError: - raise self.pool.get('res.config.settings').get_config_warning(cr, _("The Google Template cannot be found. Maybe it has been deleted."), context=context) + raise osv.except_osv(_('Warning!'), _("The Google Template cannot be found. Maybe it has been deleted.")) parents_dict = json.loads(parents) record_url = "Click on link to open Record in OpenERP\n %s/?db=%s#id=%s&model=%s" % (google_web_base_url, cr.dbname, res_id, res_model) diff --git a/addons/hr_timesheet/hr_timesheet.py b/addons/hr_timesheet/hr_timesheet.py index 7aa7cbaba08..f14ed9f0ac4 100644 --- a/addons/hr_timesheet/hr_timesheet.py +++ b/addons/hr_timesheet/hr_timesheet.py @@ -24,6 +24,7 @@ import time from openerp.osv import fields from openerp.osv import osv from openerp.tools.translate import _ +import openerp class hr_employee(osv.osv): _name = "hr.employee" @@ -147,7 +148,9 @@ class hr_analytic_timesheet(osv.osv): else: emp_id = emp_obj.search(cr, uid, [('user_id','=',context.get('user_id') or uid)], limit=1, context=context) if not emp_id: - raise osv.except_osv(_('Warning!'), _('Please create an employee for this user, using the menu: Human Resources > Employees.')) + model, action_id = self.pool['ir.model.data'].get_object_reference(cr, uid, 'hr', 'open_view_employee_list_my') + msg = _("Employee is not created for this user. Please create one from configuration panel.") + raise openerp.exceptions.RedirectWarning(msg, action_id, _('Go to the configuration panel')) emp = emp_obj.browse(cr, uid, emp_id[0], context=context) if emp.journal_id: return emp.journal_id.id diff --git a/addons/mail/res_users.py b/addons/mail/res_users.py index 8fe1482b427..e218ea85927 100644 --- a/addons/mail/res_users.py +++ b/addons/mail/res_users.py @@ -22,6 +22,7 @@ from openerp.osv import fields, osv from openerp import SUPERUSER_ID from openerp.tools.translate import _ +import openerp class res_users(osv.Model): @@ -68,7 +69,9 @@ class res_users(osv.Model): def create(self, cr, uid, data, context=None): if not data.get('login', False): - raise osv.except_osv(_('Invalid Action!'), _('You may not create a user. To create new users, you should use the "Settings > Users" menu.')) + model, action_id = self.pool['ir.model.data'].get_object_reference(cr, uid, 'base', 'action_res_users') + msg = _("You cannot create a new user from here.\n To create new user please go to configuration panel.") + raise openerp.exceptions.RedirectWarning(msg, action_id, _('Go to the configuration panel')) if context is None: context = {} diff --git a/addons/web/static/src/css/base.css b/addons/web/static/src/css/base.css index 1917396b6a3..acdcc0a95aa 100644 --- a/addons/web/static/src/css/base.css +++ b/addons/web/static/src/css/base.css @@ -376,6 +376,16 @@ display: inline; vertical-align: middle; } +.openerp .oe_warning_redirect { + border: none !important; + padding: 0 !important; + margin-left: 20px !important; + background: #f5f7f9 !important; + box-shadow: none !important; +} +.openerp .oe_warning_redirect:hover { + text-decoration: underline !important; +} .openerp .oe_stat_button:hover { background: #7c7bad; color: white; diff --git a/addons/web/static/src/css/base.sass b/addons/web/static/src/css/base.sass index cb30ffecde8..b806c32ffc2 100644 --- a/addons/web/static/src/css/base.sass +++ b/addons/web/static/src/css/base.sass @@ -348,6 +348,14 @@ $sheet-padding: 16px @include box-shadow(none) &:hover background: #ED6F6A + .oe_warning_redirect + border: none !important + padding: 0 !important + margin-left: 20px !important + background: #f5f7f9 !important + box-shadow: none !important + &:hover + text-decoration: underline !important .oe_stat_button font-weight: normal width: 132px !important diff --git a/addons/web/static/src/js/chrome.js b/addons/web/static/src/js/chrome.js index 922c3a36e47..39c7395556e 100644 --- a/addons/web/static/src/js/chrome.js +++ b/addons/web/static/src/js/chrome.js @@ -124,11 +124,12 @@ 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 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: {} }}})); + var $but = $(QWeb.render('WidgetButton', { widget : { string: text, node: { attrs: {'class': oe_link_class} }}})); $customButons.append($but); $but.on('click', function(ev) { fn.call(self.$el, ev); @@ -330,6 +331,7 @@ instance.web.RedirectWarningHandler = instance.web.Dialog.extend(instance.web.Ex this.error = error; }, display: function() { + var self = this; error = this.error; error.data.message = error.data.arguments[0]; @@ -337,14 +339,15 @@ instance.web.RedirectWarningHandler = instance.web.Dialog.extend(instance.web.Ex size: 'medium', title: "OpenERP " + (_.str.capitalize(error.type) || "Warning"), buttons: [ - {text: _t("Ok"), click: function() { this.$el.parents('.modal').modal('hide'); }}, - {text: error.data.arguments[2], click: function() { + {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]; - this.$el.parents('.modal').modal('hide'); + self.destroy(); }} ], }, QWeb.render('CrashManager.warning', {error: error})).open(); - this.destroy(); } }); instance.web.crash_manager_registry.add('openerp.exceptions.RedirectWarning', 'instance.web.RedirectWarningHandler'); diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml index 8c833817d99..e2d5ae02068 100644 --- a/addons/web/static/src/xml/base.xml +++ b/addons/web/static/src/xml/base.xml @@ -1365,7 +1365,7 @@ -