Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
4 Trả lời
1630 Lượt xem

Hi

I am working with Odoo enterprise V16 web based

Currently in my Employee detail I have many2one field contains skill name of the selected employee.

As depicted below, I want to show the skill name on the employee list instead of the record count. How to do it?

Any help will be appreciated. Thanks!



Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Odoo will have created an Extension View, and you can edit that to change the widget:

Change the widget to many2many_tags

More information about Extension Views from Studio 

Ảnh đại diện
Huỷ bỏ
Tác giả

Hi Chris. Nice solution, thanks. But `widget="many2many_tags"` will show the skills as a tag, what widget should I use to show it 1 skill 1 line like I attached in my question above?

I'm not aware of any simple way to do that in Odoo.

Câu trả lời hay nhất

Via studio you can enable "Skill"  many2many field to tree view.

Then group by "Skills"


Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Well you could create a computed field on the Employee Model. Assume skills are related by a skills_id field and that the Skill Model has a skill field titled name. Then reference this computed field in your view.

But this won't really be one skill per line. It's just all the skills on one line (similar to the tags). If you want one per line, you may have to write a Skill view which filters by your selected employee(s) or your the group-by as suggested by someone else.

skills_text = Fields.Text(compute="_compute_skills")
@api.depends('skill_ids')
    def _compute_skills(self):
        for record in self:
            record.skills_text = ", ".join([x.name for x in record.skills_ids])
Ảnh đại diện
Huỷ bỏ

Hi Craig - could this be written to a multi-line text field with a new line for each skill?

Also, could this be added to a computed field through the UI? (I suppose your code is used in development)

Câu trả lời hay nhất

Odoo default seems to be what you are looking for 


Probably you might need to filter (skills != ) and group by employee 

Ảnh đại diện
Huỷ bỏ
Tác giả

yeah correct but that is in employee skills menu. my problem is about showing the skill in employee profile, I want to show the skills name instead of just skills count like "1 record" or "2 records"

Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 7 23
3151
1
thg 5 23
3596
2
thg 5 23
3345
1
thg 5 25
1469
1
thg 8 24
1814