From b225fa0815177555208acff8eaac36311720a33d Mon Sep 17 00:00:00 2001 From: Luis Ernesto Portillo Zaldivar Date: Wed, 16 Jul 2025 08:38:14 -0600 Subject: [PATCH] =?UTF-8?q?feat(#60):=20Agregar=20visualizaci=C3=B3n=20de?= =?UTF-8?q?=20re-muestras=20en=20=C3=B3rdenes=20de=20laboratorio?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Agregar campo computed all_sample_ids que incluye re-muestras - Método recursivo para obtener todas las re-muestras - Mejorar vista de orden con pestaña unificada de muestras - Mostrar indicador de re-muestra y muestra original - Incluir estado y motivo de rechazo en la vista 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- .../__pycache__/stock_lot.cpython-312.pyc | Bin 20990 -> 21193 bytes lims_management/models/sale_order.py | 25 ++++++++++ lims_management/views/sale_order_views.xml | 44 ++++++++++++------ 3 files changed, 55 insertions(+), 14 deletions(-) diff --git a/lims_management/models/__pycache__/stock_lot.cpython-312.pyc b/lims_management/models/__pycache__/stock_lot.cpython-312.pyc index 5e39c5ffea3f7209d0190bf8e13e2a2f9d1f7c22..94794ea4c0283ab73c6f8e4a4cfba2e5ef29d7e6 100644 GIT binary patch delta 747 zcmYk4Ur19?9LMk3-QBKt+x6z=?j|dzL@{P&w`fJ=Ls(4bD&I_6BHd+%rJc>xxFhPx zKuY-$`Vb^oq)d!hJ@jf16$))xO>RB}_0~gH_!^zx{6jyuAHICg@Ao_Bp5OU9P2N2r z@}kQnaV#cZ4qhH;c`hH-$ZRgE1qJajb3;6xf&NGb$>tU#3p`oM-8=R|JU+vg=zD}6 zVMClmd_Z&|mJuHjpAa_@pAp5}t)@}l;bfX;-yg{WkCZBCi09(OD}u zEDy_}a#(5}+#~kT`m23MUh;_UP0E zKGwL)K?AtN)8r*n7)T{)in9ORywoqy5eteoT8+*(xDyN4nBsPWoy<+)EP|z=LCji( z*Re490Y76}%oms#8XuaH3Tn8hY6VrxA3BpicsAdDF0X3KYDZB`6x75>bj`;3!@oI) z%ROdYQ9KjkxHwr|P(nqep`bLZ)YPr)hQ`(lid)hu);Vd1`xno0*UDk8wTCQ&H-1>% zp1diX>h0@FZ_XYr#x>6pJC|v1zLrjQC+WsBT7=nnqAH6Aev3GQh#;;bR&&AA5uSLV sy{)NYjya|f$D5}3bg2OIZ9Y;4Z`x`r2kgW>a^t>n*I4IJ(^{7C4;%)|1poj5 delta 580 zcmX@Pl=0tUM!wU$yj%=GFkxnS#w^c`e3nLxnwve06j(VH14T8Ni4Mezth>IX15ky=95tl*46%bJcBCdjnYn$s`dYHMn zfox_V{=A8C@_YfQ$p#+k%sXnBCNIzw;i+Y=VRm7NUBht{xwjk1)p7U!G; z*U8Axvx0@8lB<$SlY6p?SNY^aUOPD0i(-K07TugY!P`!ft4IdOxy4+Rns$q|v^ce> zxaby0HgWPBZv_t4B6$$!(PR-HZLuO*AiJ0qNGO0nkpf8S_T&T~ZN|Nmdwh&oCAB{> za7}*aBQ=@ZH%35^(@5wm1E-+yM`kWw;SZdX%Y8E$FHL^vYbFj4zgw(sIr)ht&=8!g z=Vv5x8ffY*cF(+$)b!LMNMxLvT;dliwF+e2aS&kvBFsTVA&9uW`L&-pGo#RCNwkoiQMjY5zoxV1 KD+7oPRtf-Q!IlO9 diff --git a/lims_management/models/sale_order.py b/lims_management/models/sale_order.py index 61c6558..2865e4d 100644 --- a/lims_management/models/sale_order.py +++ b/lims_management/models/sale_order.py @@ -33,6 +33,31 @@ class SaleOrder(models.Model): help="Muestras de laboratorio generadas automáticamente cuando se confirmó esta orden" ) + all_sample_ids = fields.Many2many( + 'stock.lot', + string='Todas las Muestras (inc. Re-muestras)', + compute='_compute_all_samples', + help="Todas las muestras relacionadas con esta orden, incluyendo re-muestras" + ) + + @api.depends('generated_sample_ids', 'generated_sample_ids.child_sample_ids') + def _compute_all_samples(self): + """Compute all samples including resamples""" + for order in self: + all_samples = order.generated_sample_ids + # Add all resamples recursively + resamples = self.env['stock.lot'] + for sample in order.generated_sample_ids: + resamples |= self._get_all_resamples(sample) + order.all_sample_ids = all_samples | resamples + + def _get_all_resamples(self, sample): + """Recursively get all resamples of a sample""" + resamples = sample.child_sample_ids + for resample in sample.child_sample_ids: + resamples |= self._get_all_resamples(resample) + return resamples + def action_confirm(self): """Override to generate laboratory samples and tests automatically""" res = super(SaleOrder, self).action_confirm() diff --git a/lims_management/views/sale_order_views.xml b/lims_management/views/sale_order_views.xml index b2b5020..5848844 100644 --- a/lims_management/views/sale_order_views.xml +++ b/lims_management/views/sale_order_views.xml @@ -29,26 +29,42 @@ - - - - + + + + - + - - - + + + + + +