콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
3 답글
13610 화면

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?


아바타
취소
베스트 답변

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:


아바타
취소

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

베스트 답변

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

아바타
취소
관련 게시물 답글 화면 활동
2
7월 19
6194
4
10월 24
11473
1
7월 19
3289
0
4월 19
3144
12
4월 24
14076