Skip to Content
Menu
This question has been flagged
3 Replies
25117 Views

Requirement

On helpdesk tags, we want to set a list of documents:

  • Maintenance: User Manual, Specs

  • Troubleshooting: Standard Procedure, Checklist

When a ticket is created and tags are set, we want to have:

  1. Ticket 1 has Maintenance tag --> Ticket 1 displays the User Manual and the Specs documents

  2. Ticket 2 has Maintenance and Troubleshooting tags --> Ticket 2 displays the User Manual, Specs, Standard Procedure and Checklist documents

Prototype

On version 12, we added a many2many field on helpdesk tags to documents.

On the helpdesk ticket, we added a related many2many field to have direct access to all the documents of all the tags selected on the ticket.

Unfortunately, the related field only contains the documents of the first selected tag: On Ticket 2, we only get the User Manual and the Specs documents.

Questions

Is it a bug or an unsupported feature? How can we achieve the requirement?

Thanks!

Avatar
Discard
Best Answer

I'm also interested in the answer to this question as i was able to reproduce the issue, both via Studio and within a custom module. It seems that a Many2many field that is related to another many2many field doesn't pull all the results, just the results of the first record. I was able to work around this issue by not using a related many2many field and instead just using the following code with an onchange event:

helpdesk_tag.py

from odoo import models, fields, api
class HelpdeskTag(models.Model):
    _inherit = 'helpdesk.tag'
    documents = fields.Many2many('ir.attachment', string="KB Documents")
    documents_folder = fields.Many2one('documents.folder', string="KB Documents Folder") #This allows the use of domain filtering on the tag list view

helpdesk.py

from odoo import models, fields, api
class Helpdesk(models.Model):
    _inherit = 'helpdesk.ticket'
    kb_documents = fields.Many2many('ir.attachment', string="KB Documents")
    @api.onchange('tag_ids')
    def on_change_tag_ids(self):
        self.kb_documents = [(6, 0, [])]
        for record in self:
            for i in record.tag_ids:
                record.kb_documents = record.kb_documents + i.documents

This seems to work as intended and shows all the related tag documents when the tags are changed on the ticket however this might not be the best option and it would be nice if the related field would just work as you would imagine it should.

Avatar
Discard
Best Answer

Dear Maxime,

I didn't understand your requirement, it seems a little bit confusing but I am giving you the link to the Odoo tutorial  where they explained clearly the relations when adding many2many fields and the options of Odoo Studio. Everything in the video can be done with the studio in the Settings app. It's a bit longer and complexe, but it is possible. If you don't have access to Odoo Studio, try it and I will tell you where to add those fields. The video is here:

https://www.youtube.com/watch?v=nF152j_csbo

Cheers!

San Aguayo

Avatar
Discard
Author

I gave more details in the original question hoping it would solve the confusion...

Related Posts Replies Views Activity
1
Oct 20
5734
2
Aug 19
2612
1
Feb 24
836
2
Apr 23
4983
0
Jul 24
1500