[IMP] Replace except_orm with Warning

This commit is contained in:
Adrien Peiffer
2014-11-19 09:25:36 +01:00
parent 727702d6d5
commit 51e4a8a6e2
3 changed files with 10 additions and 13 deletions

View File

@@ -45,8 +45,7 @@ class AccountMoveLine(models.Model):
return True return True
err_msg = (_('Invoice name (id): %s (%s)') % err_msg = (_('Invoice name (id): %s (%s)') %
(line.invoice.name, line.invoice.id)) (line.invoice.name, line.invoice.id))
raise exceptions.except_orm( raise exceptions.Warning(
_('Error'),
_('You cannot do this on an entry generated by an invoice.' _('You cannot do this on an entry generated by an invoice.'
'You must ' 'You must '
'change the related invoice directly.\n%s.') % err_msg) 'change the related invoice directly.\n%s.') % err_msg)
@@ -60,8 +59,7 @@ class AccountMoveLine(models.Model):
return True return True
err_msg = (_('Bank statement name (id): %s (%s)') % err_msg = (_('Bank statement name (id): %s (%s)') %
(line.statement_id.name, line.statement_id.id)) (line.statement_id.name, line.statement_id.id))
raise exceptions.except_orm( raise exceptions.Warning(
_('Error'),
_('You cannot do this on an entry generated by a bank' _('You cannot do this on an entry generated by a bank'
' statement. ' ' statement. '
'You must change the related bank statement' 'You must change the related bank statement'

View File

@@ -28,10 +28,9 @@
# #
import openerp.tests.common as common import openerp.tests.common as common
from openerp.osv import orm
from datetime import datetime from datetime import datetime
from openerp.tools import DEFAULT_SERVER_DATE_FORMAT from openerp.tools import DEFAULT_SERVER_DATE_FORMAT
from openerp import workflow from openerp import workflow, exceptions
DB = common.DB DB = common.DB
ADMIN_USER_ID = common.ADMIN_USER_ID ADMIN_USER_ID = common.ADMIN_USER_ID
@@ -75,7 +74,8 @@ class TestAccountConstraints(common.TransactionCase):
move_lines = move.line_id move_lines = move.line_id
move.with_context({'from_parent_object': True})\ move.with_context({'from_parent_object': True})\
.write({'state': 'draft'}) .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): def test_post_move_invoice_ref(self):
invoice = create_simple_invoice(self) invoice = create_simple_invoice(self)
@@ -93,4 +93,5 @@ class TestAccountConstraints(common.TransactionCase):
workflow.trg_validate(self.uid, 'account.invoice', invoice.id, workflow.trg_validate(self.uid, 'account.invoice', invoice.id,
'invoice_open', self.cr) 'invoice_open', self.cr)
move_lines = invoice.move_id.line_id 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'})

View File

@@ -46,16 +46,14 @@ class AccountMove(models.Model):
continue continue
else: else:
if not line.journal_id.update_posted: if not line.journal_id.update_posted:
raise exceptions.except_orm( raise exceptions.Warning(
_('Error!'),
_('You cannot modify a posted entry of this journal.' _('You cannot modify a posted entry of this journal.'
'First you should set the journal to allow' 'First you should set the journal to allow'
' cancelling entries.') ' cancelling entries.'))
)
if self: if self:
self._cr.execute('UPDATE account_move ' self._cr.execute('UPDATE account_move '
'SET state=%s ' 'SET state=%s '
'WHERE id IN %s', ('draft', self._ids,)) 'WHERE id IN %s', ('draft', self.ids,))
return True return True
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: