From 6fef39f779e56b862a21d748124483a30796344f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adri=C3=A1n=20Bernardi?= Date: Mon, 22 Aug 2022 19:59:59 -0300 Subject: [PATCH] lims_project_implementation: change supplies domain --- lims_project_implementation/locale/es.po | 4 +++ lims_project_implementation/project.py | 27 +++++++++++++++++++ .../view/project_form.xml | 2 +- 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/lims_project_implementation/locale/es.po b/lims_project_implementation/locale/es.po index d33f531..e67436a 100644 --- a/lims_project_implementation/locale/es.po +++ b/lims_project_implementation/locale/es.po @@ -46,6 +46,10 @@ msgctxt "field:lims.project.mpi_professional,project:" msgid "Implementation project" msgstr "Proyecto implementación" +msgctxt "field:lims.project.solvent_reagent,product:" +msgid "Supply" +msgstr "Insumo" + msgctxt "field:lims.project.solvent_reagent,purchase_date:" msgid "Purchase date" msgstr "Fecha de compra" diff --git a/lims_project_implementation/project.py b/lims_project_implementation/project.py index bc85fed..0339a1b 100644 --- a/lims_project_implementation/project.py +++ b/lims_project_implementation/project.py @@ -7,6 +7,7 @@ from trytond.model import ModelSQL, ModelView, fields from trytond.report import Report from trytond.pool import PoolMeta, Pool from trytond.pyson import Eval, Equal, Bool, Not +from trytond.transaction import Transaction class Project(metaclass=PoolMeta): @@ -35,6 +36,8 @@ class Project(metaclass=PoolMeta): cls.external_quality_control.states['invisible'] = Bool( Equal(Eval('type'), 'implementation')) cls.external_quality_control.depends = ['type'] + cls.stp_solvents_and_reagents.context = {'project_type': Eval('type')} + cls.stp_solvents_and_reagents.depends = ['type', 'stp_state'] @classmethod def view_attributes(cls): @@ -95,6 +98,30 @@ class ProjectSolventAndReagent(metaclass=PoolMeta): purchase_date = fields.Date('Purchase date') + @classmethod + def __setup__(cls): + super().__setup__() + cls.product.string = 'Supply' + + @staticmethod + def default_solvent_reagent_domain(): + pool = Pool() + Config = pool.get('lims.configuration') + Category = pool.get('product.category') + if Transaction().context.get('project_type', '') == 'implementation': + return [c.id for c in Category.search([])] + config = Config(1) + return config.get_solvents() + config.get_reagents() + + def get_solvent_reagent_domain(self, name=None): + pool = Pool() + Config = pool.get('lims.configuration') + Category = pool.get('product.category') + if self.project.type == 'implementation': + return [c.id for c in Category.search([])] + config = Config(1) + return config.get_solvents() + config.get_reagents() + @fields.depends('lot') def on_change_lot(self, name=None): pool = Pool() diff --git a/lims_project_implementation/view/project_form.xml b/lims_project_implementation/view/project_form.xml index 3a88702..3a9824f 100644 --- a/lims_project_implementation/view/project_form.xml +++ b/lims_project_implementation/view/project_form.xml @@ -33,7 +33,7 @@ view_ids="lims_project_study_plan.lims_sample_view_list,lims_project_study_plan.lims_sample_view_form"/> -