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

Hello all,

I know that if I click on this button, it throws the method button_proforma_voucher. But the

For example, button_proforma_voucher method takes 5 arguments. Where does the button view take its arguments to throw the associated method?

In the view :

<button name="button_proforma_voucher" string="Register Payment" class="oe_highlight" type="object"/> 


In the python code, the method has already ids value. Where does it take thid ids? :

def button_proforma_voucher(self, cr, uid, ids, context=None):

    _logger.error(" ids :: %s", str(ids))


Thanks to help

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

Hi #Pascal

A button is not more that a way to execute an action call on the server, so if you wanna trace where the args are builded to call your button method you could see at do_execute_action function of /openerp/addons/web/static/src/js/views.js

Depending on the button action type it will be how the args get retrieved, for example a button type="object" it will call to the url "/web/dataset/call_button" that trigger the controller method call_button of the DataSet controller at /openerp/addons/web/controllers/main.py. A button type="action" it will call to the url "/web/action/load" that trigger the controller method load of the Action controller at /openerp/addons/web/controllers/main.py. For the workflow button type it will call to the url "/web/dataset/exec_workflow" that trigger the controller method exec_workflow of the DataSet controller at /openerp/addons/web/controllers/main.py

In your case it's a type="object" you could find that the [cr, uid] args get passed by the _call_kw method and the rest of the args came from the js function do_execute_action where for the type="object" it collect the record_id and the context to send it to the call_button url

Hope this helps to clarify the topic

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
2
thg 6 22
10013
3
thg 12 23
2726
0
thg 8 23
1859
2
thg 11 20
11620
1
thg 2 24
8114