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"/> - - + - - +