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

Hello,

How can I create a field using Odoo 17 Studio that auto increases with every new purchase order?

For instance, a purchase order #P0001 can have tracking number TN0001, then the next purchase order TN0002, and so forth. I also need the numbers to be auto generated and to be unique without duplicates. 

아바타
취소
베스트 답변

First go to Settings -> Technical->Sequences.  Create a new sequence.  It is quite straight forward, well explained in the interface.

The go to Settings->Technical->Automation Rules. Create a new rule. Set the model to Purchase and the trigger = On creation.  Action: Execute Python code.

Python code would look something like this:

for record in records:

    record['your field name'] = env['ir.sequence'].next_by_code('your sequence')




아바타
취소
베스트 답변

Hi, you can follow these steps, but before proceeding with the code, you need to create a sequence record.

Go to Settings -> Technical -> Sequences to create the sequence record before implementing the code.

To automate sequence generation for the Purchase model, follow these steps:

  1. Go to Settings -> Technical -> Automation Rules.
  2. Create a new rule.
  3. Set the Model to Purchase Order.
  4. Set Trigger to On Creation.
  5. Action: Choose Execute Python Code.

In the Python code block, use the following:

for record in records:
    record['field_name'] = env['ir.sequence'].next_by_code('purchase.order.tn')

Replace 'field_name' with the appropriate field where you want to store the sequence.

아바타
취소
관련 게시물 답글 화면 활동
1
5월 24
1550
1
2월 23
3238
1
9월 21
3683
0
10월 24
1010
1
11월 24
1481