diff --git a/__manifest__.py b/__manifest__.py index e0005ad..b90a5f8 100644 --- a/__manifest__.py +++ b/__manifest__.py @@ -17,6 +17,9 @@ ], 'installable': True, 'assets': { + 'web.assets_backend': [ + 'open_workshop/static/src/css/category_color.css', + ], 'point_of_sale._assets_pos': [ 'open_workshop/static/src/js/product_screen_template_patch.js', diff --git a/models/ows_models.py b/models/ows_models.py index 05d6380..9f9786f 100644 --- a/models/ows_models.py +++ b/models/ows_models.py @@ -437,13 +437,34 @@ class OwsMachine(models.Model): name = fields.Char(required=True, translate=True) code = fields.Char(required=True, help="Eindeutiger Kurzcode, z.B. 'lasercutter'") + category = fields.Selection([ + ('green', 'Kategorie 1: grün'), + ('yellow', 'Kategorie 2: gelb'), + ('red', 'Kategorie 3: rot'), + ], string="Sicherheitskategorie", required=True, default='red', help="Sicherheitsrelevante Maschinenkategorie:\n" + "- grün: keine Einweisungspflicht\n" + "- gelb: empfohlene Einweisung\n" + "- rot: Einweisung zwingend erforderlich") + + category_icon = fields.Char(string="Kategorie-Symbol", compute="_compute_category_icon", store=False) + + @api.depends('category') + def _compute_category_icon(self): + for rec in self: + icon_map = { + 'green': '🟢', + 'yellow': '🟡', + 'red': '🔴', + } + rec.category_icon = icon_map.get(rec.category, '⚪') + description = fields.Text() active = fields.Boolean(default=True) - area_id = fields.Many2one('ows.machine.area', string='Bereich') + area_id = fields.Many2one('ows.machine.area', string='Bereich', help="Bereich, in dem die Maschine oder das Gerät steht.") product_ids = fields.One2many('ows.machine.product', 'machine_id', string="Nutzungsprodukte") - product_names = fields.Char(string="Nutzungsprodukte Liste", compute="_compute_product_using_names", store=False,) + product_names = fields.Char(string="Liste der Nutzungsprodukte", compute="_compute_product_using_names", store=False,) training_ids = fields.One2many('ows.machine.training', 'machine_id', string="Einweisungsprodukte") - training_names = fields.Char(string="Einweisungsprodukte Liste", compute="_compute_product_training_names", store=False,) + training_names = fields.Char(string="Liste der Einweisungsprodukte", compute="_compute_product_training_names", store=False,) @api.depends('product_ids.product_id.name') def _compute_product_using_names(self): @@ -493,7 +514,7 @@ class OwsMachine(models.Model): access_by_area = [] for area in areas: - machines = self.search([('area_id', '=', area.id)], order="name") + machines = self.search([('area_id', '=', area.id), ('category', '=', 'red')], order="name") machine_list = [] for machine in machines: has_access = bool(self.env['ows.machine.access'].search([ diff --git a/static/src/css/category_color.css b/static/src/css/category_color.css new file mode 100644 index 0000000..154419d --- /dev/null +++ b/static/src/css/category_color.css @@ -0,0 +1,9 @@ +.category-color-circle { + display: inline-block; + width: 14px; + height: 14px; + border-radius: 50%; + margin-left: 8px; + vertical-align: middle; + border: 1px solid #444; +} diff --git a/views/machine_views.xml b/views/machine_views.xml index 287c759..e2d87ff 100644 --- a/views/machine_views.xml +++ b/views/machine_views.xml @@ -6,30 +6,35 @@ ows.machine + + + - - ows.machine.form - ows.machine - -
- - - - - - - - + + ows.machine.form + ows.machine + + + + + + + + + + + +