From 628f8d2489d03862f73d3a41663bc2f5b644384b Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Tue, 11 Feb 2020 16:24:22 +0100 Subject: Finds: do not duplicate treatments on duplicate action --- archaeological_finds/models_finds.py | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'archaeological_finds/models_finds.py') diff --git a/archaeological_finds/models_finds.py b/archaeological_finds/models_finds.py index f4056cf4b..5b980a590 100644 --- a/archaeological_finds/models_finds.py +++ b/archaeological_finds/models_finds.py @@ -1993,6 +1993,10 @@ class Find(BulkUpdatedItem, ValueGetter, DocumentItem, BaseHistorizedItem, if data: for k in data: setattr(new, k, data[k]) + # remove associated treatments + if not duplicate_for_treatment and ( + new.upstream_treatment or new.downstream_treatment): + new.upstream_treatment, new.downstream_treatment = None, None new.save() # m2m fields @@ -2023,6 +2027,8 @@ class Find(BulkUpdatedItem, ValueGetter, DocumentItem, BaseHistorizedItem, user=user, data={"label": new.label, "external_id": None})) # remove documents for this kind of duplicate (data entry) new.documents.clear() + # remove associated treatments + new.treatments.clear() return new @classmethod -- cgit v1.2.3