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

I have a lot of tags. most of them are like:

ABC/DEF/GHI/XYZ

As Odoo is showing the whole 'path' of the tags it is not easy to see what tags a customer has:

https://www.dropbox.com/s/hhi9n8mg7yqaikw/OdooTags.jpg?dl=0



Is there a way to only show the last level of the tags?

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

Hi,

Pass  partner_category_display == short in the field context or action context, then it will show only the exact name instead of parent/name.


Sample: context="{'partner_category_display': 'short' }"


See the name get function:

def name_get(self):
""" Return the categories' display name, including their direct
parent by default.

If ``context['partner_category_display']`` is ``'short'``, the short
version of the category name (without the direct parent) is used.
The default is the long version.
"""
if self._context.get('partner_category_display') == 'short':
return super(PartnerCategory, self).name_get()

res = []
for category in self:
names = []
current = category
while current:
names.append(current.name)
current = current.parent_id
res.append((category.id, ' / '.join(reversed(names))))
return res

Thanks

Ảnh đại diện
Huỷ bỏ

I tried using this with the tags in documents.document and it give me this error:

names = dict(self.name_get())
File "/home/odoo/src/user/fieldservice_extended/models/equipment.py", line 217, in name_get
current = current.parent_id
Exception

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/home/odoo/src/odoo/odoo/http.py", line 640, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception)
File "/home/odoo/src/odoo/odoo/http.py", line 316, in _handle_exception
raise exception.with_traceback(None) from new_cause
AttributeError: 'documents.document' object has no attribute 'parent_id'

Does the tag system in documents work differently. I want the same result as the OP where it only shows the final tag instead of the whole breadcrumbs in the tree list

Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 10 23
3741
2
thg 12 21
7665
4
thg 12 18
8689
2
thg 3 15
7972
2
thg 1 25
977