mirror of
https://github.com/Kalenis/kalenislims.git
synced 2023-12-14 07:13:04 +01:00
lims_industry: add type to equipment
This commit is contained in:
parent
c17273f36d
commit
611dd515ec
|
@ -181,6 +181,8 @@ class Equipment(ModelSQL, ModelView):
|
|||
template = fields.Many2One('lims.equipment.template', 'Template',
|
||||
required=True)
|
||||
name = fields.Char('Name', required=True)
|
||||
type = fields.Function(fields.Many2One('lims.equipment.type', 'Type'),
|
||||
'get_type', searcher='search_type')
|
||||
brand = fields.Function(fields.Many2One('lims.brand', 'Brand'),
|
||||
'get_brand', searcher='search_brand')
|
||||
model = fields.Char('Model', required=True)
|
||||
|
@ -259,6 +261,21 @@ class Equipment(ModelSQL, ModelView):
|
|||
def search_party(cls, name, clause):
|
||||
return [('plant.party',) + tuple(clause[1:])]
|
||||
|
||||
@fields.depends('template', '_parent_template.type')
|
||||
def on_change_with_type(self, name=None):
|
||||
return self.get_type([self], name)[self.id]
|
||||
|
||||
@classmethod
|
||||
def get_type(cls, equipments, name):
|
||||
result = {}
|
||||
for e in equipments:
|
||||
result[e.id] = e.template and e.template.type.id or None
|
||||
return result
|
||||
|
||||
@classmethod
|
||||
def search_type(cls, name, clause):
|
||||
return [('template.type',) + tuple(clause[1:])]
|
||||
|
||||
@fields.depends('template', '_parent_template.brand')
|
||||
def on_change_with_brand(self, name=None):
|
||||
return self.get_brand([self], name)[self.id]
|
||||
|
|
|
@ -246,6 +246,10 @@ msgctxt "field:lims.equipment,template:"
|
|||
msgid "Template"
|
||||
msgstr "Plantilla"
|
||||
|
||||
msgctxt "field:lims.equipment,type:"
|
||||
msgid "Type"
|
||||
msgstr "Tipo"
|
||||
|
||||
msgctxt "field:lims.equipment,voltage:"
|
||||
msgid "Voltage"
|
||||
msgstr "Tensión"
|
||||
|
|
|
@ -10,6 +10,8 @@
|
|||
<field name="plant"/>
|
||||
<label name="party"/>
|
||||
<field name="party"/>
|
||||
<label name="type"/>
|
||||
<field name="type"/>
|
||||
<label name="brand"/>
|
||||
<field name="brand"/>
|
||||
<label name="model"/>
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<?xml version="1.0"?>
|
||||
<tree>
|
||||
<field name="name" expand="1"/>
|
||||
<field name="type" expand="1"/>
|
||||
<field name="brand" expand="1"/>
|
||||
<field name="model" expand="1"/>
|
||||
<field name="power"/>
|
||||
|
|
Loading…
Reference in a new issue