added category to ows.machine model, green, yellow, red
This commit is contained in:
parent
a1eb146137
commit
416aa00109
|
|
@ -17,6 +17,9 @@
|
||||||
],
|
],
|
||||||
'installable': True,
|
'installable': True,
|
||||||
'assets': {
|
'assets': {
|
||||||
|
'web.assets_backend': [
|
||||||
|
'open_workshop/static/src/css/category_color.css',
|
||||||
|
],
|
||||||
'point_of_sale._assets_pos': [
|
'point_of_sale._assets_pos': [
|
||||||
|
|
||||||
'open_workshop/static/src/js/product_screen_template_patch.js',
|
'open_workshop/static/src/js/product_screen_template_patch.js',
|
||||||
|
|
|
||||||
|
|
@ -437,13 +437,34 @@ class OwsMachine(models.Model):
|
||||||
|
|
||||||
name = fields.Char(required=True, translate=True)
|
name = fields.Char(required=True, translate=True)
|
||||||
code = fields.Char(required=True, help="Eindeutiger Kurzcode, z.B. 'lasercutter'")
|
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()
|
description = fields.Text()
|
||||||
active = fields.Boolean(default=True)
|
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_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_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')
|
@api.depends('product_ids.product_id.name')
|
||||||
def _compute_product_using_names(self):
|
def _compute_product_using_names(self):
|
||||||
|
|
@ -493,7 +514,7 @@ class OwsMachine(models.Model):
|
||||||
|
|
||||||
access_by_area = []
|
access_by_area = []
|
||||||
for area in areas:
|
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 = []
|
machine_list = []
|
||||||
for machine in machines:
|
for machine in machines:
|
||||||
has_access = bool(self.env['ows.machine.access'].search([
|
has_access = bool(self.env['ows.machine.access'].search([
|
||||||
|
|
|
||||||
9
static/src/css/category_color.css
Normal file
9
static/src/css/category_color.css
Normal file
|
|
@ -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;
|
||||||
|
}
|
||||||
|
|
@ -6,30 +6,35 @@
|
||||||
<field name="model">ows.machine</field>
|
<field name="model">ows.machine</field>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<tree>
|
<tree>
|
||||||
|
<field name="category_icon" string="⚙" readonly="1"/>
|
||||||
<field name="name"/>
|
<field name="name"/>
|
||||||
|
<field name="category"/>
|
||||||
<field name="code"/>
|
<field name="code"/>
|
||||||
<field name="area_id" widget="many2one_color"/>
|
<field name="area_id" widget="many2one_color"/>
|
||||||
<field name="product_names"/>
|
<field name="product_names"/>
|
||||||
<field name="training_names"/>
|
<field name="training_names"/>
|
||||||
<field name="active"/>
|
<field name="active"/>
|
||||||
|
|
||||||
</tree>
|
</tree>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<!-- Maschinen Formularansicht -->
|
<!-- Maschinen Formularansicht -->
|
||||||
<record id="view_machine_form" model="ir.ui.view">
|
<record id="view_machine_form" model="ir.ui.view">
|
||||||
<field name="name">ows.machine.form</field>
|
<field name="name">ows.machine.form</field>
|
||||||
<field name="model">ows.machine</field>
|
<field name="model">ows.machine</field>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<form string="Maschine">
|
<form string="Maschine">
|
||||||
<sheet>
|
<sheet>
|
||||||
<group>
|
<group>
|
||||||
<field name="name"/>
|
<field name="category_icon" string="⚙" readonly="1"/>
|
||||||
<field name="code"/>
|
<field name="name"/>
|
||||||
<field name="area_id"/>
|
<field name="category"/>
|
||||||
<field name="description"/>
|
<field name="code"/>
|
||||||
<field name="active"/>
|
<field name="area_id"/>
|
||||||
</group>
|
<field name="description"/>
|
||||||
|
<field name="active"/>
|
||||||
|
</group>
|
||||||
|
|
||||||
<!-- Neue -->
|
<!-- Neue -->
|
||||||
<notebook>
|
<notebook>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user