mirror of
https://github.com/OCA/account-financial-tools.git
synced 2025-02-02 12:47:26 +02:00
[IMP] Replace except_orm with Warning
This commit is contained in:
@@ -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'
|
||||
|
||||
@@ -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'})
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user