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
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):
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
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])
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:
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:
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, [])
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"
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
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"
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:
import urllib2
import json
import re
+import openerp
_logger = logging.getLogger(__name__)
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')
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)
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)
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"
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
from openerp.osv import fields, osv
from openerp import SUPERUSER_ID
from openerp.tools.translate import _
+import openerp
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 = {}
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;
@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
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);
this.error = error;
},
display: function() {
+ var self = this;
error = this.error;
error.data.message = error.data.arguments[0];
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');
</div>
</t>
<t t-name="WidgetButton">
- <button type="button" t-att-class="widget.is_stat_button ? 'oe_stat_button btn btn-default' : 'oe_button oe_form_button'"
+ <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"
t-att-autofocus="widget.node.attrs.autofocus"