From 945bf4074d9a89af13ddbaca25249d765406f140 Mon Sep 17 00:00:00 2001 From: "matthias.lotz" Date: Sat, 16 May 2026 15:14:44 +0200 Subject: [PATCH] IMP: Open Workshop Base und POS, Gruppierung der Maschinen im POS nach Maschinen Namen --- open_workshop_base/models/ows_models.py | 36 ++++++++++++---- .../static/src/js/ows_machine_access_list.js | 7 ++++ .../src/xml/ows_machine_access_list.xml | 42 +++++++++++++++---- 3 files changed, 70 insertions(+), 15 deletions(-) diff --git a/open_workshop_base/models/ows_models.py b/open_workshop_base/models/ows_models.py index 193ea42..31289e1 100644 --- a/open_workshop_base/models/ows_models.py +++ b/open_workshop_base/models/ows_models.py @@ -725,17 +725,37 @@ class OwsMachine(models.Model): access_by_area = [] for area in areas: machines = self.search([('area_id', '=', area.id), ('category', '=', 'red'), ('equipment_id.status_id.name', '!=', 'Ausgemustert')], order="name") - machine_list = [] + + # Maschinen nach Namen gruppieren (gleicher Name = Gruppe) + name_groups = {} for machine in machines: - has_access = bool(self.env['ows.machine.access'].search([ - ('partner_id', '=', partner_id), - ('machine_id', '=', machine.id), - ], limit=1)) + name = machine.name + if name not in name_groups: + name_groups[name] = [] + name_groups[name].append(machine) + + machine_list = [] + for group_name, group_machines in name_groups.items(): + is_group = len(group_machines) > 1 + machine_entries = [] + for idx, machine in enumerate(group_machines): + has_access = bool(self.env['ows.machine.access'].search([ + ('partner_id', '=', partner_id), + ('machine_id', '=', machine.id), + ], limit=1)) + machine_entries.append({ + 'id': machine.id, + 'name': machine.name, + 'label': machine.model or machine.serial_no or f'#{idx + 1}', + 'has_access': has_access, + }) machine_list.append({ - 'id': machine.id, - 'name': machine.name, - 'has_access': has_access, + 'group_name': group_name, + 'is_group': is_group, + 'machines': machine_entries, + 'has_any_access': any(m['has_access'] for m in machine_entries), }) + if machine_list: access_by_area.append({ 'area': area.name, diff --git a/open_workshop_pos/static/src/js/ows_machine_access_list.js b/open_workshop_pos/static/src/js/ows_machine_access_list.js index 06532c8..b272930 100644 --- a/open_workshop_pos/static/src/js/ows_machine_access_list.js +++ b/open_workshop_pos/static/src/js/ows_machine_access_list.js @@ -19,6 +19,7 @@ export class OwsMachineAccessList extends Component { security_id: '', rfid_card: '', birthday: '', + expanded_groups: {}, }); // πŸ” Reagiere auf Partnerwechsel ΓΌber den Odoo-Bus @@ -34,6 +35,7 @@ export class OwsMachineAccessList extends Component { const order = this.pos.get_order(); const partner = order?.get_partner?.(); this.state.client = partner || null; + this.state.expanded_groups = {}; if (!partner) { this.state.grouped_accesses = []; this.state.security_briefing = false; @@ -63,6 +65,11 @@ export class OwsMachineAccessList extends Component { } } + + toggleGroup = (areaName, groupName) => { + const key = `${areaName}|${groupName}`; + this.state.expanded_groups[key] = !this.state.expanded_groups[key]; + } } diff --git a/open_workshop_pos/static/src/xml/ows_machine_access_list.xml b/open_workshop_pos/static/src/xml/ows_machine_access_list.xml index 757e490..1e498a9 100644 --- a/open_workshop_pos/static/src/xml/ows_machine_access_list.xml +++ b/open_workshop_pos/static/src/xml/ows_machine_access_list.xml @@ -59,13 +59,41 @@
    - -
  • - - - - -
  • + + + + +
  • + + + + +
  • +
    + + + +
  • + + + + + () + + +
  • + + +
  • + + + + +
  • +
    +
    +
    +