This question has been flagged
2 Replies
13794 Views

I have taken state(selection field) in project and displaying those states in kanban view. Now I have override the read_group() method to display all states so that I can drag & drop record from one state to other state.

But when I click on that kanban view, form view is not opening .

help me out.Thanks in advance

Following is the kanban view. (odoo-10 Enterprise version)

<record id="project_kanban_view2" model="ir.ui.view">
            <field name="name">project.kanban.view</field>
            <field name="model">project.project</field>
            <field name="arch" type="xml">
                <kanban default_group_by="state" class="o_kanban_small_column">
                    <field name="state" options='{"group_by_tooltip": {"requirements": "Description", "legend_priority": "Use of stars"}}'/>
                    <field name="name"/>
                    <field name="user_id"/>
                    <field name="color"/>
                    <field name="task_count"/>
                    <field name="task_needaction_count"/>
                    <field name="label_tasks"/>
                    <field name="task_ids"/>
                    <field name="alias_id"/>
                    <field name="alias_name"/>
                    <field name="alias_domain"/>
                    <field name="doc_count"/>
                    <field name="is_favorite"/>
                    <templates>
                        <field name="date_start"/>
                        <t t-name="kanban-box">
                            <div t-attf-class="#{kanban_color(record.color.raw_value)} oe_kanban_global_click_edit"> <!--oe_kanban_global_click-->
                                <div class="o_dropdown_kanban dropdown">
   
                                    <a class="dropdown-toggle btn" data-toggle="dropdown" href="#" >
                                        <span class="fa fa-bars fa-lg"/>
                                    </a>
                                     <ul class="dropdown-menu" role="menu" aria-labelledby="dLabel">
                                        <t t-if="widget.editable"><li><a type="edit">Edit</a></li></t>
                                        <t t-if="widget.deletable"><li><a type="delete">Delete</a></li></t>
                                        <li><ul class="oe_kanban_colorpicker" data-field="color"/></li>
                                    </ul>
                                </div>
                                <div class="oe_kanban_content">
                                    <div>
                                    <strong><field name="name"/></strong>
                                    </div>
                                    <div>
                                        <field name="user_id"/>
                                       
                                    </div>
                                    <div class="o_kanban_footer">
                                         
                                    </div>
                                </div>
                                <div class="oe_clear"></div>
                            </div>
                        </t>
                    </templates>
                </kanban>
            </field>
        </record>

Avatar
Discard
Author

Thanks for the reply. There is code for project.project i.e. written for the Project Dashboard(kanban view). In Project dashboard kanban view, class="o_project_kanban_boxes" is written for div and anchor a is written for Task action, when clicked on Project Dashboard (In div) then it opens Task view.

In my case when I clicked on my project kanban view , process will go in if condition (js )but there is code which for [division class anchor] (Task)..so that my project form view is not opening.

But when I comment code -this.$('.o_project_kanban_boxes a').first().click(); and write else part code - this._super.apply(this, arguments); Then my form view will open properly.

But this wont work for the Dashboard click.

 

if (this.model === 'project.project') {

this.$('.o_project_kanban_boxes a').first().click();

} else {

this._super.apply(this, arguments);

}

Best Answer

By default Odoo kanban cards click open related objects form views.

However, for projects, it is re-written on js level. Have a look at project/static/src/js/project.js You have re-defined kanban view and currently this part leads to incorrect result

this.$('.o_project_kanban_boxes a').first()

What you should do:

* redefine project.js in your module

* in the function 'on_card_clicked' do nothing: a click then would lead to a project form view

Avatar
Discard