From 5d4a7912d085a4af2491e8b413a552f598c943c2 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Thu, 27 Jun 2019 17:20:43 +0200 Subject: Warehouse: link warehouse to an organization - manage address dependencies --- archaeological_warehouse/wizards.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'archaeological_warehouse/wizards.py') diff --git a/archaeological_warehouse/wizards.py b/archaeological_warehouse/wizards.py index 3d762ceb6..7476eb2b7 100644 --- a/archaeological_warehouse/wizards.py +++ b/archaeological_warehouse/wizards.py @@ -76,6 +76,19 @@ class WarehouseWizard(Wizard): model = models.Warehouse wizard_done_window = reverse_lazy('show-warehouse') + def save_model(self, dct, m2m, whole_associated_models, form_list, + return_object): + create_organization = False + if 'create_organization' in dct: + create_organization = dct.pop('create_organization') + obj, res = super(WarehouseWizard, self).save_model( + dct, m2m, whole_associated_models, form_list, True + ) + if self.modification or not create_organization: + return return_object and (obj, res) or res + obj.create_attached_organization() + return return_object and (obj, res) or res + class WarehouseModificationWizard(Wizard): model = models.Warehouse -- cgit v1.2.3