Remove SQL checks on invoice line type
Those checks are already implemented with domain on respective fields. issue7940 review70471002
This commit is contained in:
1 parent
3a02c0f65f
commit
2f9187d287
1 file changed
+5
-12
+5
-12
@@ -9,7 +9,7 @@ from sql.aggregate import Sum
|
||||
from sql.conditionals import Coalesce, Case
|
||||
from sql.functions import Round
|
||||
|
||||
from trytond.model import Workflow, ModelView, ModelSQL, fields, Check, \
|
||||
from trytond.model import Workflow, ModelView, ModelSQL, fields, \
|
||||
sequence_ordered, Unique, DeactivableMixin
|
||||
from trytond.report import Report
|
||||
from trytond.wizard import Wizard, StateView, StateTransition, StateAction, \
|
||||
@@ -1660,17 +1660,6 @@ class InvoiceLine(sequence_ordered(), ModelSQL, ModelView, TaxableMixin):
|
||||
@classmethod
|
||||
def __setup__(cls):
|
||||
super(InvoiceLine, cls).__setup__()
|
||||
t = cls.__table__()
|
||||
cls._sql_constraints += [
|
||||
('type_account',
|
||||
Check(t, ((t.type == 'line') & (t.account != Null))
|
||||
| (t.type != 'line')),
|
||||
'Line with "line" type must have an account.'),
|
||||
('type_invoice',
|
||||
Check(t, ((t.type != 'line') & (t.invoice != Null))
|
||||
| (t.type == 'line')),
|
||||
'Line without "line" type must have an invoice.'),
|
||||
]
|
||||
cls._error_messages.update({
|
||||
'modify': ('You can not modify line "%(line)s" from invoice '
|
||||
'"%(invoice)s" that is posted or paid.'),
|
||||
@@ -1736,6 +1725,10 @@ class InvoiceLine(sequence_ordered(), ModelSQL, ModelView, TaxableMixin):
|
||||
# Migration from 4.6: drop required on description
|
||||
table.not_null_action('description', action='remove')
|
||||
|
||||
# Migration from 5.0: remove check constraints
|
||||
table.drop_constraint('type_account')
|
||||
table.drop_constraint('type_invoice')
|
||||
|
||||
@staticmethod
|
||||
def default_currency():
|
||||
Company = Pool().get('company.company')
|
||||
|
||||
Reference in new issue
Block a user