Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
3 Odpovědi
13106 Zobrazení

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
Zrušit
Nejlepší odpověď

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
Zrušit

@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.

Nejlepší odpověď

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
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
2
čvc 19
5582
4
říj 24
10301
1
čvc 19
2993
0
dub 19
2546
12
dub 24
13147