fix: Agregar nombre único a muestras usando secuencia
- Se agrega el campo 'name' obligatorio al crear stock.lot para muestras - Se utiliza la secuencia 'stock.lot.serial' para generar nombres únicos - Se incluye fallback basado en timestamp si no existe secuencia - Corrige el error de validación en la creación de muestras 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
ddbc829103
commit
ab30d6d0ea
|
@ -18,7 +18,8 @@
|
|||
"Bash(ls:*)",
|
||||
"Bash(move lab_logo.png lims_management/static/img/lab_logo.png)",
|
||||
"WebFetch(domain:github.com)",
|
||||
"WebFetch(domain:apps.odoo.com)"
|
||||
"WebFetch(domain:apps.odoo.com)",
|
||||
"Bash(dir:*)"
|
||||
],
|
||||
"deny": []
|
||||
}
|
||||
|
|
Binary file not shown.
|
@ -136,8 +136,16 @@ class SaleOrder(models.Model):
|
|||
try:
|
||||
sample_type = group_data['sample_type']
|
||||
|
||||
# Generate a unique lot name using sequence
|
||||
sequence = self.env['ir.sequence'].next_by_code('stock.lot.serial')
|
||||
if not sequence:
|
||||
# Fallback to timestamp-based name if no sequence exists
|
||||
import time
|
||||
sequence = 'LAB-' + str(int(time.time()))[-8:]
|
||||
|
||||
# Prepare sample values
|
||||
vals = {
|
||||
'name': sequence, # Add the lot name
|
||||
'product_id': sample_type.product_variant_id.id,
|
||||
'patient_id': self.partner_id.id,
|
||||
'doctor_id': self.doctor_id.id if self.doctor_id else False,
|
||||
|
|
Loading…
Reference in New Issue
Block a user