Prevent accumulation of tax rates when copying events

This commit is contained in:
Raphael Michel
2019-01-21 10:43:27 +01:00
parent 5c030796d7
commit d482bc9de0
3 changed files with 77 additions and 6 deletions

View File

@@ -543,6 +543,7 @@ class Event(EventMixin, LoggedModel):
else:
s.save()
self.settings.flush()
event_copy_data.send(
sender=self, other=other,
tax_map=tax_map, category_map=category_map, item_map=item_map, variation_map=variation_map,

View File

@@ -176,12 +176,6 @@ class EventWizard(SessionWizardView):
active=True
)
if basics_data['tax_rate']:
event.settings.tax_rate_default = event.tax_rules.create(
name=LazyI18nString.from_gettext(ugettext('VAT')),
rate=basics_data['tax_rate']
)
logdata = {}
for f in form_list:
logdata.update({
@@ -204,6 +198,13 @@ class EventWizard(SessionWizardView):
all_products=True
)
if basics_data['tax_rate']:
if not event.settings.tax_rate_default or event.settings.tax_rate_default.rate != basics_data['tax_rate']:
event.settings.tax_rate_default = event.tax_rules.create(
name=LazyI18nString.from_gettext(ugettext('VAT')),
rate=basics_data['tax_rate']
)
event.settings.set('timezone', basics_data['timezone'])
event.settings.set('locale', basics_data['locale'])
event.settings.set('locales', foundation_data['locales'])