diff --git a/lims_industry/__init__.py b/lims_industry/__init__.py index 9397f31b..14e92692 100644 --- a/lims_industry/__init__.py +++ b/lims_industry/__init__.py @@ -7,8 +7,6 @@ from . import industry from . import analysis from . import sample from . import party -from . import planification -from . import configuration from . import task @@ -29,23 +27,13 @@ def register(): analysis.SampleAttributeAttributeSet, analysis.SamplingType, analysis.ProductType, - analysis.AliquotType, - analysis.AliquotTypeProductType, analysis.Analysis, sample.Entry, sample.Sample, sample.CreateSampleStart, sample.EditSampleStart, - sample.Fraction, - sample.Aliquot, party.Party, party.Address, - planification.Rack, - planification.RackPosition, - configuration.Configuration, - configuration.ConfigurationSequence, - configuration.LabWorkYear, - configuration.LabWorkYearSequence, task.AdministrativeTaskTemplate, task.AdministrativeTask, module='lims_industry', type_='model') @@ -53,6 +41,3 @@ def register(): sample.CreateSample, sample.EditSample, module='lims_industry', type_='wizard') - Pool.register( - sample.AliquotExternalReport, - module='lims_sale_industry', type_='report') diff --git a/lims_industry/analysis.py b/lims_industry/analysis.py index f8d8dacb..5d259fb7 100644 --- a/lims_industry/analysis.py +++ b/lims_industry/analysis.py @@ -4,11 +4,10 @@ from trytond.model import ModelSQL, ModelView, DictSchemaMixin, fields from trytond.pool import PoolMeta -from trytond.pyson import Eval __all__ = ['SampleAttributeSet', 'SampleAttribute', 'SampleAttributeAttributeSet', 'SamplingType', 'ProductType', - 'AliquotType', 'AliquotTypeProductType', 'Analysis'] + 'Analysis'] class SampleAttributeSet(ModelSQL, ModelView): @@ -54,54 +53,7 @@ class ProductType(metaclass=PoolMeta): 'Attribute Set') -class AliquotType(ModelSQL, ModelView): - 'Aliquot Type' - __name__ = 'lims.aliquot.type' - - name = fields.Char('Name', required=True) - code = fields.Char('Code', required=True) - ind_volume = fields.Float('Required volume') - uom = fields.Many2One('product.uom', 'UoM') - kind = fields.Selection([ - ('int', 'Internal'), - ('ext', 'External'), - ('rack', 'Rack'), - ], 'Kind', sort=False, required=True) - product_types = fields.Many2Many('lims.aliquot.type-product.type', - 'aliquot_type', 'product_type', 'Product types', - depends=['kind'], states={ - 'invisible': Eval('kind') != 'rack', - 'required': Eval('kind') == 'rack', - }) - laboratory = fields.Many2One('party.party', 'Destination Laboratory', - depends=['kind'], states={ - 'invisible': Eval('kind') != 'ext', - 'required': Eval('kind') == 'ext', - }) - preparation = fields.Boolean('Preparation', - depends=['kind'], states={ - 'invisible': Eval('kind') != 'int', - }) - - -class AliquotTypeProductType(ModelSQL): - 'Equipment Template - Component Type' - __name__ = 'lims.aliquot.type-product.type' - _table = 'lims_aliquot_type_product_type' - - aliquot_type = fields.Many2One('lims.aliquot.type', 'Aliquot type', - required=True, ondelete='CASCADE', select=True) - product_type = fields.Many2One('lims.product.type', 'Product type', - required=True, ondelete='CASCADE', select=True) - - class Analysis(metaclass=PoolMeta): __name__ = 'lims.analysis' - aliquot_type = fields.Many2One('lims.aliquot.type', 'Aliquot type') ind_volume = fields.Float('Required volume') - - @fields.depends('aliquot_type') - def on_change_aliquot_type(self): - if self.aliquot_type: - self.ind_volume = self.aliquot_type.ind_volume diff --git a/lims_industry/analysis.xml b/lims_industry/analysis.xml index 526bb5df..d945619f 100644 --- a/lims_industry/analysis.xml +++ b/lims_industry/analysis.xml @@ -109,39 +109,6 @@ product_type_form - - - - lims.aliquot.type - tree - aliquot_type_list - - - lims.aliquot.type - form - aliquot_type_form - - - - Aliquot Types - lims.aliquot.type - - - - - - - - - - - - - - @@ -149,11 +116,6 @@ analysis_form - - lims.analysis - - analysis_list - diff --git a/lims_industry/configuration.py b/lims_industry/configuration.py deleted file mode 100644 index fbc4a440..00000000 --- a/lims_industry/configuration.py +++ /dev/null @@ -1,96 +0,0 @@ -# This file is part of lims_industry module for Tryton. -# 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.pyson import Eval -from trytond.pool import Pool, PoolMeta - -__all__ = ['Configuration', 'ConfigurationSequence', 'LabWorkYear', - 'LabWorkYearSequence'] - - -class Configuration(metaclass=PoolMeta): - __name__ = 'lims.configuration' - - rack_sequence = fields.MultiValue(fields.Many2One( - 'ir.sequence', 'Rack Sequence', required=True, - domain=[ - ('company', 'in', - [Eval('context', {}).get('company', -1), None]), - ('code', '=', 'lims.planification'), - ])) - - @classmethod - def default_rack_sequence(cls, **pattern): - return cls.multivalue_model( - 'rack_sequence').default_rack_sequence() - - @classmethod - def multivalue_model(cls, field): - pool = Pool() - if field == 'rack_sequence': - return pool.get('lims.configuration.sequence') - return super(Configuration, cls).multivalue_model(field) - - -class ConfigurationSequence(metaclass=PoolMeta): - __name__ = 'lims.configuration.sequence' - - rack_sequence = fields.Many2One('ir.sequence', - 'Rack Sequence', depends=['company'], domain=[ - ('company', 'in', [Eval('company', -1), None]), - ('code', '=', 'lims.planification'), - ]) - - @classmethod - def default_rack_sequence(cls): - pool = Pool() - ModelData = pool.get('ir.model.data') - try: - return ModelData.get_id('lims.planification', 'seq_rack') - except KeyError: - return None - - -class LabWorkYear(metaclass=PoolMeta): - __name__ = 'lims.lab.workyear' - - aliquot_sequence = fields.MultiValue(fields.Many2One( - 'ir.sequence', 'Aliquot Sequence', required=True, - domain=[ - ('company', 'in', - [Eval('context', {}).get('company', -1), None]), - ('code', '=', 'lims.aliquot'), - ])) - - @classmethod - def default_aliquot_sequence(cls, **pattern): - return cls.multivalue_model( - 'aliquot_sequence').default_aliquot_sequence() - - @classmethod - def multivalue_model(cls, field): - pool = Pool() - if field == 'aliquot_sequence': - return pool.get('lims.lab.workyear.sequence') - return super(LabWorkYear, cls).multivalue_model(field) - - -class LabWorkYearSequence(metaclass=PoolMeta): - __name__ = 'lims.lab.workyear.sequence' - - aliquot_sequence = fields.Many2One('ir.sequence', - 'Aliquot Sequence', depends=['company'], domain=[ - ('company', 'in', [Eval('company', -1), None]), - ('code', '=', 'lims.aliquot'), - ]) - - @classmethod - def default_aliquot_sequence(cls): - pool = Pool() - ModelData = pool.get('ir.model.data') - try: - return ModelData.get_id('lims.aliquot', 'seq_aliquot') - except KeyError: - return None diff --git a/lims_industry/configuration.xml b/lims_industry/configuration.xml deleted file mode 100644 index a64ca228..00000000 --- a/lims_industry/configuration.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - lims.configuration - - configuration_form - - - - - - lims.lab.workyear - - workyear_form - - - lims.lab.workyear - - workyear_list - - - - diff --git a/lims_industry/locale/es.po b/lims_industry/locale/es.po index 8b26190a..8c764b2f 100644 --- a/lims_industry/locale/es.po +++ b/lims_industry/locale/es.po @@ -2,150 +2,6 @@ msgid "" msgstr "Content-Type: text/plain; charset=utf-8\n" -msgctxt "field:lims.aliquot,create_date:" -msgid "Create Date" -msgstr "Fecha creación" - -msgctxt "field:lims.aliquot,create_uid:" -msgid "Create User" -msgstr "Usuario creación" - -msgctxt "field:lims.aliquot,fraction:" -msgid "Fraction" -msgstr "Fracción" - -msgctxt "field:lims.aliquot,id:" -msgid "ID" -msgstr "ID" - -msgctxt "field:lims.aliquot,kind:" -msgid "Kind" -msgstr "Clase" - -msgctxt "field:lims.aliquot,laboratory:" -msgid "Destination Laboratory" -msgstr "Laboratorio destino" - -msgctxt "field:lims.aliquot,number:" -msgid "Number" -msgstr "Número" - -msgctxt "field:lims.aliquot,preparation:" -msgid "Preparation" -msgstr "Preparación" - -msgctxt "field:lims.aliquot,rec_name:" -msgid "Record Name" -msgstr "Nombre" - -msgctxt "field:lims.aliquot,shipment_date:" -msgid "Shipment date" -msgstr "Fecha de envío" - -msgctxt "field:lims.aliquot,type:" -msgid "Type" -msgstr "Tipo" - -msgctxt "field:lims.aliquot,write_date:" -msgid "Write Date" -msgstr "Fecha modificación" - -msgctxt "field:lims.aliquot,write_uid:" -msgid "Write User" -msgstr "Usuario modificación" - -msgctxt "field:lims.aliquot.type,code:" -msgid "Code" -msgstr "Código" - -msgctxt "field:lims.aliquot.type,create_date:" -msgid "Create Date" -msgstr "Fecha creación" - -msgctxt "field:lims.aliquot.type,create_uid:" -msgid "Create User" -msgstr "Usuario creación" - -msgctxt "field:lims.aliquot.type,id:" -msgid "ID" -msgstr "ID" - -msgctxt "field:lims.aliquot.type,ind_volume:" -msgid "Required volume" -msgstr "Volumen requerido" - -msgctxt "field:lims.aliquot.type,kind:" -msgid "Kind" -msgstr "Clase" - -msgctxt "field:lims.aliquot.type,laboratory:" -msgid "Destination Laboratory" -msgstr "Laboratorio destino" - -msgctxt "field:lims.aliquot.type,name:" -msgid "Name" -msgstr "Nombre" - -msgctxt "field:lims.aliquot.type,preparation:" -msgid "Preparation" -msgstr "Preparación" - -msgctxt "field:lims.aliquot.type,product_types:" -msgid "Product types" -msgstr "Tipos de producto" - -msgctxt "field:lims.aliquot.type,rec_name:" -msgid "Record Name" -msgstr "Nombre" - -msgctxt "field:lims.aliquot.type,uom:" -msgid "UoM" -msgstr "UdM" - -msgctxt "field:lims.aliquot.type,write_date:" -msgid "Write Date" -msgstr "Fecha modificación" - -msgctxt "field:lims.aliquot.type,write_uid:" -msgid "Write User" -msgstr "Usuario modificación" - -msgctxt "field:lims.aliquot.type-product.type,aliquot_type:" -msgid "Aliquot type" -msgstr "Tipo de alícuota" - -msgctxt "field:lims.aliquot.type-product.type,create_date:" -msgid "Create Date" -msgstr "Fecha creación" - -msgctxt "field:lims.aliquot.type-product.type,create_uid:" -msgid "Create User" -msgstr "Usuario creación" - -msgctxt "field:lims.aliquot.type-product.type,id:" -msgid "ID" -msgstr "ID" - -msgctxt "field:lims.aliquot.type-product.type,product_type:" -msgid "Product type" -msgstr "Tipo de producto" - -msgctxt "field:lims.aliquot.type-product.type,rec_name:" -msgid "Record Name" -msgstr "Nombre" - -msgctxt "field:lims.aliquot.type-product.type,write_date:" -msgid "Write Date" -msgstr "Fecha modificación" - -msgctxt "field:lims.aliquot.type-product.type,write_uid:" -msgid "Write User" -msgstr "Usuario modificación" - -msgctxt "field:lims.analysis,aliquot_type:" -msgid "Aliquot type" -msgstr "Tipo de alícuota" - msgctxt "field:lims.analysis,ind_volume:" msgid "Required volume" msgstr "Volumen requerido" @@ -358,14 +214,6 @@ msgctxt "field:lims.component.type,write_uid:" msgid "Write User" msgstr "Usuario modificación" -msgctxt "field:lims.configuration,rack_sequence:" -msgid "Rack Sequence" -msgstr "Secuencia de Rack" - -msgctxt "field:lims.configuration.sequence,rack_sequence:" -msgid "Rack Sequence" -msgstr "Secuencia de Rack" - msgctxt "field:lims.create_sample.start,attributes:" msgid "Attributes" msgstr "Atributos" @@ -638,74 +486,6 @@ msgctxt "field:lims.equipment.type,write_uid:" msgid "Write User" msgstr "Usuario modificación" -msgctxt "field:lims.lab.workyear,aliquot_sequence:" -msgid "Aliquot Sequence" -msgstr "Secuencia de Alícuota" - -msgctxt "field:lims.lab.workyear.sequence,aliquot_sequence:" -msgid "Aliquot Sequence" -msgstr "Secuencia de Alícuota" - -msgctxt "field:lims.planification,aliquot_type:" -msgid "Rack type" -msgstr "Tipo Rack" - -msgctxt "field:lims.planification,positions:" -msgid "Positions" -msgstr "Posiciones" - -msgctxt "field:lims.planification,rack_number:" -msgid "Rack number" -msgstr "Número Rack" - -msgctxt "field:lims.planification,rack_state:" -msgid "Rack state" -msgstr "Estado Rack" - -msgctxt "field:lims.planification,rack_user:" -msgid "Rack user" -msgstr "Usuario Rack" - -msgctxt "field:lims.planification,type:" -msgid "Type" -msgstr "Tipo" - -msgctxt "field:lims.planification.position,aliquot:" -msgid "Aliquot" -msgstr "Alícuota" - -msgctxt "field:lims.planification.position,create_date:" -msgid "Create Date" -msgstr "Fecha creación" - -msgctxt "field:lims.planification.position,create_uid:" -msgid "Create User" -msgstr "Usuario creación" - -msgctxt "field:lims.planification.position,id:" -msgid "ID" -msgstr "ID" - -msgctxt "field:lims.planification.position,planification:" -msgid "Planification" -msgstr "Planificación" - -msgctxt "field:lims.planification.position,position:" -msgid "Position" -msgstr "Posición" - -msgctxt "field:lims.planification.position,rec_name:" -msgid "Record Name" -msgstr "Nombre" - -msgctxt "field:lims.planification.position,write_date:" -msgid "Write Date" -msgstr "Fecha modificación" - -msgctxt "field:lims.planification.position,write_uid:" -msgid "Write User" -msgstr "Usuario modificación" - msgctxt "field:lims.plant,city:" msgid "City" msgstr "Ciudad" @@ -1090,14 +870,6 @@ msgctxt "help:lims.sample.attribute,selection_sorted:" msgid "If the selection must be sorted on label" msgstr "Si la selección debe ordenarse por la etiqueta" -msgctxt "model:ir.action,name:act_aliquot" -msgid "Aliquots" -msgstr "Alícuotas" - -msgctxt "model:ir.action,name:act_aliquot_type" -msgid "Aliquot Types" -msgstr "Tipos de alícuota" - msgctxt "model:ir.action,name:act_brand" msgid "Brands" msgstr "Marcas" @@ -1142,10 +914,6 @@ msgctxt "model:ir.action,name:act_plant" msgid "Plants" msgstr "Plantas" -msgctxt "model:ir.action,name:act_rack_list" -msgid "Racks" -msgstr "Racks" - msgctxt "model:ir.action,name:act_sample_attribute" msgid "Sample Attributes" msgstr "Atributos de muestra" @@ -1158,41 +926,10 @@ msgctxt "model:ir.action,name:act_sampling_type" msgid "Sampling Types" msgstr "Tipos de muestreo" -msgctxt "model:ir.action,name:report_aliquot_external" -msgid "External Aliquots Shipping" -msgstr "Envío de Alícuotas externas" - msgctxt "model:ir.action,name:wiz_edit_sample" msgid "Edit Samples" msgstr "Modificar muestras" -msgctxt "model:ir.action.act_window.domain,name:act_rack_list_domain_all" -msgid "All" -msgstr "Todo" - -msgctxt "" -"model:ir.action.act_window.domain,name:act_rack_list_domain_confirmed" -msgid "Confirmed" -msgstr "Confirmado" - -msgctxt "model:ir.action.act_window.domain,name:act_rack_list_domain_draft" -msgid "Draft" -msgstr "Borrador" - -msgctxt "" -"model:ir.action.act_window.domain,name:act_rack_list_domain_not_executed" -msgid "Not executed" -msgstr "No ejecutado" - -msgctxt "" -"model:ir.action.act_window.domain,name:act_rack_list_domain_preplanned" -msgid "Pre-Planned" -msgstr "Pre-Planificado" - -msgctxt "model:ir.message,text:lbl_aliquot_preparation" -msgid "Aliquot preparation" -msgstr "Preparación de Alícuota" - msgctxt "model:ir.message,text:lbl_component_missing_data" msgid "Missing data in Component" msgstr "Faltan datos en Componente" @@ -1213,10 +950,6 @@ msgctxt "model:ir.message,text:lbl_sample_missing_data" msgid "Missing data in Sample" msgstr "Faltan datos en Muestra" -msgctxt "model:ir.message,text:msg_aliquot_no_sequence" -msgid "There is no aliquot sequence for the work year \"%(work_year)s\"." -msgstr "No hay una secuencia de alícuotas para el año laboral «%(work_year)s»" - msgctxt "model:ir.message,text:msg_component_type_unique" msgid "A component of the same type already exists for the equipment" msgstr "Ya existe un componente del mismo tipo para el equipo" @@ -1237,42 +970,10 @@ msgctxt "model:ir.message,text:msg_party_no_tax_identifier" msgid "Party \"%(party)s\" has no Tax Identifier" msgstr "La entidad «%(party)s» no tiene identificador fiscal" -msgctxt "model:ir.message,text:msg_planification_position_unique" -msgid "Rack positions must be unique" -msgstr "Las posiciones del Rack deben ser únicas" - msgctxt "model:ir.message,text:msg_plant_name_unique" msgid "There is already a plant with the same name for the party" msgstr "Ya existe una planta con el mismo nombre para el tercero" -msgctxt "model:ir.message,text:msg_user_no_laboratory" -msgid "There is no laboratory for this user" -msgstr "No hay un Laboratorio por defecto para este usuario" - -msgctxt "model:ir.sequence,name:seq_aliquot" -msgid "Aliquot" -msgstr "Alícuota" - -msgctxt "model:ir.sequence,name:seq_rack" -msgid "Rack" -msgstr "Rack" - -msgctxt "model:ir.sequence.type,name:seq_type_aliquot" -msgid "Aliquot" -msgstr "Alícuota" - -msgctxt "model:ir.sequence.type,name:seq_type_rack" -msgid "Rack" -msgstr "Rack" - -msgctxt "model:ir.ui.menu,name:menu_aliquot" -msgid "Aliquots" -msgstr "Alícuotas" - -msgctxt "model:ir.ui.menu,name:menu_aliquot_type" -msgid "Aliquot Types" -msgstr "Tipos de alícuota" - msgctxt "model:ir.ui.menu,name:menu_brand" msgid "Brands" msgstr "Marcas" @@ -1317,10 +1018,6 @@ msgctxt "model:ir.ui.menu,name:menu_plant" msgid "Plants" msgstr "Plantas" -msgctxt "model:ir.ui.menu,name:menu_rack_list" -msgid "Racks" -msgstr "Racks" - msgctxt "model:ir.ui.menu,name:menu_sample_attribute" msgid "Sample Attributes" msgstr "Atributos de muestra" @@ -1333,18 +1030,6 @@ msgctxt "model:ir.ui.menu,name:menu_sampling_type" msgid "Sampling Types" msgstr "Tipos de muestreo" -msgctxt "model:lims.aliquot,name:" -msgid "Aliquot" -msgstr "Alícuota" - -msgctxt "model:lims.aliquot.type,name:" -msgid "Aliquot Type" -msgstr "Tipo de alícuota" - -msgctxt "model:lims.aliquot.type-product.type,name:" -msgid "Equipment Template - Component Type" -msgstr "Plantilla de equipo - Tipo de componente" - msgctxt "model:lims.brand,name:" msgid "Brand" msgstr "Marca" @@ -1381,10 +1066,6 @@ msgctxt "model:lims.equipment.type,name:" msgid "Equipment Type" msgstr "Tipo de componente" -msgctxt "model:lims.planification.position,name:" -msgid "Rack Position" -msgstr "Posición de Rack" - msgctxt "model:lims.plant,name:" msgid "Plant" msgstr "Planta" @@ -1409,46 +1090,6 @@ msgctxt "model:lims.sampling.type,name:" msgid "Sampling Type" msgstr "Muestreo" -msgctxt "selection:lims.aliquot,kind:" -msgid "External" -msgstr "Externa" - -msgctxt "selection:lims.aliquot,kind:" -msgid "Internal" -msgstr "Interna" - -msgctxt "selection:lims.aliquot,kind:" -msgid "Rack" -msgstr "Rack" - -msgctxt "selection:lims.aliquot.type,kind:" -msgid "External" -msgstr "Externa" - -msgctxt "selection:lims.aliquot.type,kind:" -msgid "Internal" -msgstr "Interna" - -msgctxt "selection:lims.aliquot.type,kind:" -msgid "Rack" -msgstr "Rack" - -msgctxt "selection:lims.planification,rack_state:" -msgid "Closed" -msgstr "Cerrado" - -msgctxt "selection:lims.planification,rack_state:" -msgid "Open" -msgstr "Abierto" - -msgctxt "selection:lims.planification,type:" -msgid "Normal" -msgstr "Normal" - -msgctxt "selection:lims.planification,type:" -msgid "Rack" -msgstr "Rack" - msgctxt "selection:lims.sample.attribute,type_:" msgid "Boolean" msgstr "Boolean" @@ -1537,10 +1178,6 @@ msgctxt "view:lims.planification:" msgid "Add RM/BMZ" msgstr "Añadir RM/BMZ" -msgctxt "view:lims.planification:" -msgid "Aliquots" -msgstr "Alícuotas" - msgctxt "view:lims.planification:" msgid "Comments" msgstr "Observaciones" diff --git a/lims_industry/message.xml b/lims_industry/message.xml index 200cf761..e4dbe8cd 100644 --- a/lims_industry/message.xml +++ b/lims_industry/message.xml @@ -1,9 +1,6 @@ - - Aliquot preparation - Missing data in Component @@ -19,9 +16,6 @@ Missing data in Sample - - There is no aliquot sequence for the work year "%(work_year)s". - A component of the same type already exists for the equipment @@ -40,11 +34,5 @@ There is already a plant with the same name for the party - - There is no laboratory for this user - - - Rack positions must be unique - diff --git a/lims_industry/planification.py b/lims_industry/planification.py deleted file mode 100644 index c4a47c86..00000000 --- a/lims_industry/planification.py +++ /dev/null @@ -1,168 +0,0 @@ -# This file is part of lims_industry module for Tryton. -# The COPYRIGHT file at the top level of this repository contains -# the full copyright notices and license terms. - -from trytond.model import ModelSQL, ModelView, fields, Unique -from trytond.pool import Pool, PoolMeta -from trytond.pyson import Not, Bool, Equal, Eval -from trytond.transaction import Transaction -from trytond.exceptions import UserError -from trytond.i18n import gettext - -__all__ = ['Rack', 'RackPosition'] - - -class Rack(metaclass=PoolMeta): - __name__ = 'lims.planification' - - type = fields.Selection([ - ('normal', 'Normal'), - ('rack', 'Rack'), - ], 'Type', required=True, sort=False) - rack_number = fields.Char('Rack number', readonly=True) - aliquot_type = fields.Many2One('lims.aliquot.type', 'Rack type', - states={'required': Eval('type') == 'rack'}, - domain=[('kind', '=', 'rack')], - depends=['type']) - rack_state = fields.Selection([ - (None, ''), - ('open', 'Open'), - ('closed', 'Closed'), - ], 'Rack state', sort=False, - states={'required': Eval('type') == 'rack'}, - depends=['type']) - rack_user = fields.Many2One('res.user', 'Rack user', - states={'required': Eval('type') == 'rack'}, - depends=['type']) - positions = fields.One2Many('lims.planification.position', - 'planification', 'Positions', - states={'readonly': Not(Bool(Equal(Eval('state'), 'draft')))}, - depends=['state']) - - @classmethod - def __setup__(cls): - super(Rack, cls).__setup__() - cls.details.context.update({'planification_type': Eval('type')}) - - @staticmethod - def default_type(): - return 'normal' - - @staticmethod - def default_rack_user(): - return int(Transaction().user) - - @classmethod - def create(cls, vlist): - pool = Pool() - Config = pool.get('lims.configuration') - Sequence = pool.get('ir.sequence') - AliquotType = pool.get('lims.aliquot.type') - - vlist = [x.copy() for x in vlist] - config = Config(1) - for values in vlist: - if values['type'] != 'rack': - continue - number = '%s' % values['date'].strftime("%Y%m%d") - number += '-%s' % AliquotType(values['aliquot_type']).code - number += '-%s' % Sequence.get_id(config.rack_sequence.id) - values['rack_number'] = number - return super(Rack, cls).create(vlist) - - @classmethod - def plan_aliquot(cls, aliquot, analysis): - pool = Pool() - PlanificationPosition = pool.get('lims.planification.position') - PlanificationDetail = pool.get('lims.planification.detail') - Date = pool.get('ir.date') - - if aliquot.type.kind != 'rack': - return - - laboratory = Transaction().context.get('laboratory', None) - if not laboratory: - raise UserError(gettext('lims_industry.msg_user_no_laboratory')) - - # Rack - create_new_rack = True - position = 1 - open_racks = cls.search([ - ('type', '=', 'rack'), - ('laboratory', '=', laboratory), - ('rack_user', '=', int(Transaction().user)), - ('aliquot_type', '=', aliquot.type), - ('rack_state', '=', 'open'), - ]) - for open_rack in open_racks: - if len(open_rack.positions) >= 20: - open_rack.rack_state = 'closed' - open_rack.save() - continue - rack = open_rack - position += len(rack.positions) - create_new_rack = False - break - - if create_new_rack: - today = Date.today() - rack = cls( - laboratory=laboratory, - date=today, - date_from=today, - date_to=today, - state='draft', - type='rack', - aliquot_type=aliquot.type.id, - rack_state='open', - rack_user=int(Transaction().user), - ) - rack.save() - - # Rack position - rack_position = PlanificationPosition( - planification=rack.id, - position=position, - aliquot=aliquot.id, - ) - rack_position.save() - if position == 20: - rack.rack_state = 'closed' - rack.save() - - # Fraction to plan - rack_services = [] - for analysis_id in analysis: - if not PlanificationDetail.search([ - ('planification', '=', rack.id), - ('fraction', '=', aliquot.fraction.id), - ('service_analysis', '=', analysis_id), - ]): - rack_service = PlanificationDetail( - planification=rack.id, - fraction=aliquot.fraction.id, - service_analysis=analysis_id, - ) - rack_services.append(rack_service) - PlanificationDetail.save(rack_services) - - -class RackPosition(ModelSQL, ModelView): - 'Rack Position' - __name__ = 'lims.planification.position' - - planification = fields.Many2One('lims.planification', 'Planification', - ondelete='CASCADE', select=True, required=True) - position = fields.Integer('Position', required=True, - domain=[('position', '>=', 1), ('position', '<=', 20)]) - aliquot = fields.Many2One('lims.aliquot', 'Aliquot', required=True) - - @classmethod - def __setup__(cls): - super(RackPosition, cls).__setup__() - cls._order.insert(0, ('position', 'ASC')) - t = cls.__table__() - cls._sql_constraints += [ - ('position_uniq', Unique(t, t.planification, t.position), - 'lims_industry.msg_planification_position_unique'), - ] diff --git a/lims_industry/planification.xml b/lims_industry/planification.xml deleted file mode 100644 index 3c544e96..00000000 --- a/lims_industry/planification.xml +++ /dev/null @@ -1,122 +0,0 @@ - - - - - - - - - - - - - - lims.planification - form - rack_form - - - lims.planification - tree - rack_list - - - - Racks - lims.planification - - - - - - - - - - - - - - - Draft - - - - - - Pre-Planned - - - - - - Confirmed - - - - - - Not executed - - - - - - All - - - - - - - - - - - lims.planification.position - form - planification_position_form - - - lims.planification.position - tree - planification_position_list - - - - - - - - - Rack - lims.planification - - - - - - - Rack - lims.planification - - - - - diff --git a/lims_industry/report/aliquot_external.fodt b/lims_industry/report/aliquot_external.fodt deleted file mode 100644 index 2f6830eb..00000000 --- a/lims_industry/report/aliquot_external.fodt +++ /dev/null @@ -1,248 +0,0 @@ - - - - 2019-10-09T17:38:31.2842241360P0DLibreOffice/6.0.7.3$Linux_X86_64 LibreOffice_project/00m0$Build-3 - - - 0 - 0 - 22250 - 8821 - true - false - - - view2 - 2625 - 2501 - 0 - 0 - 22248 - 8819 - 0 - 0 - false - 120 - false - false - - - - - false - - false - false - false - false - false - true - false - true - true - false - - true - - false - false - true - false - true - false - 827680 - false - false - true - false - false - true - true - true - true - true - true - false - false - 1 - false - false - false - - false - false - - false - false - false - - false - 0 - false - - 0 - true - false - false - false - false - false - true - false - false - false - true - 923240 - true - false - false - false - high-resolution - true - true - true - false - false - false - false - false - false - false - false - false - true - false - 0 - true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/lims_industry/sample.py b/lims_industry/sample.py index b011247e..53b18272 100644 --- a/lims_industry/sample.py +++ b/lims_industry/sample.py @@ -2,18 +2,14 @@ # The COPYRIGHT file at the top level of this repository contains # the full copyright notices and license terms. -from trytond.model import ModelSQL, ModelView, fields +from trytond.model import ModelView, fields from trytond.wizard import Wizard, StateTransition, StateView, Button -from trytond.report import Report from trytond.pool import Pool, PoolMeta -from trytond.pyson import Eval, Bool +from trytond.pyson import Eval from trytond.transaction import Transaction -from trytond.exceptions import UserError -from trytond.i18n import gettext __all__ = ['Entry', 'Sample', 'CreateSampleStart', 'CreateSample', - 'EditSampleStart', 'EditSample', 'Fraction', 'Aliquot', - 'AliquotExternalReport'] + 'EditSampleStart', 'EditSample'] class Entry(metaclass=PoolMeta): @@ -369,162 +365,3 @@ class EditSample(Wizard): entry.state = 'draft' entry.save() return entry - - -class Fraction(metaclass=PoolMeta): - __name__ = 'lims.fraction' - - @classmethod - def confirm(cls, fractions): - super(Fraction, cls).confirm(fractions) - for fraction in fractions: - fraction.create_aliquots() - fraction.plan_aliquots() - - def create_aliquots(self): - pool = Pool() - EntryDetailAnalysis = pool.get('lims.entry.detail.analysis') - Aliquot = pool.get('lims.aliquot') - - aliquot_types = [] - analysis_detail = EntryDetailAnalysis.search([ - ('fraction', '=', self.id)]) - for detail in analysis_detail: - if detail.analysis.aliquot_type: - aliquot_types.append(detail.analysis.aliquot_type.id) - - aliquots = [] - for type in list(set(aliquot_types)): - aliquot = Aliquot() - aliquot.fraction = self.id - aliquot.type = type - aliquots.append(aliquot) - if aliquots: - Aliquot.save(aliquots) - - def plan_aliquots(self): - pool = Pool() - Service = pool.get('lims.service') - Aliquot = pool.get('lims.aliquot') - Planification = pool.get('lims.planification') - - analysis_ids = [] - services = Service.search([('fraction', '=', self.id)]) - for service in services: - analysis_ids.append(service.analysis.id) - analysis = list(set(analysis_ids)) - - aliquots = Aliquot.search([('fraction', '=', self.id)]) - for aliquot in aliquots: - Planification.plan_aliquot(aliquot, analysis) - - -class Aliquot(ModelSQL, ModelView): - 'Aliquot' - __name__ = 'lims.aliquot' - _rec_name = 'number' - - number = fields.Char('Number', select=True, readonly=True) - fraction = fields.Many2One('lims.fraction', 'Fraction', required=True, - ondelete='CASCADE', select=True, depends=['number'], - states={'readonly': Bool(Eval('number'))}) - type = fields.Many2One('lims.aliquot.type', 'Type', required=True) - kind = fields.Function(fields.Selection([ - ('int', 'Internal'), - ('ext', 'External'), - ('rack', 'Rack'), - ], 'Kind'), 'get_type_field') - shipment_date = fields.Date('Shipment date', - states={'invisible': Eval('kind') != 'ext'}, - depends=['kind']) - laboratory = fields.Function(fields.Many2One('party.party', - 'Destination Laboratory', - states={'invisible': Eval('kind') != 'ext'}, - depends=['kind']), 'get_type_field') - preparation = fields.Function(fields.Boolean('Preparation', - states={'invisible': Eval('kind') != 'int'}, - depends=['kind']), 'get_type_field') - - @classmethod - def __setup__(cls): - super(Aliquot, cls).__setup__() - cls._order.insert(0, ('number', 'DESC')) - - @fields.depends('type') - def on_change_with_kind(self, name=None): - if self.type: - result = self.get_type_field((self,), ('kind',)) - return result['kind'][self.id] - return None - - @fields.depends('type') - def on_change_with_laboratory(self, name=None): - if self.type: - result = self.get_type_field((self,), ('laboratory',)) - return result['laboratory'][self.id] - return None - - @fields.depends('type') - def on_change_with_preparation(self, name=None): - if self.type: - result = self.get_type_field((self,), ('preparation',)) - return result['preparation'][self.id] - return None - - @classmethod - def get_type_field(cls, aliquots, names): - result = {} - for name in names: - result[name] = {} - if name == 'laboratory': - for a in aliquots: - field = getattr(a.type, name, None) - result[name][a.id] = field.id if field else None - else: - for a in aliquots: - result[name][a.id] = getattr(a.type, name, None) - return result - - @classmethod - def create(cls, vlist): - pool = Pool() - LabWorkYear = pool.get('lims.lab.workyear') - Sequence = pool.get('ir.sequence') - TaskTemplate = Pool().get('lims.administrative.task.template') - - workyear_id = LabWorkYear.find() - workyear = LabWorkYear(workyear_id) - sequence = workyear.get_sequence('aliquot') - if not sequence: - raise UserError(gettext('lims_industry.msg_aliquot_no_sequence', - work_year=workyear.rec_name)) - - vlist = [x.copy() for x in vlist] - for values in vlist: - values['number'] = Sequence.get_id(sequence.id) - - aliquots = super(Aliquot, cls).create(vlist) - TaskTemplate.create_tasks('aliquot_preparation', - cls._for_task_preparation(aliquots)) - return aliquots - - @classmethod - def _for_task_preparation(cls, aliquots): - AdministrativeTask = Pool().get('lims.administrative.task') - res = [] - for aliquot in aliquots: - if not aliquot.preparation: - continue - if AdministrativeTask.search([ - ('type', '=', 'aliquot_preparation'), - ('origin', '=', '%s,%s' % (cls.__name__, aliquot.id)), - ('state', 'not in', ('done', 'discarded')), - ]): - continue - res.append(aliquot) - return res - - -class AliquotExternalReport(Report): - 'External Aliquots Shipping' - __name__ = 'lims.aliquot.external.report' diff --git a/lims_industry/sample.xml b/lims_industry/sample.xml index 7dc88a0f..7cbb9c73 100644 --- a/lims_industry/sample.xml +++ b/lims_industry/sample.xml @@ -41,71 +41,5 @@ - - - - lims.aliquot - tree - aliquot_list - - - lims.aliquot - form - aliquot_form - - - - Aliquots - lims.aliquot - - - - - - - - - - - - - - - - - - External Aliquots Shipping - lims.aliquot - lims.aliquot.external.report - lims_industry/report/aliquot_external.fodt - - - - form_print - lims.aliquot,-1 - - - - - - - - - - Aliquot - lims.aliquot - - - - - - - Aliquot - lims.aliquot - - - diff --git a/lims_industry/task.py b/lims_industry/task.py index 83121bde..3aa6a76d 100644 --- a/lims_industry/task.py +++ b/lims_industry/task.py @@ -24,8 +24,6 @@ class AdministrativeTaskTemplate(metaclass=PoolMeta): gettext('lims_industry.lbl_sample_missing_data'))) types.append(('sample_insufficient_volume', gettext('lims_industry.lbl_sample_insufficient_volume'))) - types.append(('aliquot_preparation', - gettext('lims_industry.lbl_aliquot_preparation'))) return types @@ -40,6 +38,5 @@ class AdministrativeTask(metaclass=PoolMeta): 'lims.component', 'party.party', 'lims.sample', - 'lims.aliquot', ]) return origins diff --git a/lims_industry/tryton.cfg b/lims_industry/tryton.cfg index 7765dc12..cf78cbf3 100644 --- a/lims_industry/tryton.cfg +++ b/lims_industry/tryton.cfg @@ -8,6 +8,4 @@ xml: analysis.xml sample.xml party.xml - planification.xml - configuration.xml message.xml diff --git a/lims_industry/view/aliquot_form.xml b/lims_industry/view/aliquot_form.xml deleted file mode 100644 index 5e0de2fb..00000000 --- a/lims_industry/view/aliquot_form.xml +++ /dev/null @@ -1,17 +0,0 @@ - -
-