Read-only billing address

ref #246
This commit is contained in:
Tobias Kunze 2025-11-07 11:21:40 +01:00
parent 21102f30c7
commit cbdbc253e8
3 changed files with 95 additions and 62 deletions

View file

@ -86,7 +86,13 @@ class BillingEntityAdmin(admin.ModelAdmin):
@admin.register(OrganizationOrigin) @admin.register(OrganizationOrigin)
class OrganizationOriginAdmin(admin.ModelAdmin): class OrganizationOriginAdmin(admin.ModelAdmin):
list_display = ("name", "billing_entity", "default_odoo_sale_order_id") list_display = (
"name",
"billing_entity",
"default_odoo_sale_order_id",
"hide_billing_address",
)
list_filter = ("hide_billing_address",)
search_fields = ("name",) search_fields = ("name",)
autocomplete_fields = ("billing_entity",) autocomplete_fields = ("billing_entity",)
filter_horizontal = ("limit_cloudproviders",) filter_horizontal = ("limit_cloudproviders",)

View file

@ -419,6 +419,20 @@ class OrganizationOrigin(ServalaModelMixin, models.Model):
"If set, this sale order will be used for new organizations with this origin." "If set, this sale order will be used for new organizations with this origin."
), ),
) )
hide_billing_address = models.BooleanField(
default=False,
verbose_name=_("Hide Billing Address"),
help_text=_(
"If enabled, the billing address will not be shown in the organization details view."
),
)
billing_message = models.TextField(
blank=True,
verbose_name=_("Billing Message"),
help_text=_(
"Optional message to display instead of billing address (e.g., 'You will be invoiced by Exoscale')."
),
)
class Meta: class Meta:
verbose_name = _("Organization origin") verbose_name = _("Organization origin")

View file

@ -156,72 +156,85 @@
</div> </div>
</div> </div>
</div> </div>
{% if form.instance.billing_entity and form.instance.billing_entity.odoo_data.invoice_address %} {% if not form.instance.origin.hide_billing_address %}
{% if form.instance.billing_entity and form.instance.billing_entity.odoo_data.invoice_address %}
<div class="card">
<div class="card-header">
<h4 class="card-title">{% translate "Billing Address" %}</h4>
{% if form.instance.has_inherited_billing_entity %}
<p class="text-muted">
<small>{% translate "This billing address cannot be modified." %}</small>
</p>
{% endif %}
</div>
<div class="card-content">
<div class="card-body">
{% with odoo_data=form.instance.billing_entity.odoo_data %}
<div class="table-responsive">
<table class="table table-lg">
<tbody>
{% if odoo_data.invoice_address %}
<tr>
<th class="w-25">
<span class="d-flex mt-2">{% translate "Invoice Contact Name" %}</span>
</th>
<td>{{ odoo_data.invoice_address.name|default:"" }}</td>
</tr>
<tr>
<tr>
<th class="w-25">
<span class="d-flex mt-2">{% translate "Street" %}</span>
</th>
<td>{{ odoo_data.invoice_address.street|default:"" }}</td>
</tr>
{% if odoo_data.invoice_address.street2 %}
<tr>
<th class="w-25">
<span class="d-flex mt-2">{% translate "Street 2" %}</span>
</th>
<td>{{ odoo_data.invoice_address.street2 }}</td>
</tr>
{% endif %}
<tr>
<th class="w-25">
<span class="d-flex mt-2">{% translate "City" %}</span>
</th>
<td>{{ odoo_data.invoice_address.city|default:"" }}</td>
</tr>
<tr>
<th class="w-25">
<span class="d-flex mt-2">{% translate "ZIP Code" %}</span>
</th>
<td>{{ odoo_data.invoice_address.zip|default:"" }}</td>
</tr>
<tr>
<th class="w-25">
<span class="d-flex mt-2">{% translate "Country" %}</span>
</th>
<td>{{ odoo_data.invoice_address.country_id.1|default:"" }}</td>
</tr>
<th class="w-25">
<span class="d-flex mt-2">{% translate "Invoice Email" %}</span>
</th>
<td>{{ odoo_data.invoice_address.email|default:"" }}</td>
</tr>
{% endif %}
</tbody>
</table>
</div>
{% endwith %}
</div>
</div>
</div>
{% endif %}
{% elif form.instance.origin.billing_message %}
<div class="card"> <div class="card">
<div class="card-header"> <div class="card-header">
<h4 class="card-title">{% translate "Billing Address" %}</h4> <h4 class="card-title">{% translate "Billing Information" %}</h4>
{% if form.instance.has_inherited_billing_entity %}
<p class="text-muted">
<small>{% translate "This billing address cannot be modified." %}</small>
</p>
{% endif %}
</div> </div>
<div class="card-content"> <div class="card-content">
<div class="card-body"> <div class="card-body">
{% with odoo_data=form.instance.billing_entity.odoo_data %} <p>{{ form.instance.origin.billing_message }}</p>
<div class="table-responsive">
<table class="table table-lg">
<tbody>
{% if odoo_data.invoice_address %}
<tr>
<th class="w-25">
<span class="d-flex mt-2">{% translate "Invoice Contact Name" %}</span>
</th>
<td>{{ odoo_data.invoice_address.name|default:"" }}</td>
</tr>
<tr>
<tr>
<th class="w-25">
<span class="d-flex mt-2">{% translate "Street" %}</span>
</th>
<td>{{ odoo_data.invoice_address.street|default:"" }}</td>
</tr>
{% if odoo_data.invoice_address.street2 %}
<tr>
<th class="w-25">
<span class="d-flex mt-2">{% translate "Street 2" %}</span>
</th>
<td>{{ odoo_data.invoice_address.street2 }}</td>
</tr>
{% endif %}
<tr>
<th class="w-25">
<span class="d-flex mt-2">{% translate "City" %}</span>
</th>
<td>{{ odoo_data.invoice_address.city|default:"" }}</td>
</tr>
<tr>
<th class="w-25">
<span class="d-flex mt-2">{% translate "ZIP Code" %}</span>
</th>
<td>{{ odoo_data.invoice_address.zip|default:"" }}</td>
</tr>
<tr>
<th class="w-25">
<span class="d-flex mt-2">{% translate "Country" %}</span>
</th>
<td>{{ odoo_data.invoice_address.country_id.1|default:"" }}</td>
</tr>
<th class="w-25">
<span class="d-flex mt-2">{% translate "Invoice Email" %}</span>
</th>
<td>{{ odoo_data.invoice_address.email|default:"" }}</td>
</tr>
{% endif %}
</tbody>
</table>
</div>
{% endwith %}
</div> </div>
</div> </div>
</div> </div>