Skip to Content
Menu
This question has been flagged
2 Replies
3407 Views

Hello,

I have created a QWeb report on the tasks, that I can launch from the list view of tasks (menu print after selecting e few tasks).
I also managed to launch it from the task form view in a button:

    <button class="oe_stat_button" type="action" name="600" icon="fa-file-o" string="My Report" />

Now, I would like to be able to launch it from a project form view, like if I had selected all its tasks in the task list view : what should I add in the button code so that it passes the tasks to the report ?
I tried to add "args" or "context", but it doesn't work (or I don't know the right syntax).

(I'm using Odoo 12 for now)

Thanks for your help !
Avatar
Discard
Author Best Answer

Thank you Eduardo for your answer.
But I'm not sure to understand what to do with that...
Where should I put this xml code ? Directly In the form view ?
And how do I call it then ?


I tried to modify the button code in the project form. adding the context, but it doesn't work better.

    <button class="oe_stat_button" type="action" name="600" icon="fa-file-o" string="My Report" context="{'active_ids': task_ids}" />

When clicking, I get the report generated on the first task of the first of all my projects...

Avatar
Discard
Best Answer

Maybe you could call an ir.actions.server and return the print report action with other active ids.

<record id="project_redirect_report_with_all_tasks" model="ir.actions.server">
    <field name="name">Redirect to task reports with all project tasks</field>
    <field name="model_id" ref="project.model_project_task"/>
    <field name="binding_model_id" ref="project.model_project_project"/>
    <field name="binding_type">action</field>
    <field name="state">code</field>
    <field name="code">[action] = env.ref('my_other_print_action_report').read()
action['context'].update({'active_ids': records.mapped('task_ids').ids})
    </field>

 

Avatar
Discard
Related Posts Replies Views Activity
0
Dec 21
3531
2
Oct 20
3063
0
Aug 19
3192
1
Aug 19
9266
2
Jul 23
784