From 1b203eeb1081ce5ae5f4375ab441588bcdf07af2 Mon Sep 17 00:00:00 2001 From: "matthias.lotz" Date: Sat, 13 Dec 2025 17:43:07 +0100 Subject: [PATCH] feat(equipment-view): Integrate OWS into Maintenance menu with Equipment-centric views MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Extended maintenance.equipment model with Related fields to ows.machine - ows_machine_id: One2many inverse relation - ows_category: Related to machine category (editable, stored) - ows_area_id: Related to machine area (editable, stored) - ows_product_ids: Related One2many for usage products - ows_training_ids: Related One2many for training products - Equipment Form View Extensions: - Added ows_area_id and ows_category after location field - New 'Offene Werkstatt (Hobbyhimmel)' notebook page with: - Security section (category icon, category, area) - Usage products section (Nutzungsprodukte) - Training products section (Einweisungsprodukte) - Page visibility controlled by ows_machine_id existence - Equipment List/Search View Extensions: - Added ows_category_icon and ows_area_id columns - Added OWS search fields (area, category) - Added category filters (green/yellow/red) - Added OWS grouping options (by area, by category) - Menu Structure Migration: - Removed standalone 'Ausrüstung' top-level menu - Integrated all OWS config into Maintenance → Configuration: - Bereiche (Areas) - Zuordnungen (Assignments) container - Nutzungsprodukte (Usage Products) - Einweisungsprodukte (Training Products) - Created simplified tree views for Equipment context: - view_ows_machine_product_tree_simple (no machine_id column) - view_ows_machine_training_tree_simple (no machine_id column) - Freed location field from automatic area synchronization: - Removed area → location mapping in create()/write() - location now available for detailed physical location info - ows_area_id provides workspace area assignment BREAKING CHANGE: Standalone OWS menu removed, all features now in Maintenance app UX IMPROVEMENT: Single Equipment view shows all data, no split views needed --- open_workshop_base/models/ows_models.py | 60 +++++++++++---- .../views/machine_area_views.xml | 3 - .../views/machine_product_training_views.xml | 26 ++++++- .../views/maintenance_equipment_views.xml | 77 +++++++++++++++++-- open_workshop_base/views/menu_views.xml | 58 +++++++------- 5 files changed, 167 insertions(+), 57 deletions(-) diff --git a/open_workshop_base/models/ows_models.py b/open_workshop_base/models/ows_models.py index 4724705..93e88f5 100644 --- a/open_workshop_base/models/ows_models.py +++ b/open_workshop_base/models/ows_models.py @@ -400,6 +400,51 @@ AVAILABLE_COLORS = [ ('#ffffff', 'Weiss'), ] +class OwsMachineArea(models.Model): + _name = 'ows.machine.area' + _table = 'ows_machine_area' + _description = 'OWS: Maschinenbereich' + + +class MaintenanceEquipment(models.Model): + """Erweitere maintenance.equipment mit OWS-Feldern für direkte Bearbeitung""" + _inherit = 'maintenance.equipment' + + # Inverse Relation zu ows.machine + ows_machine_id = fields.One2many('ows.machine', 'equipment_id', string='OWS Maschine', readonly=True) + + # OWS-Felder direkt auf Equipment (via related für einfache Bearbeitung) + ows_category = fields.Selection( + related='ows_machine_id.category', + string='Sicherheitskategorie', + readonly=False, + store=True + ) + ows_category_icon = fields.Char( + related='ows_machine_id.category_icon', + string='⚙' + ) + ows_area_id = fields.Many2one( + 'ows.machine.area', + related='ows_machine_id.area_id', + string='Bereich', + readonly=False, + store=True + ) + ows_product_ids = fields.One2many( + 'ows.machine.product', + related='ows_machine_id.product_ids', + string='Nutzungsprodukte', + readonly=False + ) + ows_training_ids = fields.One2many( + 'ows.machine.training', + related='ows_machine_id.training_ids', + string='Einweisungsprodukte', + readonly=False + ) + + class OwsMachineArea(models.Model): _name = 'ows.machine.area' _table = 'ows_machine_area' @@ -527,12 +572,6 @@ class OwsMachine(models.Model): 'serial_no': vals.get('serial_no', False), } - # Area → Location Mapping für Equipment - if 'area_id' in vals and vals['area_id']: - area = self.env['ows.machine.area'].browse(vals['area_id']) - if area and area.name: - equipment_vals['location'] = area.name - equipment = self.env['maintenance.equipment'].create(equipment_vals) vals['equipment_id'] = equipment.id @@ -541,15 +580,8 @@ class OwsMachine(models.Model): def write(self, vals): """ Bei Updates: - 1. Area → Location synchronisieren - 2. Name/Serial_no → Equipment synchronisieren + 1. Name/Serial_no → Equipment synchronisieren """ - # Area → Location Mapping - if 'area_id' in vals and vals['area_id']: - area = self.env['ows.machine.area'].browse(vals['area_id']) - if area and area.name: - vals['location'] = area.name - # Name/Serial_no an Equipment weiterleiten equipment_vals = {} if 'name' in vals: diff --git a/open_workshop_base/views/machine_area_views.xml b/open_workshop_base/views/machine_area_views.xml index 1f990aa..e5b0538 100644 --- a/open_workshop_base/views/machine_area_views.xml +++ b/open_workshop_base/views/machine_area_views.xml @@ -7,9 +7,6 @@ list,form - - - ows.machine.area.tree diff --git a/open_workshop_base/views/machine_product_training_views.xml b/open_workshop_base/views/machine_product_training_views.xml index 621c9fe..e8fcd86 100644 --- a/open_workshop_base/views/machine_product_training_views.xml +++ b/open_workshop_base/views/machine_product_training_views.xml @@ -1,5 +1,5 @@ - + ows.machine.product.tree ows.machine.product @@ -10,8 +10,19 @@ + + + + ows.machine.product.tree.simple + ows.machine.product + + + + + + - + ows.machine.training.tree ows.machine.training @@ -22,6 +33,17 @@ + + + + ows.machine.training.tree.simple + ows.machine.training + + + + + + diff --git a/open_workshop_base/views/maintenance_equipment_views.xml b/open_workshop_base/views/maintenance_equipment_views.xml index 3d98456..1ac35e0 100644 --- a/open_workshop_base/views/maintenance_equipment_views.xml +++ b/open_workshop_base/views/maintenance_equipment_views.xml @@ -1,15 +1,80 @@ - - - maintenance.equipment.form.location.readonly + + + maintenance.equipment.form.ows maintenance.equipment - - 1 - Wird automatisch aus dem Bereich (ows.machine) synchronisiert. Änderungen nur über Bereich möglich. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + maintenance.equipment.tree.ows + maintenance.equipment + + + + + + + + + + + + maintenance.equipment.search.ows + maintenance.equipment + + + + + + + + + + + + + + + + + + + + + + + diff --git a/open_workshop_base/views/menu_views.xml b/open_workshop_base/views/menu_views.xml index 9df5aec..797a624 100644 --- a/open_workshop_base/views/menu_views.xml +++ b/open_workshop_base/views/menu_views.xml @@ -1,11 +1,15 @@ - - + + Ausrüstung - ows.machine + maintenance.equipment list,form - {'search_default_group_area': 1, 'group_expand': True} + [('ows_machine_id', '!=', False)] + { + 'default_ows_category': 'red', + 'search_default_group_by_area': 1 + } @@ -15,42 +19,32 @@ list,form - - - + + + + - - - - - - - - + + parent="maintenance.menu_maintenance_config" + sequence="51"/> - - + - - +