This question has been flagged

In the CRM App sometimes there is the need to associate a number (id) to every lead generated. The one Odoo generates is not useful because it keeps count of the previous records, even if deleted.

To have create a custom sequence , or make Odoo start counting where you want, an Automated Action with Studio is necessary:

1. Create a field within Opportunity for an integer number:


2. Go to Studio/Automated Actions and create one

3. Select Lead/Opportunity model

4. Activate it 'when creating'

5. Apply to all registers

6. Action to do: Update register

Data to Write: 

Select the created integer field.

Set python expression: str(record.id)

If you have already 1000 leads in the database and want to start counting from lead 1001 (allocating ID=1 and so on from there), set str(record.id-1000). This way, Odoo will generate ID 1001-1000= 1 and start sequencing from there for the following leads created/imported.

Attention: If you need to import leads again, make sure to deactivate the Automated Action during the import process and activate it again after, also updating the Python expression number (previous number set+number of leads imported) to maintain the sequence integrity.


Avatar
Discard