feat(#31): Implementar ciclo de vida de muestras

This commit is contained in:
Luis Ernesto Portillo Zaldivar 2025-07-14 15:08:03 -06:00
parent 80323a38b9
commit 4510ba27c7
2 changed files with 42 additions and 6 deletions

View File

@ -33,3 +33,27 @@ class StockLot(models.Model):
string='Collected by', string='Collected by',
default=lambda self: self.env.user default=lambda self: self.env.user
) )
state = fields.Selection([
('collected', 'Recolectada'),
('received', 'Recibida en Laboratorio'),
('in_process', 'En Proceso'),
('analyzed', 'Analizada'),
('stored', 'Almacenada'),
('disposed', 'Desechada')
], string='Estado', default='collected', tracking=True)
def action_receive(self):
self.write({'state': 'received'})
def action_start_analysis(self):
self.write({'state': 'in_process'})
def action_complete_analysis(self):
self.write({'state': 'analyzed'})
def action_store(self):
self.write({'state': 'stored'})
def action_dispose(self):
self.write({'state': 'disposed'})

View File

@ -14,6 +14,7 @@
<field name="collection_date"/> <field name="collection_date"/>
<field name="collector_id"/> <field name="collector_id"/>
<field name="container_type"/> <field name="container_type"/>
<field name="state" decoration-success="state == 'analyzed'" decoration-info="state == 'in_process'" decoration-muted="state == 'stored' or state == 'disposed'" widget="badge"/>
</list> </list>
</field> </field>
</record> </record>
@ -24,6 +25,14 @@
<field name="model">stock.lot</field> <field name="model">stock.lot</field>
<field name="arch" type="xml"> <field name="arch" type="xml">
<form string="Lab Sample"> <form string="Lab Sample">
<header>
<button name="action_receive" string="Recibir" type="object" class="oe_highlight" invisible="state != 'collected'"/>
<button name="action_start_analysis" string="Iniciar Análisis" type="object" class="oe_highlight" invisible="state != 'received'"/>
<button name="action_complete_analysis" string="Completar Análisis" type="object" class="oe_highlight" invisible="state != 'in_process'"/>
<button name="action_store" string="Almacenar" type="object" invisible="state == 'stored' or state == 'disposed'"/>
<button name="action_dispose" string="Desechar" type="object" invisible="state == 'disposed'"/>
<field name="state" widget="statusbar" statusbar_visible="collected,received,in_process,analyzed,stored"/>
</header>
<sheet> <sheet>
<div class="oe_title"> <div class="oe_title">
<h1> <h1>
@ -32,17 +41,20 @@
</div> </div>
<group> <group>
<group> <group>
<field name="patient_id"/> <field name="patient_id" readonly="state != 'collected'"/>
<field name="request_id"/> <field name="request_id"
readonly="state != 'collected'"
domain="[('is_lab_request', '=', True), '|', ('partner_id', '=', False), ('partner_id', '=', patient_id)]"/>
<field name="product_id" <field name="product_id"
string="Sample Type" string="Sample Type"
domain="[('is_sample_type', '=', True)]" domain="[('is_sample_type', '=', True)]"
options="{'no_create': True, 'no_create_edit': True}"/> options="{'no_create': True, 'no_create_edit': True}"
readonly="state != 'collected'"/>
</group> </group>
<group> <group>
<field name="collection_date"/> <field name="collection_date" readonly="state != 'collected'"/>
<field name="collector_id"/> <field name="collector_id" readonly="state != 'collected'"/>
<field name="container_type"/> <field name="container_type" readonly="state != 'collected'"/>
</group> </group>
</group> </group>
</sheet> </sheet>