İçereği Atla
Menü
Bu soru işaretlendi
1 Cevapla
2614 Görünümler

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
Vazgeç
En İyi Yanı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

Avatar
Vazgeç

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

İlgili Gönderiler Cevaplar Görünümler Aktivite
1
Eki 23
3381
2
Ara 21
7457
4
Ara 18
8566
2
Mar 15
7775
2
Oca 25
862