Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
3 Odpowiedzi
5975 Widoki
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"/>





Awatar
Odrzuć
Najlepsza odpowiedź

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

Awatar
Odrzuć
Najlepsza odpowiedź

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

Awatar
Odrzuć
Najlepsza odpowiedź

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)

Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
1
sty 25
1777
0
sie 22
2645
0
mar 22
2625
1
paź 19
5562
2
maj 18
6464