Siirry sisältöön
Menu
Sinun on rekisteröidyttävä, jotta voit olla vuorovaikutuksessa yhteisön kanssa.
Tämä kysymys on merkitty
3755 Näkymät

I've been asked to develop a tag system for attachments.

While for attachments I've used the Document Management System module, I didn't find anything useful for tag management.

Thus, I've developed my own, custom module in which attachments (ir.attachment model) have been extended with a Many2many relation with a tag model, that in turn represents... a tag, and has a tag field representing the actual tag's textual content.

Then I've been struggling with search by tag... 

The problem here is that the searched term has to be compared with a related object's fields (i.e. the tags), not with a field of the attachment itself.

So I came up with a workaround. I've extended the attachment model with:

  • a computed char field called tags with an associated custom search method _search_tags

  • a boolean field called found_by_tag

_search_tags is invoked each time a search is performed and its job is to set the flag found_by_tag to the proper value, based on the searched term.

Thus, the expression for the search view becomes [('found_by_tag', '=', True)].

Note: For the actual code, check this stack overflow question: http://stackoverflow.com/questions/34086330/odoo-implementing-a-tag-system-for-attachments

While the workaround actually works, I'm wondering if that's too much. Is there a simpler way to implement a search by tag? Or, alternatively, is there a module that may be used for this purpose?

Avatar
Hylkää
Aiheeseen liittyviä artikkeleita Vastaukset Näkymät Toimenpide
0
jouluk. 24
1569
1
lokak. 23
3867
1
maalisk. 23
6789
2
huhtik. 22
4236
2
jouluk. 21
7718