From 12955b974c1710948dee566a3455024ec247306d Mon Sep 17 00:00:00 2001 From: Adri?n Bernardi Date: Fri, 20 Sep 2019 19:15:59 -0300 Subject: [PATCH] lims_industry: brand and power in Equipment --- lims_industry/industry.py | 14 ++++++++++++++ lims_industry/locale/es.po | 8 ++++++++ lims_industry/view/equipment_form.xml | 10 +++++++--- lims_industry/view/equipment_list.xml | 4 +++- lims_industry/view/equipment_template_list.xml | 1 + lims_industry/view/plant_form.xml | 4 ++-- 6 files changed, 35 insertions(+), 6 deletions(-) diff --git a/lims_industry/industry.py b/lims_industry/industry.py index 96ae3aae..c2e19eff 100644 --- a/lims_industry/industry.py +++ b/lims_industry/industry.py @@ -129,7 +129,10 @@ class Equipment(ModelSQL, ModelView): template = fields.Many2One('lims.equipment.template', 'Template', required=True) name = fields.Char('Name', required=True) + brand = fields.Function(fields.Many2One('lims.brand', 'Brand'), + 'get_brand', searcher='search_brand') model = fields.Char('Model', required=True) + power = fields.Char('Power', required=True) serial_number = fields.Char('Serial number') internal_id = fields.Char('Internal ID Code') latitude = fields.Numeric('Latitude', digits=(3, 14)) @@ -162,21 +165,32 @@ class Equipment(ModelSQL, ModelView): def search_party(cls, name, clause): return [('plant.party',) + tuple(clause[1:])] + def get_brand(self, name): + if self.template: + return self.template.brand.id + + @classmethod + def search_brand(cls, name, clause): + return [('template.brand',) + tuple(clause[1:])] + @fields.depends('template') def on_change_template(self): pool = Pool() Component = pool.get('lims.component') model = None + power = None components = [] if self.template: model = self.template.model + power = self.template.power for type in self.template.component_types: value = Component(**Component.default_get( list(Component._fields.keys()))) value.type = type.id components.append(value) self.model = model + self.power = power self.components = components diff --git a/lims_industry/locale/es.po b/lims_industry/locale/es.po index b3c0a781..ab2bf4a7 100644 --- a/lims_industry/locale/es.po +++ b/lims_industry/locale/es.po @@ -126,6 +126,10 @@ msgctxt "field:lims.component.type,write_uid:" msgid "Write User" msgstr "Usuario modificación" +msgctxt "field:lims.equipment,brand:" +msgid "Brand" +msgstr "Marca" + msgctxt "field:lims.equipment,components:" msgid "Components" msgstr "Componentes" @@ -182,6 +186,10 @@ msgctxt "field:lims.equipment,plant:" msgid "Plant" msgstr "Planta" +msgctxt "field:lims.equipment,power:" +msgid "Power" +msgstr "Potencia" + msgctxt "field:lims.equipment,rec_name:" msgid "Record Name" msgstr "Nombre" diff --git a/lims_industry/view/equipment_form.xml b/lims_industry/view/equipment_form.xml index ea5aa586..c06d7f8d 100644 --- a/lims_industry/view/equipment_form.xml +++ b/lims_industry/view/equipment_form.xml @@ -6,12 +6,16 @@ -