Skip to Content
Menu
This question has been flagged
2 Replies
2010 Views

hello

This is on Odoo Online 17

Iam trying to make new sequence but its not working


1- I have made the sequence

Sequence Code: patientid.seq

Implementation: Standerd

Sequence Size: 5

Step: 1

Next Number: 1



2- I have made the Automation Rules

Model: Contact

Trigger: On Save

When updating: patient id   ( which the number that have to be increased )


Actions To Do: Execute Code

if not vals.get('x_studio_medical_id'): 

        vals['x_studio_medical_id'] = env['ir.sequence'].next_by_code('patientid.seq')


Name of the field : x_studio_medical_id


its not working how can i fix it 


Avatar
Discard
Best Answer

Hi,
Adding a small point to the other answers,
it will be good to iterate the records variable:

for record in records:
  if not record.x_studio_medical_id:
     record['x_studio_medical_id'] = env['ir.sequence'].next_by_code('patientid.seq')

For more, see this sample:  Generate Barcode For Products Using Automated Action In Odoo


Thanks

Avatar
Discard
Best Answer

Please try this code


if not record.x_studio_medical_id: 

         record.write({'x_studio_medical_id' : env['ir.sequence'].next_by_code('patientid.seq')})

Avatar
Discard