diff --git a/lims_industry/industry.py b/lims_industry/industry.py index 8a00b91d..ad8e97a0 100644 --- a/lims_industry/industry.py +++ b/lims_industry/industry.py @@ -210,6 +210,8 @@ class Component(ModelSQL, ModelView): internal_id = fields.Char('Internal ID Code') customer_description = fields.Char('Customer description') year_manufacturing = fields.Integer('Year of manufacturing') + plant = fields.Function(fields.Many2One('lims.plant', 'Plant'), + 'get_plant', searcher='search_plant') party = fields.Function(fields.Many2One('party.party', 'Party'), 'get_party', searcher='search_party') @@ -227,6 +229,14 @@ class Component(ModelSQL, ModelView): res += ' - ' + self.model return res + def get_plant(self, name): + if self.equipment: + return self.equipment.plant.id + + @classmethod + def search_plant(cls, name, clause): + return [('equipment.plant',) + tuple(clause[1:])] + def get_party(self, name): if self.equipment: return self.equipment.plant.party.id diff --git a/lims_industry/locale/es.po b/lims_industry/locale/es.po index ab2bf4a7..b1d0e847 100644 --- a/lims_industry/locale/es.po +++ b/lims_industry/locale/es.po @@ -70,6 +70,10 @@ msgctxt "field:lims.component,party:" msgid "Party" msgstr "Tercero" +msgctxt "field:lims.component,plant:" +msgid "Plant" +msgstr "Planta" + msgctxt "field:lims.component,power:" msgid "Power" msgstr "Potencia" diff --git a/lims_industry/view/component_form.xml b/lims_industry/view/component_form.xml index 6742f57b..b9774f82 100644 --- a/lims_industry/view/component_form.xml +++ b/lims_industry/view/component_form.xml @@ -4,6 +4,10 @@