Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
3752 มุมมอง

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?

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
0
ธ.ค. 24
1559
bulk assign tags in contacts แก้ไขแล้ว
1
ต.ค. 23
3860
How to set attachments to public? แก้ไขแล้ว
1
มี.ค. 23
6769
2
เม.ย. 22
4230
2
ธ.ค. 21
7718