From e310cfc96a22f276aa76cc8b03782d94226502b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Mon, 20 Aug 2018 22:39:16 +0200 Subject: [PATCH] Remove unique constraint on attachment name issue7613 review50531002 --- CHANGELOG | 1 + trytond/ir/attachment.py | 15 ++++----------- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 49bf052e05..a51f7d9063 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,4 @@ +* Remove unique constraint on attachment name * New icons * Add pyson TimeDelta * Remove button if it is not allowed to access some of its dependant fields diff --git a/trytond/ir/attachment.py b/trytond/ir/attachment.py index b1c07af29e..a2f617a510 100644 --- a/trytond/ir/attachment.py +++ b/trytond/ir/attachment.py @@ -3,7 +3,7 @@ from sql import Null from sql.operators import Concat -from ..model import ModelView, ModelSQL, fields, Unique +from ..model import ModelView, ModelSQL, fields from ..transaction import Transaction from ..pyson import Eval from .resource import ResourceMixin @@ -51,16 +51,6 @@ class Attachment(ResourceMixin, ModelSQL, ModelView): 'invisible': Eval('type') != 'data', }, depends=['type']), 'get_size') - @classmethod - def __setup__(cls): - super(Attachment, cls).__setup__() - table = cls.__table__() - cls._sql_constraints += [ - ('resource_name', - Unique(table, table.resource, table.name), - 'The names of attachments must be unique by resource.'), - ] - @classmethod def __register__(cls, module_name): cursor = Transaction().connection.cursor() @@ -86,6 +76,9 @@ class Attachment(ResourceMixin, ModelSQL, ModelView): table.drop_column('digest') table.drop_column('collision') + # Migration from 4.8: remove unique constraint + table.drop_constraint('resource_name') + @staticmethod def default_type(): return 'data'