Skip to Content
Menu
This question has been flagged
3 Replies
4204 Views

Hello community, Happy 2021


At our company, we would like to give numbers to leads - Lead #1, #2 and so on, automatically. Can Odoo do that?


Thanking you in advance,


LB

Avatar
Discard
Author

Thank you everybody for your help with this question. Amazing the power of this community! Happy 2021!

Best Answer

Hello, 


You can add integer filed with name of id like below:


id = fields.Integer(string="ID")


I hope it's working.


Thanks

Avatar
Discard
Best Answer

Hello Luis,

You would first need to create a new ID field as Manish said but for what you want to achieve there is a bit more to this. 

You would also need to create a sequence which can be seen here. The fields are pretty obvious to understand, in your case you would want a sequence size if 0 as for no padding, step of 1 and the next number would be 1 (starting number for now). Keep note of the "Sequence Code", this will be used later. This can be found in Settings->Technical->Sequences, here is my example

You would then need to create an automated action which will get this new number and assign it to the new field that you have created. For this, you would need to go to Settings->Technical->Automated Actions. Create a new one with the relevant fields: Model->Lead/Opportunity, Action To Do->Update the record, Trigger->On creation. Then in the One2Many select your new field set it as a Python Expression and write the value:

record.env["ir.sequence"].next_by_code("")

Now when creating a record you should be good to go. 

Hope this helps, 

Thanks, 

Avatar
Discard

Hi there, can this be done in a Standard subscription database? If not, is there any workaround?

Hi Samuel - this should be possible with the Standard subscription on Odoo Online (it does *not* need Studio). You need to be in Developer Mode. There's a full description here: https://odootricks.tips/sequence-document-numbering/

I've tried it but I guess there is the need to create a new field and that won't be possible in Standard. But if you know how to do it without the creation of a field, explain it please :)

My mistake, I hadn't read the answer in full. However...

It should be possible without Studio but it is more difficult. You should be able to create a field from the Technical menu and even create an Extension View to display it (I'd probably do it in a demo database using Studio and then copy the XML).

Best Answer

Hi,

If you need to set the sequence for the lead without any custom modules, ie from the user interface itself, you can add a new field using the developer mode and also assign a sequential value using the Automated action in Odoo.

To add a field to hold the sequence in the lead, we can do like this:  How to Add Custom Field From User Interface In Odoo

Once the field is added to the view, we need to set the auto incremental sequential value, for that you can create a automated action, for that Settings -> Technical -> Automation -> Automated Action.


See: Assign Sequential Value For Field Using Automated Action And Sequence


If yo don't want to do from ui itself, you can do it from the custom module, for that see how sequential value can be set from code in odoo: How to Add New Sequence in odoo12


Thanks

Avatar
Discard
Related Posts Replies Views Activity
1
Nov 18
3267
3
Jul 25
4498
4
Aug 24
1820
1
Jun 24
1946
1
Jan 24
2233