This question has been flagged
3 Replies
19535 Views

Hello All,

I am working on odoo 10 kanban view of purchase order module in which i created a new stage field(many2one relation with stage module) and  as per define stage in  purchase order kanban view get order as per stage 

But as per requirement i want to show all stages including empty one. for that i follow below link 

http://ludwiktrammer.github.io/odoo/odoo-grouping-kanban-view-empty.html

but  i did not find " group_by_full" attribute in kanban view  and not in any other modules like sale or project kanban view

Below in my module.py code in which i try to implement "group_by full" but it did not for me

@api.multi   

def stage_groups(self):   

   postage = self.env['stage.stage'].search([]).name_get() 

   return postage 

group_by_full = {'po_stage': stage_groups,}


below is my view code :

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

<field name="name">purchase_kanban</field>   

<field name="model">purchase.order</field>   

<field name="inherit_id" ref="purchase.view_purchase_order_kanban"/>  

  <field name="arch" type="xml">     

<!-- Adding attribute -->     

<xpath expr="//kanban[@class='o_kanban_mobile']" position="attributes">           

<attribute name="default_group_by">po_stage</attribute>          

    <attribute name="group_expand">_read_group_stage_ids</attribute>     

    </xpath>     

    <xpath expr="//kanban[@class='o_kanban_mobile']" position="inside">       

          <field name="po_stage"  />

    </xpath>   

</field> 

</record>


so kindly suggest how i can achieved this in odoo 10




Avatar
Discard
Best Answer

group_by_full has been replaced in Odoo 10 by group_expand which is a different (better IMHO) mechanism.

See this SO answer for more details: https://stackoverflow.com/a/40761734/2498426

Avatar
Discard
Best Answer

Just in case someone would come by here and want to know:

If you go in the Debug -> Modify Action, and add in the context {'default_project_id': x} (x being the actual project ID), it will do the trick.

At least from 15>, didn't try on

Coming from standard:


    @api.model

    def _read_group_stage_ids(self, stages, domain, order):

        search_domain = [('id', 'in', stages.ids)]

        if 'default_project_id' in self.env.context:

            search_domain = ['|', ('project_ids', '=', self.env.context['default_project_id'])] + search_domain


        stage_ids = stages._search(search_domain, order=order, access_rights_uid=SUPERUSER_ID)

        return stages.browse(stage_ids)

Avatar
Discard
Best Answer

Hello 

as per consider the code that mention  in the first link 

you can not use many2many field in group by clause 

Avatar
Discard

If you mean many2one as it is stated in question, in sources of odoo 10 you may see many2one field project.task.stage_id and it's work