Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda
3 Replies
13645 Tampilan

I want to assign my Opportunities an incremental value much like Sales Orders and Delivery Orders.

I have created a Sequence from the Sequences menu in Developer mode:


I have created a custom field on the crm.lead model.

How do I get the value of the field to come from the sequence when a new Opportunity is created?


Avatar
Buang
Jawaban Terbai

You create an Automated Action to listen to record creation and assign the value.

Use the Sequence code to find it and ask it for the next sequence value like this:



If you add the custom Sequence field to the view:


Avatar
Buang

@ray how would this work in v17.

I tried following but its not working

Trigger after creation
Delay 0 hours

Actions to do
Update record
Compute Fuel Log Reference to this python expression

record.env['ir.sequence'].next_by_code('x_fuel_logs')

For some reason, the Form View in 17 has a widget that limits what triggers can be selected, and "on creation" is not available. But it still seems to be there so maybe you can create or update using upload - or use Studio to remove the "improvement".

Removing ON CREATE and ON UPDATE was intentional - read about the change at https://github.com/odoo/odoo/pull/114352 - you can use data import to populate these two options but they are likely to be removed in the future. It appears that ON SAVE is the suggestion option for automations that previously used either of the other two options.

Jawaban Terbai

Hi,

For generating the sequence value for a field in any model,  first create a sequence from the sequence menu under the settings in the debug mode and then we have to create an automated action to assign the sequence value on the record creation.

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

For creating from the code, see this: How to Add New Sequence in odoo

Thanks

Avatar
Buang
Post Terkait Replies Tampilan Aktivitas
2
Jul 19
6203
4
Okt 24
11478
1
Jul 19
3302
0
Apr 19
3164
12
Apr 24
14096