تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
3741 أدوات العرض

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?

الصورة الرمزية
إهمال
المنشورات ذات الصلة الردود أدوات العرض النشاط
0
ديسمبر 24
1554
1
أكتوبر 23
3853
1
مارس 23
6766
2
أبريل 22
4227
2
ديسمبر 21
7713