This question has been flagged
5 Replies
9289 Views

Is it possible to make changes to addons/mail/data/mail_data.xml, without changing the file itself, but with a custom module?

I want to change the header with send with Odoo removed

Avatar
Discard
Author

I tried it with this, but no luck:


<record id="mail_template_data_notification_email_default" model="mail.template">

<field name="body_html">=

Best Answer

create the demo data with the same id  in your custom module

And  in parallel use delete  tag to delete the already created demo data like

<delete model='mail.mail' search="[('id','=',ref('mail.ir_cron_mail_scheduler_action'))]" />
Avatar
Discard
Best Answer

Hi Mario, more then 3 years has passed since your request, so I guess you already found a solution, but I will post what I've made here as reference for anyone who got similar issues.

For what I've seen googling around many people suggest to override the original template by simply putting the model name followed by the name of the template view. But this alone will not work. One way to force it works, by fooling the noupdate field, is to delete the template and create a new one with the original id, as suggested here by Prakash. However, this is very risky, since other models my reference the original template.

So, I've made an override of the _rendere_template method in the mail.template Class:

class MailTemplate(models.Model):
_name = 'mail.template'
_inherit = 'mail.template'

mail_template = []

@api.model
def _render_template(self, template_txt, model, res_ids, post_process=False):
import pdb; pdb.set_trace()
self.mail_template.append(self.__dict__['_prefetch']['mail.template'])
if your_template_id in self.mail_template[0]:
if model == 'project.task' and post_process is True:
if type(res_ids) is list:
if template_txt:
template_txt = """
put your body_html text here
"""
res = super(MailTemplate, self)._render_template(template_txt, model, res_ids, post_process)
return res

The html_body is contained in the template_txt variable when post_process is true (this is method is called in a for cycle where all the template fields are passed, so we need to make sure to rewrite the template_txt when this is really the html_body). Then we need to pass the id of the template we want to override, otherwise we will override any mail template, each time we are gonna send an email (which, of course, is no good).

Hope this will help other people who want to override an original mail template without deleting it.

Cheers, 

Avatar
Discard
Best Answer

If what you're looking for is to remove the sent using odoo message search for the Notification Emails template and remove that whole small code paragraph that you can see there at the right. 

Avatar
Discard
Author

I know that, but I want to use a module for that: For odoo 9+ footer can be customized via Template Activate developer mode (Top right-hand corner -> About) Navigate to Settings\Technical\Email\Templates Select (set checkbox) "Notification Email" record click Action ->Export add field "Body" to export fields click "Export to Field" open csv via your editor Change footer as you need Navigate to Settings\Technical\Email\Templates click "Import" Validate and Import your file