From 2f9187d28789c27677dbd1ea99c3a2f3e3937fc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Sun, 23 Dec 2018 17:31:21 +0100 Subject: [PATCH] Remove SQL checks on invoice line type Those checks are already implemented with domain on respective fields. issue7940 review70471002 --- invoice.py | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/invoice.py b/invoice.py index d1dc55454f..eafee852a0 100644 --- a/invoice.py +++ b/invoice.py @@ -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')