Merge pull request 'fix(#69): Corregir error 'Expected singleton' en métodos de acción de stock.lot' (#70) from bugfix/69-singleton-error-stock-lot into dev

Reviewed-on: #70
This commit is contained in:
luis_portillo 2025-07-17 07:43:27 +00:00
commit db3462184b
3 changed files with 61 additions and 54 deletions

View File

@ -145,74 +145,81 @@ class StockLot(models.Model):
) )
def action_collect(self): def action_collect(self):
"""Mark sample as collected""" """Mark sample(s) as collected"""
old_state = self.state for record in self:
self.write({'state': 'collected', 'collection_date': fields.Datetime.now()}) old_state = record.state
self.message_post( record.write({'state': 'collected', 'collection_date': fields.Datetime.now()})
body='Muestra recolectada por %s' % self.env.user.name, record.message_post(
subject='Estado actualizado: Recolectada', body='Muestra recolectada por %s' % self.env.user.name,
message_type='notification' subject='Estado actualizado: Recolectada',
) message_type='notification'
)
def action_receive(self): def action_receive(self):
"""Mark sample as received in laboratory""" """Mark sample(s) as received in laboratory"""
old_state = self.state for record in self:
self.write({'state': 'received'}) old_state = record.state
self.message_post( record.write({'state': 'received'})
body='Muestra recibida en laboratorio por %s' % self.env.user.name, record.message_post(
subject='Estado actualizado: Recibida', body='Muestra recibida en laboratorio por %s' % self.env.user.name,
message_type='notification' subject='Estado actualizado: Recibida',
) message_type='notification'
)
def action_start_analysis(self): def action_start_analysis(self):
"""Start analysis process""" """Start analysis process"""
old_state = self.state for record in self:
self.write({'state': 'in_process'}) old_state = record.state
self.message_post( record.write({'state': 'in_process'})
body='Análisis iniciado por %s' % self.env.user.name, record.message_post(
subject='Estado actualizado: En Proceso', body='Análisis iniciado por %s' % self.env.user.name,
message_type='notification' subject='Estado actualizado: En Proceso',
) message_type='notification'
)
def action_complete_analysis(self): def action_complete_analysis(self):
"""Mark analysis as completed""" """Mark analysis as completed"""
old_state = self.state for record in self:
self.write({'state': 'analyzed'}) old_state = record.state
self.message_post( record.write({'state': 'analyzed'})
body='Análisis completado por %s' % self.env.user.name, record.message_post(
subject='Estado actualizado: Analizada', body='Análisis completado por %s' % self.env.user.name,
message_type='notification' subject='Estado actualizado: Analizada',
) message_type='notification'
)
def action_store(self): def action_store(self):
"""Store the sample""" """Store the sample(s)"""
old_state = self.state for record in self:
self.write({'state': 'stored'}) old_state = record.state
self.message_post( record.write({'state': 'stored'})
body='Muestra almacenada por %s' % self.env.user.name, record.message_post(
subject='Estado actualizado: Almacenada', body='Muestra almacenada por %s' % self.env.user.name,
message_type='notification' subject='Estado actualizado: Almacenada',
) message_type='notification'
)
def action_dispose(self): def action_dispose(self):
"""Dispose of the sample""" """Dispose of the sample(s)"""
old_state = self.state for record in self:
self.write({'state': 'disposed'}) old_state = record.state
self.message_post( record.write({'state': 'disposed'})
body='Muestra desechada por %s. Motivo de disposición registrado.' % self.env.user.name, record.message_post(
subject='Estado actualizado: Desechada', body='Muestra desechada por %s. Motivo de disposición registrado.' % self.env.user.name,
message_type='notification' subject='Estado actualizado: Desechada',
) message_type='notification'
)
def action_cancel(self): def action_cancel(self):
"""Cancel the sample""" """Cancel the sample(s)"""
old_state = self.state for record in self:
self.write({'state': 'cancelled'}) old_state = record.state
self.message_post( record.write({'state': 'cancelled'})
body='Muestra cancelada por %s' % self.env.user.name, record.message_post(
subject='Estado actualizado: Cancelada', body='Muestra cancelada por %s' % self.env.user.name,
message_type='notification' subject='Estado actualizado: Cancelada',
) message_type='notification'
)
def action_open_rejection_wizard(self): def action_open_rejection_wizard(self):
"""Open the rejection wizard""" """Open the rejection wizard"""