mirror of
https://github.com/OCA/account-financial-tools.git
synced 2025-02-02 12:47:26 +02:00
[IMP] Use exceptions.warning for account_invoice_constraint_chronology addons
This commit is contained in:
committed by
Francesco Apruzzese
parent
a1e51c5e7f
commit
deb618521b
@@ -31,6 +31,7 @@ from openerp import models, api, fields
|
||||
from openerp.tools.translate import _
|
||||
from openerp.tools import DEFAULT_SERVER_DATE_FORMAT
|
||||
from datetime import datetime
|
||||
from openerp import exceptions
|
||||
|
||||
|
||||
class account_invoice(models.Model):
|
||||
@@ -54,12 +55,11 @@ class account_invoice(models.Model):
|
||||
DEFAULT_SERVER_DATE_FORMAT)
|
||||
date_invoice_tz = fields\
|
||||
.Date.context_today(self, date_invoice_format)
|
||||
raise models.except_orm(_('Error !'),
|
||||
_("Chronology Error!"
|
||||
" Please confirm older draft"
|
||||
" invoices before %s and"
|
||||
" try again.") %
|
||||
date_invoice_tz)
|
||||
raise exceptions.Warning(_("Chronology Error!"
|
||||
" Please confirm older draft"
|
||||
" invoices before %s and"
|
||||
" try again.") %
|
||||
date_invoice_tz)
|
||||
|
||||
if inv.internal_number is False:
|
||||
invoices = self.search([('state', 'in', ['open', 'paid']),
|
||||
@@ -73,10 +73,9 @@ class account_invoice(models.Model):
|
||||
DEFAULT_SERVER_DATE_FORMAT)
|
||||
date_invoice_tz = fields\
|
||||
.Date.context_today(self, date_invoice_format)
|
||||
raise models.except_orm(_('Error !'),
|
||||
_("Chronology Error! There"
|
||||
" exist at least one invoice"
|
||||
" with a date posterior"
|
||||
" to %s.") %
|
||||
date_invoice_tz)
|
||||
raise exceptions.Warning(_("Chronology Error! There"
|
||||
" exist at least one"
|
||||
" invoice with a date"
|
||||
" posterior to %s.") %
|
||||
date_invoice_tz)
|
||||
return res
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
|
||||
import openerp.tests.common as common
|
||||
from openerp import workflow
|
||||
from openerp.osv import orm
|
||||
from openerp import exceptions
|
||||
from datetime import datetime, timedelta
|
||||
from openerp.tools import DEFAULT_SERVER_DATE_FORMAT
|
||||
|
||||
@@ -106,7 +106,7 @@ class TestAccountConstraintChronology(common.TransactionCase):
|
||||
create_simple_invoice(self, journal_id, date)
|
||||
date = today.strftime(DEFAULT_SERVER_DATE_FORMAT)
|
||||
invoice_2 = create_simple_invoice(self, journal_id, date)
|
||||
self.assertRaises(orm.except_orm, workflow.trg_validate, self.uid,
|
||||
self.assertRaises(exceptions.Warning, workflow.trg_validate, self.uid,
|
||||
'account.invoice', invoice_2.id, 'invoice_open',
|
||||
self.cr)
|
||||
|
||||
@@ -120,7 +120,7 @@ class TestAccountConstraintChronology(common.TransactionCase):
|
||||
'invoice_open', self.cr)
|
||||
date = today.strftime(DEFAULT_SERVER_DATE_FORMAT)
|
||||
invoice_2 = create_simple_invoice(self, journal_id, date)
|
||||
self.assertRaises(orm.except_orm, workflow.trg_validate, self.uid,
|
||||
self.assertRaises(exceptions.Warning, workflow.trg_validate, self.uid,
|
||||
'account.invoice', invoice_2.id, 'invoice_open',
|
||||
self.cr)
|
||||
|
||||
@@ -131,6 +131,6 @@ class TestAccountConstraintChronology(common.TransactionCase):
|
||||
date = yesterday.strftime(DEFAULT_SERVER_DATE_FORMAT)
|
||||
create_simple_invoice(self, journal_id, date)
|
||||
invoice_2 = create_simple_invoice(self, journal_id, False)
|
||||
self.assertRaises(orm.except_orm, workflow.trg_validate, self.uid,
|
||||
self.assertRaises(exceptions.Warning, workflow.trg_validate, self.uid,
|
||||
'account.invoice', invoice_2.id, 'invoice_open',
|
||||
self.cr)
|
||||
|
||||
Reference in New Issue
Block a user