diff --git a/documents/plans/ISSUE7_PLAN.md b/documents/plans/ISSUE7_PLAN.md new file mode 100644 index 0000000..f02cfa2 --- /dev/null +++ b/documents/plans/ISSUE7_PLAN.md @@ -0,0 +1,57 @@ +# Plan de Actividades: Issue #7 - Gestión de Muestras de Laboratorio + +## Objetivo + +Extender el modelo de Lotes/Números de Serie de Odoo (`stock.lot`) para representar y gestionar las **Muestras de Laboratorio**. Esto permitirá la trazabilidad completa de la muestra desde su recolección hasta el análisis. + +## TODO + +- [x] **Extender el Modelo de Lote/Número de Serie (`stock.lot`):** + - [x] Crear el archivo `lims_management/models/stock_lot.py`. + - [x] Heredar del modelo `stock.lot`. + - [x] Añadir campos: `is_lab_sample`, `patient_id`, `request_id`, `collection_date`, `container_type`. + - [ ] **(Nuevo)** Añadir campo `collector_id` (Many2one a `res.users`) para registrar quién tomó la muestra. + +- [x] **Adaptar las Vistas de Lote/Número de Serie:** + - [x] Crear el archivo `lims_management/views/stock_lot_views.xml`. + - [x] Crear vistas de lista y formulario para las muestras. + - [x] Crear un producto de servicio por defecto para las muestras. + - [ ] **(Nuevo)** Añadir el campo `collector_id` a las vistas de lista y formulario. + +- [x] **Crear el Menú "Gestión de Muestras":** + - [x] Modificar `lims_management/views/menus.xml`. + - [x] Crear acción de ventana y `menuitem` para `stock.lot` con el dominio y contexto adecuados. + +- [x] **Establecer Permisos y Reglas de Dominio:** + - [x] Modificar `lims_management/security/ir.model.access.csv` para dar permisos sobre `stock.lot`. + - [x] Añadir dominios en las vistas para los campos relacionales. + +- [x] **Actualizar el Manifiesto (`__manifest__.py`):** + - [x] Añadir nuevos archivos de modelos, vistas y datos al manifiesto. + +- [x] **Verificación Final:** + - [x] Reiniciar y verificar la instancia de Odoo. + +- [x] **Mejorar Modelo de Productos para Tipos de Muestra:** + - [x] Añadir un campo booleano `is_sample_type` al modelo `product.template`. + +- [x] **Crear Menú para "Tipos de Muestra":** + - [x] Añadir acción de ventana y `menuitem` para los tipos de muestra. + +- [x] **Actualizar Vista de Muestras (`stock.lot`):** + - [x] Hacer visible y aplicar dominio al campo `product_id` (Tipo de Muestra). + - [x] Eliminar el producto genérico y su referencia en el contexto. + +- [x] **Crear Datos de Demostración:** + - [x] Crear archivo `demo/z_sample_demo.xml` con tipos de muestra y muestras de ejemplo. + - [x] Añadir el archivo de demostración al manifiesto. + - [ ] **(Nuevo)** Actualizar los datos de demostración para incluir el `collector_id`. + +- [x] **Verificación Final (con Demo):** + - [x] Validar la funcionalidad completa con los datos de demostración. + +--- +## Consideraciones Futuras (Siguientes Issues) + +- **Ciclo de Vida de la Muestra:** Implementar un campo de estado (`state`) con su lógica de transiciones (ej. 'Recolectada' -> 'Recibida' -> 'En Proceso' -> 'Completada' -> 'Almacenada'). +- **Informes de Muestras:** Crear informes en PDF o vistas dinámicas sobre el estado y trazabilidad de las muestras. \ No newline at end of file diff --git a/init_odoo.py b/init_odoo.py index 5c0d251..d1c5a08 100644 --- a/init_odoo.py +++ b/init_odoo.py @@ -104,4 +104,4 @@ except FileNotFoundError: sys.exit(1) except Exception as e: print(f"Ocurrió un error inesperado al ejecutar Odoo: {e}") - sys.exit(1) + sys.exit(1) \ No newline at end of file diff --git a/lims_management/__manifest__.py b/lims_management/__manifest__.py index b17245a..6de926c 100644 --- a/lims_management/__manifest__.py +++ b/lims_management/__manifest__.py @@ -25,11 +25,13 @@ 'views/partner_views.xml', 'views/analysis_views.xml', 'views/sale_order_views.xml', + 'views/stock_lot_views.xml', 'views/menus.xml', ], 'demo': [ 'demo/z_lims_demo.xml', 'demo/z_analysis_demo.xml', + 'demo/z_sample_demo.xml', ], 'installable': True, 'application': True, diff --git a/lims_management/demo/z_sample_demo.xml b/lims_management/demo/z_sample_demo.xml new file mode 100644 index 0000000..bb871b6 --- /dev/null +++ b/lims_management/demo/z_sample_demo.xml @@ -0,0 +1,41 @@ + + + + + + Tubo de Suero (Tapa Roja) + + service + + + Tubo EDTA (Tapa Morada) + + service + + + Contenedor de Orina + + service + + + + + SAM-2025-00001 + + + + + + serum_tube + + + SAM-2025-00002 + + + + + + edta_tube + + + diff --git a/lims_management/models/__init__.py b/lims_management/models/__init__.py index 4ffd5f7..5b09e9e 100644 --- a/lims_management/models/__init__.py +++ b/lims_management/models/__init__.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- -from . import partner -from . import product from . import analysis_range -from . import sale_order \ No newline at end of file +from . import product +from . import partner +from . import sale_order +from . import stock_lot diff --git a/lims_management/models/__pycache__/__init__.cpython-312.pyc b/lims_management/models/__pycache__/__init__.cpython-312.pyc index 51f1d65..03e4810 100644 Binary files a/lims_management/models/__pycache__/__init__.cpython-312.pyc and b/lims_management/models/__pycache__/__init__.cpython-312.pyc differ diff --git a/lims_management/models/__pycache__/product.cpython-312.pyc b/lims_management/models/__pycache__/product.cpython-312.pyc index b04b788..15c2049 100644 Binary files a/lims_management/models/__pycache__/product.cpython-312.pyc and b/lims_management/models/__pycache__/product.cpython-312.pyc differ diff --git a/lims_management/models/__pycache__/stock_lot.cpython-312.pyc b/lims_management/models/__pycache__/stock_lot.cpython-312.pyc new file mode 100644 index 0000000..3c5a0bb Binary files /dev/null and b/lims_management/models/__pycache__/stock_lot.cpython-312.pyc differ diff --git a/lims_management/models/product.py b/lims_management/models/product.py index 248a0d4..40f24a7 100644 --- a/lims_management/models/product.py +++ b/lims_management/models/product.py @@ -26,3 +26,8 @@ class ProductTemplate(models.Model): 'analysis_id', string="Rangos de Referencia" ) + + is_sample_type = fields.Boolean( + string="Is a Sample Type", + help="Check if this product represents a type of laboratory sample container." + ) diff --git a/lims_management/models/stock_lot.py b/lims_management/models/stock_lot.py new file mode 100644 index 0000000..1c37cfc --- /dev/null +++ b/lims_management/models/stock_lot.py @@ -0,0 +1,35 @@ +# -*- coding: utf-8 -*- +from odoo import models, fields + +class StockLot(models.Model): + _inherit = 'stock.lot' + + is_lab_sample = fields.Boolean(string='Is a Laboratory Sample') + + patient_id = fields.Many2one( + 'res.partner', + string='Patient', + domain="[('is_patient', '=', True)]" + ) + + request_id = fields.Many2one( + 'sale.order', + string='Lab Request', + domain="[('is_lab_request', '=', True)]" + ) + + collection_date = fields.Datetime(string='Collection Date') + + container_type = fields.Selection([ + ('serum_tube', 'Serum Tube'), + ('edta_tube', 'EDTA Tube'), + ('swab', 'Swab'), + ('urine', 'Urine Container'), + ('other', 'Other') + ], string='Container Type') + + collector_id = fields.Many2one( + 'res.users', + string='Collected by', + default=lambda self: self.env.user + ) diff --git a/lims_management/security/ir.model.access.csv b/lims_management/security/ir.model.access.csv index a326f43..9d946ac 100644 --- a/lims_management/security/ir.model.access.csv +++ b/lims_management/security/ir.model.access.csv @@ -1,3 +1,4 @@ id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink access_lims_analysis_range_user,lims.analysis.range.user,model_lims_analysis_range,base.group_user,1,1,1,1 access_sale_order_receptionist,sale.order.receptionist,sale.model_sale_order,group_lims_receptionist,1,1,1,0 +access_stock_lot_user,stock.lot.user,stock.model_stock_lot,base.group_user,1,1,1,1 diff --git a/lims_management/views/menus.xml b/lims_management/views/menus.xml index 678716b..c7f58cd 100644 --- a/lims_management/views/menus.xml +++ b/lims_management/views/menus.xml @@ -75,6 +75,33 @@ action="action_lims_lab_request" sequence="15"/> + + + Muestras de Laboratorio + stock.lot + list,form + + [('is_lab_sample', '=', True)] + + +

+ Crea una nueva muestra de laboratorio +

+
+
+ + + + + + + + Tipos de Muestra + product.template + kanban,form + [('is_sample_type', '=', True)] + + +

+ Crea un nuevo tipo de muestra +

+
+
+ + + diff --git a/lims_management/views/stock_lot_views.xml b/lims_management/views/stock_lot_views.xml new file mode 100644 index 0000000..9c5587a --- /dev/null +++ b/lims_management/views/stock_lot_views.xml @@ -0,0 +1,54 @@ + + + + + + + lab.sample.list + stock.lot + + + + + + + + + + + + + + + lab.sample.form + stock.lot + +
+ +
+

+ +

+
+ + + + + + + + + + + + +
+
+
+
+ +
+