changeset 59d41d23e45c in modules/account_invoice:default
details: 
https://hg.tryton.org/modules/account_invoice?cmd=changeset;node=59d41d23e45c
description:
        Remove SQL checks on invoice line type

        Those checks are already implemented with domain on respective fields.

        issue7940
        review70471002
diffstat:

 invoice.py |  17 +++++------------
 1 files changed, 5 insertions(+), 12 deletions(-)

diffs (41 lines):

diff -r 22eabf722a91 -r 59d41d23e45c invoice.py
--- a/invoice.py        Mon Oct 15 22:56:01 2018 +0200
+++ b/invoice.py        Sun Dec 23 17:31:21 2018 +0100
@@ -9,7 +9,7 @@
 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 @@
     @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 @@
         # 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')

Reply via email to