forked from CGM_Public/pretix_original
Allow to only require the name in the invoice address
This commit is contained in:
@@ -45,6 +45,10 @@ DEFAULTS = {
|
|||||||
'default': 'True',
|
'default': 'True',
|
||||||
'type': bool,
|
'type': bool,
|
||||||
},
|
},
|
||||||
|
'invoice_name_required': {
|
||||||
|
'default': 'False',
|
||||||
|
'type': bool,
|
||||||
|
},
|
||||||
'invoice_address_required': {
|
'invoice_address_required': {
|
||||||
'default': 'False',
|
'default': 'False',
|
||||||
'type': bool,
|
'type': bool,
|
||||||
|
|||||||
@@ -436,6 +436,14 @@ class InvoiceSettingsForm(SettingsForm):
|
|||||||
required=False,
|
required=False,
|
||||||
widget=forms.CheckboxInput(attrs={'data-checkbox-dependency': '#id_invoice_address_asked'}),
|
widget=forms.CheckboxInput(attrs={'data-checkbox-dependency': '#id_invoice_address_asked'}),
|
||||||
)
|
)
|
||||||
|
invoice_name_required = forms.BooleanField(
|
||||||
|
label=_("Require customer name"),
|
||||||
|
required=False,
|
||||||
|
widget=forms.CheckboxInput(
|
||||||
|
attrs={'data-checkbox-dependency': '#id_invoice_address_asked',
|
||||||
|
'data-inverse-dependency': '#id_invoice_address_required'}
|
||||||
|
),
|
||||||
|
)
|
||||||
invoice_address_vatid = forms.BooleanField(
|
invoice_address_vatid = forms.BooleanField(
|
||||||
label=_("Ask for VAT ID"),
|
label=_("Ask for VAT ID"),
|
||||||
help_text=_("Does only work if an invoice address is asked for. VAT ID is not required."),
|
help_text=_("Does only work if an invoice address is asked for. VAT ID is not required."),
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
<legend>{% trans "Invoicing" %}</legend>
|
<legend>{% trans "Invoicing" %}</legend>
|
||||||
{% bootstrap_field form.invoice_address_asked layout="horizontal" %}
|
{% bootstrap_field form.invoice_address_asked layout="horizontal" %}
|
||||||
{% bootstrap_field form.invoice_address_required layout="horizontal" %}
|
{% bootstrap_field form.invoice_address_required layout="horizontal" %}
|
||||||
|
{% bootstrap_field form.invoice_name_required layout="horizontal" %}
|
||||||
{% bootstrap_field form.invoice_address_vatid layout="horizontal" %}
|
{% bootstrap_field form.invoice_address_vatid layout="horizontal" %}
|
||||||
{% bootstrap_field form.invoice_numbers_consecutive layout="horizontal" %}
|
{% bootstrap_field form.invoice_numbers_consecutive layout="horizontal" %}
|
||||||
{% bootstrap_field form.invoice_numbers_prefix layout="horizontal" %}
|
{% bootstrap_field form.invoice_numbers_prefix layout="horizontal" %}
|
||||||
|
|||||||
@@ -84,9 +84,8 @@ class InvoiceAddressForm(forms.ModelForm):
|
|||||||
'is_business': BusinessBooleanRadio,
|
'is_business': BusinessBooleanRadio,
|
||||||
'street': forms.Textarea(attrs={'rows': 2, 'placeholder': _('Street and Number')}),
|
'street': forms.Textarea(attrs={'rows': 2, 'placeholder': _('Street and Number')}),
|
||||||
'company': forms.TextInput(attrs={'data-typocheck-source': '1',
|
'company': forms.TextInput(attrs={'data-typocheck-source': '1',
|
||||||
'data-display-dependency': '#id_is_business_1',
|
'data-display-dependency': '#id_is_business_1'}),
|
||||||
'data-required-if': '#id_is_business_1'}),
|
'name': forms.TextInput(attrs={'data-typocheck-source': '1'}),
|
||||||
'name': forms.TextInput(attrs={'data-typocheck-source': '1', 'data-required-if': '#id_is_business_0'}),
|
|
||||||
'vat_id': forms.TextInput(attrs={'data-display-dependency': '#id_is_business_1'}),
|
'vat_id': forms.TextInput(attrs={'data-display-dependency': '#id_is_business_1'}),
|
||||||
}
|
}
|
||||||
labels = {
|
labels = {
|
||||||
@@ -105,6 +104,12 @@ class InvoiceAddressForm(forms.ModelForm):
|
|||||||
if 'required' in f.widget.attrs:
|
if 'required' in f.widget.attrs:
|
||||||
del f.widget.attrs['required']
|
del f.widget.attrs['required']
|
||||||
|
|
||||||
|
if event.settings.invoice_name_required:
|
||||||
|
self.fields['name'].required = True
|
||||||
|
else:
|
||||||
|
self.fields['company'].widget.attrs['data-required-if'] = '#id_is_business_1'
|
||||||
|
self.fields['name'].widget.attrs['data-required-if'] = '#id_is_business_0'
|
||||||
|
|
||||||
def clean(self):
|
def clean(self):
|
||||||
data = self.cleaned_data
|
data = self.cleaned_data
|
||||||
if not data['name'] and not data['company'] and self.event.settings.invoice_address_required:
|
if not data['name'] and not data['company'] and self.event.settings.invoice_address_required:
|
||||||
|
|||||||
@@ -32,8 +32,8 @@
|
|||||||
<div class="panel panel-default">
|
<div class="panel panel-default">
|
||||||
<div class="panel-heading">
|
<div class="panel-heading">
|
||||||
<h4 class="panel-title">
|
<h4 class="panel-title">
|
||||||
<a class="{% if not event.settings.invoice_address_required %} collapsed {% endif %}" data-toggle="collapse" href="#invoice">
|
<a class="{% if not event.settings.invoice_address_required and not event.settings.invoice_name_required %} collapsed{% endif %}" data-toggle="collapse" href="#invoice">
|
||||||
<strong>{% trans "Invoice information" %}{% if not event.settings.invoice_address_required %}
|
<strong>{% trans "Invoice information" %}{% if not event.settings.invoice_address_required and not event.settings.invoice_name_required %}
|
||||||
{% trans "(optional)" %}
|
{% trans "(optional)" %}
|
||||||
{% endif %}</strong>
|
{% endif %}</strong>
|
||||||
|
|
||||||
@@ -41,7 +41,7 @@
|
|||||||
</a>
|
</a>
|
||||||
</h4>
|
</h4>
|
||||||
</div>
|
</div>
|
||||||
<div id="invoice" class="panel-collapse collapse {% if event.settings.invoice_address_required %} in {% endif %}">
|
<div id="invoice" class="panel-collapse collapse{% if event.settings.invoice_address_required or event.settings.invoice_name_required %} in {% endif %}">
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
{% bootstrap_form invoice_form layout="horizontal" %}
|
{% bootstrap_form invoice_form layout="horizontal" %}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user