跳至内容
菜单
此问题已终结
2 回复
2993 查看

in project app i can manage stages and select, for what projects will be generated stages columns in kanban


i want do the same in maintenance module by selecting teams in stages, but when i try use in maintenence kanban attribute "default_group_by" it uses all available values from field "stage_id". I try to use domain, rules, but it didnt help. How this mechanism works?


Please help, a try to solve this problem for 2 days.

形象
丢弃
编写者

@m-azzain
i just found solution. In app maintance in field 'stage_id' there was a parameter:
group_expand='_read_group_stage_ids'

and in this function programm chooses all stages.

At start i think, that it is default and try to fix this and do it like in project app. I feel so dumb now)

Now my problem i think is solved, thank you for trying to help.

编写者

@odoo, @odoo_team
i cant delete my own mistake comment and answer to other reply, because CarmaError.
Can it be available for default?

编写者 最佳答案

@m-azzain
i think its not that i need, i want to add in 'maintenance.team'  a field (many2many - available stages), and when i chooce for example columns "new", "in work", "ended", i want, that kanban show me just this columns for team, where i choose it. But problem is that kanban shows all available stages from that many2many field and i dont know, how to hide it.

in app "project" its already realized, for each project you can choose used stages, but i cant find it in code. Maybe this is some of js script there, i dont know.

形象
丢弃

I think you are talking about fold
It is actually quite simple, you just need to have a fold field in the group_by model.

In the case of project module there is a fold field in 'project.project.stage' when you set it to true you will get the corresponding column folded.

but in your case, Many2many field, or even if it is One2Many, this can't be achieved

编写者

@m-azzain
i just found solution. In app maintance in field 'stage_id' there was a parameter:
group_expand='_read_group_stage_ids'

and in this function programm chooses all stages.

At start i think, that it is default and try to fix this and do it like in project app. I feel so dumb now)

Now my problem i think is solved, thank you for trying to help.

You are welcome

@Wald Sin, You mentioning group_expand='_read_group_stage_ids' let me give it a review and found that it is the conditional to activate the fold field, so folding is actually works even with Many2many and One2Many.

最佳答案

If I am correct the stage_id is in 'maintenance.request' and 'maintenance.request' is in 'maintenance.team'
If that the case, I think the problem is about how are you grouping your data
That is when you try to group the teams by stages you will end up with same team appear in many stages, because it has different requests in these stages.

but if you still want to group your team by this way, you need to have a stages field in the team model so that you used it for grouping

stages = fields.Many2many('practice.maintenance.stage', compute='_compute_team_stages', store=True)

@api.depends('request_ids.stage_id')
def _compute_team_stages(self):
for team in self:
team.stages = team.request_ids.stage_id

With regard to the kanban view you can use the above defined field(stages) as a value for default_group_by so that kanban will use it for grouping by default. or you can put it in the search view as a filter in the group tag.

kanban will display whatever grouping you provide, so if you have multiple groups you can define all of them in the search view

形象
丢弃

<record id="maintenance_team_view_search" model="ir.ui.view">
<field name="name">practice.maintenance.team.search</field>
<field name="model">practice.maintenance.team</field>
<field name="arch" type="xml">
<search string="Search">
<field name="stages"/>
<group string='Group by...'>
<filter string='Stages' name="stages" domain="[]" context="{'group_by': 'stages'}"/>
</group>
</search>
</field>
</record>

相关帖文 回复 查看 活动
0
6月 22
1920
0
8月 22
11
1
7月 22
97
1
5月 24
1237
0
3月 22
2789