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

Hi,

I can't understand the way when you click on a project (on the dashboard) the new view display only the tasks of this project. I want to do something similar. Can anyone help me, explaining the mechanism or linking some documentation ?

Thanks a lot.


Avatar
Discard
Best Answer

Hi,


The developper doc says you can use a type "action" in kanban box:

Buttons and fields
While most of the Kanban templates are standard QWeb, the Kanban view processes field, button and a elements specially:
    by default fields are replaced by their formatted value, unless they match specific kanban view widgets
    buttons and links with a type attribute become perform Odoo-related operations rather than their standard HTML function. Possible types are:
    action, object   standard behavior for Odoo buttons, most attributes relevant to standard Odoo buttons can be used.   ...


In the project_view.xml you find that the kanban project view is linked to an action called : act_project_project_2_project_task_all:

<div class="oe_kanban_project_list">

                                        <a t-if="record.use_tasks.raw_value" name="%(act_project_project_2_project_task_all)d" type="action" style="margin-right: 10px">                                           

                                        <t t-raw="record.task_count.raw_value"/> Tasks                                       

                                        </a>                                   

</div>


This action ( which is in the same module) filter the tasks of the active project :

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

 <field name="name">Tasks</field>

 <field name="res_model">project.task</field>

 <field name="view_mode">kanban,tree,form,calendar,gantt,graph</field>

 <field name="context">{

    'search_default_project_id': [active_id],

    'default_project_id': active_id,

    'active_test': False,

 }</field>

...

 

Edit :

To use  'search_default_project_id', you must have a search view where one filter named "project_id" exists.

See more explanations here :https://www.odoo.com/forum/help-1/question/set-default-filter-value-in-search-view-5856


If I'm not wrong, the key 'default_project_id': active_id means that, if you create a task, its project_id will be automatically set to active_id ( ie the project you clicked in kanban view).


Avatar
Discard
Author

Hi, thanks a lot for this answer. Maybe my question wasn't precise enough. I saw this view, this action, and I manage do do something similar (displaying some element grouped like I wanted) but I don't understand from where the

" 'search_default_project_id': [active_id],

'default_project_id': active_id,"

syntax come. I tried to find a function that define it but I failed and I can't neither adapt it directly

(I tried :

<field name="context">{

'search_default_myclass_id': [active_id],

'default_myclass_id': active_id,

}</field>

)

Maybe I miss something ?

see my edit

Author

Thanks it works !

I just have one more problem, maybe you can help me :

I have a system of class like this :

class GrandParent(models.Model):

[...]

class Parent(models.Model):

grand_dad_id=fields.Many2One('GrandParent')

children_ids=fields.One2Many('Child)

[...]

class Child(models.Model):

dad_id=fields.Many2One('Parent')

[...]

And when cliking on a grandParent kanban card I would like to display his "family" : his grand children (class child) grouped by parent

I don't know how to acess the "grand_dad" property.

I tried something like :

<record id="view_child_search" model="ir.ui.view">

[...]

<search string="User Stories">

<!-- <field name="dad_id.grand_dad_id"/> -->

[...]

</record>

With in the action on the grand_parent card :

{'search_default_parent':active_id}

Maybe you could create a field or filter (in the search view) using a domain like [('parent_id','child_of',[self])] (or something like that) and using it in you search_default_xxx context key ? (but not sure it's exactly what you need!)

May I suggest to open a new thread with this question ?

Author

Ok I'll do that

Thanks a lot for your help !

Related Posts Replies Views Activity
2
Oct 24
4171
6
Dec 17
7601
0
Apr 20
1996
2
Aug 19
2892
1
Jul 19
2252