diff --git a/addons/account/invoice.py b/addons/account/invoice.py index 20eea676611..c66dda115b2 100644 --- a/addons/account/invoice.py +++ b/addons/account/invoice.py @@ -324,6 +324,17 @@ class account_invoice(osv.osv): 'user_id': lambda s,cr,u,c: u, } + def create(self, cr, uid, vals, context={}): + try: + res = super(account_invoice, self).create(cr, uid, vals, context) + return res + except Exception,e: + if '"journal_id" viol' in e.args[0]: + raise except_orm(_('Configuration Error!'), + _('There is no Accounting Journal of type Sale/Purchase defined!')) + else: + raise except_orm(_('UnknownError'), str(e)) + def unlink(self, cr, uid, ids, context=None): invoices = self.read(cr, uid, ids, ['state']) unlink_ids = []