Hi all.
Found a solution myself.
Its a quite forceful approach but nothing else worked till now.
Basic Idea:
Don't replace or modify the jinja email templates.
Just replace its translation!
That approach works for any language, even the base language.
The html bodies and subjects of those jinja email templates are used as keys to find a translation.
If its present it will be used instead the original text elements.
Changing existing translations could be easily done using the email template dialog at the technical menu.
But how to change it by installing a module?
Usually already existing translations are not replaced by a custom moduls .po file.
For that to achieve you have the reload the entire language with the replace option checked.
Especially when the translation resides in a module like base, sales or any other core module this approach does not help because reloading the language in full will restore the original templates too.
To change those translations they have to be deleted and to be created anew by your module.
Fortunately we have a tool at hand to achive exactly this.
Here are the steps to change the email templates of a given language.
1.) Make a backup of your database in case something goes awfully wrong.
No kidding. There may happen some weired things with the translation mechanism.
At least on my side I broke the translation several times by now and the only way back was to restore a proper backup of the whole system. As soon as you have the replacement modul working, its stable and easy to use though.
2.) Edit the template translation manually using the email template dialog at the technical menu and test them
Yes, its way more convenient to 'develop' and 'test' the new templates on a dev, test or staging environment using the ui instead of a installable module. So you have always a live backup at hand (at the production instance) in case you need to revert to a proper working template translation.
3.) Find out the names of the modules that are inplementing the email templates you want to change.
In my case the list contained:
account
auth_signup
purchase
sale
website_portal
website_sale
But this depends on your installed modules.
4.) Export the translations of those modules for your desired language into a single .po file
5.) Create a module that deletes all email template translations of your choice by issuing an xml statement like this:
<delete model="ir.translation" search="[('name','like','mail.template'),('lang', '=','de_DE')]"/>
6.) Place the above created .po file (in this case with the name 'de.po') inside the translation folder of the modul.
This will whipe all german email template translations and replaces them with the ones defined in the de.po file as soon as you install or upgrade the modul.
During development of your templates that approach is easy to use and only requires an update of that modul as soon as you change the content of the modules .po file.
As soon as you are done with development of the templates you should fine tune the module.
Find proper domain search clauses to delete just the template you want to change and not just all of them. This usually requires to look into the original src column of the translation records to find something unique and then create proper delete xml's like this:
<!-- Delete german mail template translations -->
<!-- Template body and subject will be loaded again via the translation de.po file -->
<!-- Auth Signup: Odoo Account Created -->
<delete model="ir.translation" search="[('module', '=','auth_signup'),('name','=','mail.template,subject'),('lang', '=','de_DE'),('src','=','Welcome to ${object.company_id.name}!')]"/>
<delete model="ir.translation" search="[('module', '=','auth_signup'),('name','=','mail.template,body_html'),('lang', '=','de_DE'),('src','like','Your account has been successfully created!')]"/>
<!-- Auth Signup: Odoo Connection -->
<delete model="ir.translation" search="[('module', '=','auth_signup'),('name','=','mail.template,subject'),('lang', '=','de_DE'),('src','=','${object.create_uid.name} from ${object.company_id.name} invites you to connect to Odoo')]"/>
<delete model="ir.translation" search="[('module', '=','auth_signup'),('name','=','mail.template,body_html'),('lang', '=','de_DE'),('src','like','You have been invited by ${object.create_uid.name} of ${object.company_id.name} to connect on Odoo')]"/>
This code snippet deletes just the auth sign up and account creation email template by selecting their respective html body and subject translation. The .po file of the module then only need to contain those deleted translation records.
To find those entries in the .po file and extract them into a reduced .po file could easily be done using a text editor with search capability. My tool of choice for all odoo development tasks including this is PyCharm.
However one should be quite familar with the structure of .po files to not break the very lengthy html_body translations. Especially when it comes to further or later changes to those templates. Editing the content of such a reduced .po files is better done using POEdit or like tools designed for such translation files to avoid any formating issues.
Regarding the name of your modul I would suggest to place a 'x_' in front like 'x_MyEmailTemplates'. This ensures that your module is the last one processed when it comes to upgrades.
Good luck and remember taking a backup first prior issuing any delete statements that mangle with translations or any other table at the database. Otherwise you may not be able to recover from any mistake easily without fully reinstalling odoo from scratch.
Cheers
Stephan