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

I am currently using Odoo 12 and I need assistance in getting the active id from the URL instead of from the context. The reason for this is because the active_id/active_ids change to the selected values on the tree for the server action therefore i was wondering if it was possible to get the active_id that is currently in the URL or even retrieve the previous context as that has the ID i am looking for. 


I tried using the http library to get the full URL such as the below code:


http.request.httprequest.__dict__


But it does not return the get paramaters.


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

You can check active_ids from the context in the function of binded model.

example

model="ir.actions.server" id="demo_failure_action">
name="name">Failed to install demo data for some modules, demo disabled
name="model_id" ref="base.model_ir_demo_failure_wizard"/>
name="state">code
name="code">
active_ids = env.context.get('active_ids')
failures = env['ir.demo_failure'].search([
('wizard_id', '=', False),
])
record = model.create({
'failure_ids': [Command.set(failures.ids)],
})
action = {
'type': 'ir.actions.act_window',
'res_id': record.id,
'res_model': 'ir.demo_failure.wizard',
'target': 'new',
'views': [(env.ref('base.demo_failures_dialog').id, 'form')],
}


Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 10 21
3446
1
thg 4 24
3131
1
thg 4 24
1722
1
thg 4 25
3190
3
thg 6 23
10807