[IMP] account: when the period is not defined, raise a RedirectWarning instead of...
authorThibault Delavallée <tde@openerp.com>
Fri, 3 Jan 2014 09:36:10 +0000 (10:36 +0100)
committerThibault Delavallée <tde@openerp.com>
Fri, 3 Jan 2014 09:36:10 +0000 (10:36 +0100)
This allows to add a redirection button to the configuration panel
of fiscal years.

bzr revid: tde@openerp.com-20140103093610-p7u12yb03rkj81bk

addons/account/account.py

index 89836be..8bef8e7 100644 (file)
@@ -1023,7 +1023,10 @@ class account_period(osv.osv):
         if not result:
             result = self.search(cr, uid, args, context=context)
         if not result:
-            raise osv.except_osv(_('Error!'), _('There is no period defined for this date: %s.\nPlease create one.')%dt)
+            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'))
+
         return result
 
     def action_draft(self, cr, uid, ids, *args):