Перейти к содержимому
Меню
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Этот вопрос был отмечен
688 Представления

I am using Odoo 17.

I have created a custom module that opens the mail composer in the "helpdesk.ticket" model extended whenever i click the "Send message" button in the chatter. I have also made it so that when the composer is opened it automatically selects a custom mail template i created within Odoo.

When i click "Send message" it instantly opens the composer in extended mode.


You can see here that the composer opens with a template already set.

This is the model and code that sets the template:
Model: "helpdesk_default_mail_template/models/mail_compose_message.py"
code:

from odoo import models, api

class MailComposeMessage(models.TransientModel):

    _inherit = "mail.compose.message"

    @api.model

    def default_get(self, fields_list):

        res = super().default_get(fields_list)

        if res.get("model") == "helpdesk.ticket" and res.get("subtype_id") == 1:

            template = self.env["mail.template"].search(

                [("name", "=", "Helpdesk Default Mail Template")], limit=1

            )

            if template:

                res["template_id"] = template.id

        return res

 
The only problem i have is that the recipient and body fields are not set with values from the template. I have to open "Load template" and manually select the "Helpdesk Default Mail Template" again, before it sets the recipients and renders the body_html from the template to the body inside the composer.

This is when the composer has just been opened:


And this is after i have manually selected the "Helpdesk Default Mail Template" again:

You can see that the recipients has been set and the body content has been set.

How do i make sure that these two fields are set automatically when the composer is opened just like the template is automatically set when the composer is opened.

Аватар
Отменить
Related Posts Ответы Просмотры Активность
0
мар. 25
29
0
мар. 25
35
0
сент. 24
807
1
янв. 25
814
0
июл. 24
1183