From 680ee310ae40fa4f728ba05186a90df09e150d1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adri=C3=A1n=20Bernardi?= Date: Thu, 25 Nov 2021 16:40:49 -0300 Subject: [PATCH] lims_project_implementation: add project professionals --- lims_project_implementation/__init__.py | 1 + lims_project_implementation/locale/es.po | 24 +++++++++++++ lims_project_implementation/project.py | 36 +++++++++++++++++-- lims_project_implementation/project.xml | 13 +++++++ .../view/project_form.xml | 3 ++ .../view/project_mpi_professional_form.xml | 7 ++++ .../view/project_mpi_professional_list.xml | 5 +++ lims_project_study_plan/locale/es.po | 2 +- 8 files changed, 87 insertions(+), 4 deletions(-) create mode 100644 lims_project_implementation/view/project_mpi_professional_form.xml create mode 100644 lims_project_implementation/view/project_mpi_professional_list.xml diff --git a/lims_project_implementation/__init__.py b/lims_project_implementation/__init__.py index b1f5b30..4719a6f 100644 --- a/lims_project_implementation/__init__.py +++ b/lims_project_implementation/__init__.py @@ -11,6 +11,7 @@ def register(): Pool.register( configuration.Configuration, project.Project, + project.ProjectProfessional, project.ProjectSolventAndReagent, project.Entry, project.Fraction, diff --git a/lims_project_implementation/locale/es.po b/lims_project_implementation/locale/es.po index 539c4b1..d33f531 100644 --- a/lims_project_implementation/locale/es.po +++ b/lims_project_implementation/locale/es.po @@ -26,10 +26,26 @@ msgctxt "field:lims.project,mpi_product_types:" msgid "Product types" msgstr "Tipos de producto" +msgctxt "field:lims.project,mpi_professionals:" +msgid "Professionals" +msgstr "Profesionales" + msgctxt "field:lims.project,mpi_services:" msgid "Requested analysis" msgstr "Análisis requeridos" +msgctxt "field:lims.project.mpi_professional,employee:" +msgid "Employee" +msgstr "Empleado" + +msgctxt "field:lims.project.mpi_professional,position:" +msgid "Position" +msgstr "Posición" + +msgctxt "field:lims.project.mpi_professional,project:" +msgid "Implementation project" +msgstr "Proyecto implementación" + msgctxt "field:lims.project.solvent_reagent,purchase_date:" msgid "Purchase date" msgstr "Fecha de compra" @@ -38,6 +54,10 @@ msgctxt "model:ir.action,name:report_implementation" msgid "Implementation Projects" msgstr "Proyectos Implementación" +msgctxt "model:lims.project.mpi_professional,name:" +msgid "Project Professional" +msgstr "Profesional de proyecto" + msgctxt "report:lims.project.implementation_report:" msgid "(" msgstr "(" @@ -233,6 +253,10 @@ msgctxt "view:lims.project:" msgid "General" msgstr "General" +msgctxt "view:lims.project:" +msgid "Professionals" +msgstr "Profesionales" + msgctxt "view:lims.project:" msgid "Samples" msgstr "Muestras" diff --git a/lims_project_implementation/project.py b/lims_project_implementation/project.py index 85fa559..bc85fed 100644 --- a/lims_project_implementation/project.py +++ b/lims_project_implementation/project.py @@ -3,7 +3,7 @@ # The COPYRIGHT file at the top level of this repository contains # the full copyright notices and license terms. -from trytond.model import fields +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 @@ -23,6 +23,8 @@ class Project(metaclass=PoolMeta): mpi_methods = fields.Function(fields.Text('Methods'), 'get_mpi_methods') mpi_laboratory_date = fields.Date( 'Date of delivery of report and procedure to the laboratory',) + mpi_professionals = fields.One2Many( + 'lims.project.mpi_professional', 'project', 'Professionals') @classmethod def __setup__(cls): @@ -30,6 +32,9 @@ class Project(metaclass=PoolMeta): project_type = ('implementation', 'Implementation') if project_type not in cls.type.selection: cls.type.selection.append(project_type) + cls.external_quality_control.states['invisible'] = Bool( + Equal(Eval('type'), 'implementation')) + cls.external_quality_control.depends = ['type'] @classmethod def view_attributes(cls): @@ -74,11 +79,36 @@ class Project(metaclass=PoolMeta): return '\n'.join(s.method.name for s in services if s.method) +class ProjectProfessional(ModelSQL, ModelView): + 'Project Professional' + __name__ = 'lims.project.mpi_professional' + + project = fields.Many2One('lims.project', 'Implementation project', + ondelete='CASCADE', select=True, required=True) + employee = fields.Many2One('company.employee', 'Employee', required=True) + position = fields.Many2One('lims.project.stp_professional.position', + 'Position') + + class ProjectSolventAndReagent(metaclass=PoolMeta): __name__ = 'lims.project.solvent_reagent' purchase_date = fields.Date('Purchase date') + @fields.depends('lot') + def on_change_lot(self, name=None): + pool = Pool() + Move = pool.get('stock.move') + + if not self.lot: + return + purchases = Move.search([ + ('lot', '=', self.lot), + ('from_location.type', '=', 'supplier'), + ], order=[('effective_date', 'ASC')], limit=1) + if purchases: + self.purchase_date = purchases[0].effective_date + class Entry(metaclass=PoolMeta): __name__ = 'lims.entry' @@ -118,9 +148,9 @@ class ImplementationsReport(Report): __name__ = 'lims.project.implementation_report' @classmethod - def get_context(cls, records, data): + def get_context(cls, records, header, data): records = [r for r in records if r.type == 'implementation'] - report_context = super().get_context(records, data) + report_context = super().get_context(records, header, data) report_context['company'] = report_context['user'].company report_context['records'] = records return report_context diff --git a/lims_project_implementation/project.xml b/lims_project_implementation/project.xml index 07f9832..e3d8171 100644 --- a/lims_project_implementation/project.xml +++ b/lims_project_implementation/project.xml @@ -10,6 +10,19 @@ project_form + + + + lims.project.mpi_professional + form + project_mpi_professional_form + + + lims.project.mpi_professional + tree + project_mpi_professional_list + + diff --git a/lims_project_implementation/view/project_form.xml b/lims_project_implementation/view/project_form.xml index d686b02..3a88702 100644 --- a/lims_project_implementation/view/project_form.xml +++ b/lims_project_implementation/view/project_form.xml @@ -25,6 +25,9 @@ + + + diff --git a/lims_project_implementation/view/project_mpi_professional_form.xml b/lims_project_implementation/view/project_mpi_professional_form.xml new file mode 100644 index 0000000..b700893 --- /dev/null +++ b/lims_project_implementation/view/project_mpi_professional_form.xml @@ -0,0 +1,7 @@ + +
+