Skip to Content
Menu
This question has been flagged
1 Reply
2553 Views

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?

Avatar
Discard
Best Answer

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

Avatar
Discard

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

Related Posts Replies Views Activity
1
Oct 23
3281
2
Dec 21
7386
4
Dec 18
8508
2
Mar 15
7718
2
Jan 25
798