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

In an Odoo view, I can create a button to trigger a specific window action by giving the button a name equal to the database identifier for the action. For example:

<button type="action" name="123">Trigger</button>Will trigger action id 123 when clicked.

Is it possible to accomplish the same thing using the XML ID of the action rather than the database ID?

I'm asking because I have created a module full of data files that include view and window actions. The views include a reference to the ID of the window action since they contain buttons to trigger them. However, I don't know the ID's of the window actions until the module is imported, so I can't include them in the views on the initial import.

Is there any way around this?

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

Yes.

Look at how Odoo does it in the Project module:

<record id="act_project_project_2_project_task_all" 
model="ir.actions.act_window">
...

<button
class="oe_stat_button"
type="action"
attrs="{'invisible':[('use_tasks','=', False)]}"
name="%(act_project_project_2_project_task_all)d"


If the window action is defined in the module where the button is defined, you can do it without a prefix of the module name (like the example above).  If your window action is in a different module (like the project module), prefix it like this:

name="%(project.act_project_project_2_project_task_all)d"
Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
3
thg 6 25
5575
2
thg 12 23
18265
1
thg 7 17
4246
1
thg 11 16
3720
4
thg 3 24
14668