Skip to Content
Menu
This question has been flagged
3 Replies
5794 Views
I am trying to display stages for a model defined 
as a Many2one field in Kanban view in Odoo 15.
But when I add the stage_id field in Kanban view,
stage_id with records in it are displayed in kanban view but not all stages.

This is my stage_id defined:
@api.model
def _read_group_stage_ids(self, stages, domain, order):
search_domain = [('id', 'in', stages.ids)]
stage_ids = stages._search(search_domain, order=order, access_rights_uid=SUPERUSER_ID) return stages.browse(stage_ids)
stage_id = fields.Many2one(
'idx.repair.stage', string='報修階段', index=True, tracking=True, readonly=False, store=True, copy=False, ondelete='restrict', default=_default_stage_id, group_expand='_read_group_stage_ids') There is the xml part where I use the Many2one field in the kanban view
to be displayed in view:
id="idx_repair_order_kanban_view_leads" model="ir.ui.view">
name="name">idx.repair.order.kanban.lead
name="model">idx.repair.order
name="priority" eval="1"/>
name="arch" type="xml">
default_group_by="stage_id" class="o_kanban_small_column o_opportunity_kanban oe_kanban_global_click" archivable="false" sample="1">
name="stage_id"/>
name="sn_code_id"/>
name="color"/>

t-name="kanban-box">
t-attf-class="#{!selection_mode ? kanban_color(record.color.raw_value) : ''} oe_kanban_global_click oe_kanban_card d-flex flex-column">


class="oe_kanban_content flex-grow-1">
class="o_kanban_record_title oe_kanban_details">
name="sn_code_id"/>


class="oe_clear"/>





Avatar
Discard
Best Answer

Hii  @艾創點-karen,

Please try below code:

def _read_group_stage_ids(self, stages, domain, order):
"""Read group customization in order to display all the stages in the
kanban view, even if they are empty
"""
stage_ids = stages._search([], order=order, access_rights_uid=SUPERUSER_ID)
return stages.browse(stage_ids)

You could either try below code

def _read_group_stage_ids(self, stages, domain, order):
return return self.env['idx.repair.stage'].search([])


Hope this solves your query.

Thanks & Regards,
Email: odoo@aktivsoftware.com
Skype: kalpeshmaheshwar

Avatar
Discard
Best Answer

Hi,

Please try with the code below
state = fields.Selection(
        [('draft', 'New'), ('running', 'Running'), ('stopped', 'Stopped')]
        , string='Status', default='draft'
        group_expand='read_group_stage_ids')

    def read_group_stage_ids(self, states, domain, order):
    
        return [key for key, _ in self._fields['state'].selection]

By using this code you can see all the stages in the kanban view


Hope it helps

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
Related Posts Replies Views Activity
1
Jan 25
1658
0
Aug 22
2543
0
Mar 22
2508
1
Oct 19
5473
2
May 18
6349