diff --git a/models/ows_models.py b/models/ows_models.py
index 0c595e0..e6b9a6c 100644
--- a/models/ows_models.py
+++ b/models/ows_models.py
@@ -15,13 +15,25 @@ class ResPartner(models.Model):
@api.depends('machine_access_ids')
def _compute_machine_access_html(self):
+ """
+ Computes an HTML representation of the machine access permissions for each partner.
+ The HTML is structured as a grid of machine areas, where each area contains a table
+ listing the machines and whether the partner has access to them.
+
+ - Iterates through all machine areas and their associated machines.
+ - Checks if the partner has access to each machine.
+ - Generates an HTML table with a checkmark or cross icon for each machine access status.
+ - Assigns the generated HTML to the `machine_access_html` field of the partner.
+ """
for partner in self:
areas = self.env['ows.machine.area'].search([], order="name")
- html = "
"
+ html = """
+
+ """
for area in areas:
html += f"
"
html += f"
"
- html += f"
{area.name}
"
+ html += f"
{area.name}
Datum
Gültig bis
"
machines = self.env['ows.machine'].search([('area_id', '=', area.id)], order="name")
for machine in machines:
access = self.env['ows.machine.access'].search([
@@ -29,17 +41,20 @@ class ResPartner(models.Model):
('machine_id', '=', machine.id),
], limit=1)
icon = "" if access else ""
- html += """
+ date_granted = access.date_granted.strftime('%Y-%m-%d') if access and access.date_granted else ""
+ date_expiry = access.date_expiry.strftime('%Y-%m-%d') if access and access.date_expiry else ""
+ html += f"""