diff --git a/src/servala/core/models/organization.py b/src/servala/core/models/organization.py index fe22623..2a90464 100644 --- a/src/servala/core/models/organization.py +++ b/src/servala/core/models/organization.py @@ -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): """ diff --git a/src/servala/frontend/templates/frontend/organizations/update.html b/src/servala/frontend/templates/frontend/organizations/update.html index 0d55f22..384d5a5 100644 --- a/src/servala/frontend/templates/frontend/organizations/update.html +++ b/src/servala/frontend/templates/frontend/organizations/update.html @@ -36,26 +36,105 @@ {% endpartialdef org-name-edit %} -{% block card_content %} -
- - - - - {% partial org-name %} - - - - - - -
- {% translate "Name" %} -
- {% translate "Namespace" %} - -
{{ form.instance.namespace }}
- {% translate "System-generated namespace for Kubernetes resources." %} -
-
-{% endblock card_content %} +{% block content %} +
+
+
+
+
+ + + + + {% partial org-name %} + + + + + + +
+ {% translate "Name" %} +
+ {% translate "Namespace" %} + +
{{ form.instance.namespace }}
+ {% translate "System-generated namespace for Kubernetes resources." %} +
+
+
+
+
+ {% if form.instance.billing_entity and form.instance.billing_entity.odoo_data.invoice_address %} +
+
+

{% translate "Billing Address" %}

+
+
+
+ {% with odoo_data=form.instance.billing_entity.odoo_data %} +
+ + + {% if odoo_data.invoice_address %} + + + + + + + + + + {% if odoo_data.invoice_address.street2 %} + + + + + {% endif %} + + + + + + + + + + + + + + + + + + + + {% endif %} + +
+ {% translate "Invoice Contact Name" %} + {{ odoo_data.invoice_address.name|default:"" }}
+ {% translate "Street" %} + {{ odoo_data.invoice_address.street|default:"" }}
+ {% translate "Street 2" %} + {{ odoo_data.invoice_address.street2 }}
+ {% translate "City" %} + {{ odoo_data.invoice_address.city|default:"" }}
+ {% translate "ZIP Code" %} + {{ odoo_data.invoice_address.zip|default:"" }}
+ {% translate "Country" %} + {{ odoo_data.invoice_address.country_id.1|default:"" }}
+ {% translate "VAT ID" %} + {{ odoo_data.company.vat|default:"" }}
+ {% translate "Invoice Email" %} + {{ odoo_data.invoice_address.email|default:"" }}
+
+ {% endwith %} +
+
+
+ {% endif %} +
+{% endblock content %}