Skip to Content
Menu
This question has been flagged
1 Reply
2822 Views

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.


Avatar
Discard
Best Answer

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')],
}


Avatar
Discard
Related Posts Replies Views Activity
1
Oct 21
2596
1
Apr 24
1115
1
Apr 24
511
3
Jun 23
6732
0
Jun 21
1990