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"" + html += f"" 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""" - - + + + + - """.format(machine.name, icon) + """ html += "
{area.name}
{area.name}DatumGültig bis
{}{icon}{date_granted}{date_expiry}
" html += "
" partner.machine_access_html = html - class OwsMachineArea(models.Model): _name = 'ows.machine.area' _table = "ows_machine_area" @@ -63,6 +78,10 @@ class OwsMachine(models.Model): area_id = fields.Many2one('ows.machine.area', string='Bereich') + product_ids = fields.One2many('ows.machine.product', 'machine_id', string="Einweisungsprodukte") + + + _sql_constraints = [ ('code_unique', 'unique(code)', 'Maschinencode muss eindeutig sein.') ] diff --git a/static/src/css/pos.css b/static/src/css/pos.css index f5a32f2..7d66d73 100644 --- a/static/src/css/pos.css +++ b/static/src/css/pos.css @@ -1675,6 +1675,13 @@ td { transition: all 150ms linear; background: rgb(227, 246, 237); } + +.pos .clientlist-screen .client-details-grid { + display: grid; + grid-template-columns: repeat(2, 1fr); + gap: 0px; +} + .pos .clientlist-screen .client-details{ padding: 16px; border-bottom: solid 5px rgb(110,200,155); @@ -1782,7 +1789,7 @@ td { .pos .clientlist-screen .client-detail > .briefinglabel{ font-weight: bold; display: inline-block; - width: 250px; + text-align: right; margin-right: 8px; } diff --git a/static/src/xml/partner_access_popup.xml b/static/src/xml/partner_access_popup.xml index 7356568..e238b08 100644 --- a/static/src/xml/partner_access_popup.xml +++ b/static/src/xml/partner_access_popup.xml @@ -1,18 +1,24 @@ +
-
    - - - -
    + + + + + + + +
+
+ diff --git a/views/partner_machine_access_html.xml b/views/partner_machine_access_html.xml index 880f097..8ea8aa9 100644 --- a/views/partner_machine_access_html.xml +++ b/views/partner_machine_access_html.xml @@ -7,7 +7,7 @@ - + diff --git a/views/res_partner_view.xml b/views/res_partner_view.xml index ad3292c..2d191a3 100644 --- a/views/res_partner_view.xml +++ b/views/res_partner_view.xml @@ -6,7 +6,7 @@ - +