Billing Entity Management #66
2 changed files with 145 additions and 23 deletions
|
@ -192,6 +192,49 @@ class BillingEntity(ServalaModelMixin, models.Model):
|
|||
# return instance
|
||||
pass
|
||||
|
||||
@cached_property
|
||||
def odoo_data(self):
|
||||
data = {
|
||||
"company": None,
|
||||
"invoice_address": None,
|
||||
}
|
||||
|
||||
company_fields = ["name", "company_type", "vat"]
|
||||
invoice_address_fields = [
|
||||
"name",
|
||||
"company_type",
|
||||
"type",
|
||||
"parent_id",
|
||||
"street",
|
||||
"street2",
|
||||
"city",
|
||||
"zip",
|
||||
"country_id",
|
||||
"email",
|
||||
]
|
||||
|
||||
if self.odoo_company_id:
|
||||
company_records = CLIENT.search_read(
|
||||
model="res.partner",
|
||||
domain=[["id", "=", self.odoo_company_id]],
|
||||
fields=company_fields,
|
||||
limit=1,
|
||||
)
|
||||
if company_records:
|
||||
data["company"] = company_records[0]
|
||||
|
||||
if self.odoo_invoice_id:
|
||||
invoice_address_records = CLIENT.search_read(
|
||||
model="res.partner",
|
||||
domain=[["id", "=", self.odoo_invoice_id]],
|
||||
fields=invoice_address_fields,
|
||||
limit=1,
|
||||
)
|
||||
if invoice_address_records:
|
||||
data["invoice_address"] = invoice_address_records[0]
|
||||
|
||||
return data
|
||||
|
||||
|
||||
class OrganizationOrigin(ServalaModelMixin, models.Model):
|
||||
"""
|
||||
|
|
|
@ -36,26 +36,105 @@
|
|||
</form>
|
||||
</td>
|
||||
{% endpartialdef org-name-edit %}
|
||||
{% block card_content %}
|
||||
<div class="table-responsive">
|
||||
<table class="table table-lg">
|
||||
<tbody>
|
||||
<tr>
|
||||
<th class="w-25">
|
||||
<span class="d-flex mt-2">{% translate "Name" %}</span>
|
||||
</th>
|
||||
{% partial org-name %}
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="w-25">
|
||||
<span class="d-flex mt-2">{% translate "Namespace" %}</span>
|
||||
</th>
|
||||
<td>
|
||||
<div>{{ form.instance.namespace }}</div>
|
||||
<small class="text-muted">{% translate "System-generated namespace for Kubernetes resources." %}</small>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{% endblock card_content %}
|
||||
{% block content %}
|
||||
<section class="section">
|
||||
<div class="card">
|
||||
<div class="card-content">
|
||||
<div class="card-body">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-lg">
|
||||
<tbody>
|
||||
<tr>
|
||||
<th class="w-25">
|
||||
<span class="d-flex mt-2">{% translate "Name" %}</span>
|
||||
</th>
|
||||
{% partial org-name %}
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="w-25">
|
||||
<span class="d-flex mt-2">{% translate "Namespace" %}</span>
|
||||
</th>
|
||||
<td>
|
||||
<div>{{ form.instance.namespace }}</div>
|
||||
<small class="text-muted">{% translate "System-generated namespace for Kubernetes resources." %}</small>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% 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>
|
||||
</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>
|
||||
<tr>
|
||||
<th class="w-25">
|
||||
<span class="d-flex mt-2">{% translate "VAT ID" %}</span>
|
||||
</th>
|
||||
<td>{{ odoo_data.company.vat|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 %}
|
||||
</section>
|
||||
{% endblock content %}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue