From 51e4a8a6e2efb51f09cb41e9c84fbd7752a60121 Mon Sep 17 00:00:00 2001 From: Adrien Peiffer Date: Wed, 19 Nov 2014 09:25:36 +0100 Subject: [PATCH] [IMP] Replace except_orm with Warning --- account_constraints/model/account_move_line.py | 6 ++---- account_constraints/tests/test_account_constraints.py | 9 +++++---- account_default_draft_move/account.py | 8 +++----- 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/account_constraints/model/account_move_line.py b/account_constraints/model/account_move_line.py index 8e38285c8..f74f3ac1a 100644 --- a/account_constraints/model/account_move_line.py +++ b/account_constraints/model/account_move_line.py @@ -45,8 +45,7 @@ class AccountMoveLine(models.Model): return True err_msg = (_('Invoice name (id): %s (%s)') % (line.invoice.name, line.invoice.id)) - raise exceptions.except_orm( - _('Error'), + raise exceptions.Warning( _('You cannot do this on an entry generated by an invoice.' 'You must ' 'change the related invoice directly.\n%s.') % err_msg) @@ -60,8 +59,7 @@ class AccountMoveLine(models.Model): return True err_msg = (_('Bank statement name (id): %s (%s)') % (line.statement_id.name, line.statement_id.id)) - raise exceptions.except_orm( - _('Error'), + raise exceptions.Warning( _('You cannot do this on an entry generated by a bank' ' statement. ' 'You must change the related bank statement' diff --git a/account_constraints/tests/test_account_constraints.py b/account_constraints/tests/test_account_constraints.py index cfae38313..4682803e1 100644 --- a/account_constraints/tests/test_account_constraints.py +++ b/account_constraints/tests/test_account_constraints.py @@ -28,10 +28,9 @@ # import openerp.tests.common as common -from openerp.osv import orm from datetime import datetime from openerp.tools import DEFAULT_SERVER_DATE_FORMAT -from openerp import workflow +from openerp import workflow, exceptions DB = common.DB ADMIN_USER_ID = common.ADMIN_USER_ID @@ -75,7 +74,8 @@ class TestAccountConstraints(common.TransactionCase): move_lines = move.line_id move.with_context({'from_parent_object': True})\ .write({'state': 'draft'}) - self.assertRaises(orm.except_orm, move_lines.write, {'credit': 0.0}) + self.assertRaises(exceptions.Warning, move_lines.write, + {'credit': 0.0}) def test_post_move_invoice_ref(self): invoice = create_simple_invoice(self) @@ -93,4 +93,5 @@ class TestAccountConstraints(common.TransactionCase): workflow.trg_validate(self.uid, 'account.invoice', invoice.id, 'invoice_open', self.cr) move_lines = invoice.move_id.line_id - self.assertRaises(orm.except_orm, move_lines.write, {'ref': 'test'}) + self.assertRaises(exceptions.Warning, move_lines.write, + {'ref': 'test'}) diff --git a/account_default_draft_move/account.py b/account_default_draft_move/account.py index 7ac525e44..3c5bb6c8b 100644 --- a/account_default_draft_move/account.py +++ b/account_default_draft_move/account.py @@ -46,16 +46,14 @@ class AccountMove(models.Model): continue else: if not line.journal_id.update_posted: - raise exceptions.except_orm( - _('Error!'), + raise exceptions.Warning( _('You cannot modify a posted entry of this journal.' 'First you should set the journal to allow' - ' cancelling entries.') - ) + ' cancelling entries.')) if self: self._cr.execute('UPDATE account_move ' 'SET state=%s ' - 'WHERE id IN %s', ('draft', self._ids,)) + 'WHERE id IN %s', ('draft', self.ids,)) return True # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: