Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
4 Trả lời
1451 Lượt xem

Hello all, 

I need to automatically record["company_id"] = env.company on creation in res_partner. 


The code works, the trigger on the hand is hidden in UX. Can't find the trigger "On creation". I have work around that will do for the moment. How can I find that trigger 

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hello Valentin

In Odoo 17, Odoo deprecated the triggers On Creation, On Update, On Creation & Update, they were replaced by the trigger On save.

This trigger is called whenever the record is saved whether its creation or updating the record, however you can utilize the When updating Field to perform the action only at creation.

For example you can set the field When updating to Created On or Created By, As these fields only change at the creation of the record.

Here is an Example of how your rule will look like

I hope this helps

If it helps please upvote my answer and Mark it as Correct

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hello, 


Sorry, I misunderstood the problem. After checking Odoo, it seems that in Odoo 17 and later, we can use the following instead:

on_create_or_write : On save



Thanks


Ảnh đại diện
Huỷ bỏ
Tác giả

Anas, judging the UX you are in V16 or earlier version. I'm working in V18 as said in the title. The on_creation trigger does not appear.

Câu trả lời hay nhất

The UI has changed again in version 18.3... we now have 'On create' back again, and 'On create and edit' is the same as 'On save'.


Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Use On save and select "Created on" or "ID" in "When updating?"




Ảnh đại diện
Huỷ bỏ