[MOV][IMP] account: reorganize qweb / jinja templates used for mailing

PURPOSE

Clean organization of templates in odoo apps: mail.template records in data,
qweb templates (views) used directly in code, notably using post with view.
Purpose is to ease future improvements in posting based on templates.

SPECIFICATIONS

  * move those templates in their own file to ease their discovering and
    maintenance;
  * put them into data (as those are not views even if it contains qweb)
  * guidelines are now :

    -> Qweb templates should be in data/mail_templates.xml;
    -> mail.template records should be in data/mail_template_data.xml;

  * put their declaration in no update when not done if template has no
    technical code or complex dependency on underlying code;
  * move found mail data (mail.message.subtype or mail.activity.type) records
    in a mail_data file that should contain only "core" records linked to mail;

LINKS

Task ID-2375767
COM PR odoo/odoo#61814
ENT PR odoo/enterprise#14775
UPG PR odoo/upgrade#1936
This commit is contained in:
Thibault Delavallée
2020-11-25 12:31:09 +00:00
parent 78c68f4b88
commit da1f3d3ce4
4 changed files with 64 additions and 71 deletions
+2 -3
View File
@@ -22,6 +22,8 @@ You could use this simplified accounting in case you work with an (external) acc
'data/data_account_type.xml',
'data/account_data.xml',
'data/digest_data.xml',
'views/account_report.xml',
'data/mail_template_data.xml',
'views/account_payment_view.xml',
'wizard/account_automatic_entry_wizard_views.xml',
'wizard/account_unreconcile_view.xml',
@@ -45,9 +47,7 @@ You could use this simplified accounting in case you work with an (external) acc
'views/account_chart_template_views.xml',
'views/res_partner_bank_views.xml',
'views/report_statement.xml',
'views/account_report.xml',
'views/terms_template.xml',
'data/mail_template_data.xml',
'wizard/account_validate_move_view.xml',
'views/res_company_views.xml',
'views/product_view.xml',
@@ -64,7 +64,6 @@ You could use this simplified accounting in case you work with an (external) acc
'views/account_journal_dashboard_view.xml',
'views/account_portal_templates.xml',
'views/report_payment_receipt_templates.xml',
'data/payment_receipt_data.xml',
'views/account_onboarding_templates.xml',
'data/service_cron.xml',
'views/account_incoterms_view.xml',
@@ -55,5 +55,34 @@
<field name="lang">${object.partner_id.lang}</field>
<field name="auto_delete" eval="True"/>
</record>
<record id="mail_template_data_payment_receipt" model="mail.template">
<field name="name">Payment Receipt: Send by email</field>
<field name="model_id" ref="account.model_account_payment"/>
<field name="subject">${object.company_id.name} Payment Receipt (Ref ${object.name or 'n/a' })</field>
<field name="partner_to">${object.partner_id.id}</field>
<field name="body_html" type="xml">
<div style="margin: 0px; padding: 0px;">
<p style="margin: 0px; padding: 0px; font-size: 13px;">
Dear ${object.partner_id.name}<br/><br/>
Thank you for your payment.
Here is your payment receipt <strong>${(object.name or '').replace('/','-')}</strong> amounting
to <strong>${format_amount(object.amount, object.currency_id)}</strong> from ${object.company_id.name}.
<br /><br />
Do not hesitate to contact us if you have any questions.
<br/><br/>
Best regards,
% if user.signature:
<br/>
${user.signature | safe}
% endif
</p>
</div>
</field>
<field name="report_template" ref="account.action_report_payment_receipt"/>
<field name="report_name">${(object.name or '').replace('/','-')}</field>
<field name="lang">${object.partner_id.lang}</field>
<field name="auto_delete" eval="True"/>
</record>
</data>
</odoo>
@@ -1,68 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data noupdate="1">
<!--Email template -->
<record id="mail_template_data_payment_receipt" model="mail.template">
<field name="name">Payment Receipt: Send by email</field>
<field name="model_id" ref="account.model_account_payment"/>
<field name="subject">${object.company_id.name} Payment Receipt (Ref ${object.name or 'n/a' })</field>
<field name="partner_to">${object.partner_id.id}</field>
<field name="body_html" type="xml">
<div style="margin: 0px; padding: 0px;">
<p style="margin: 0px; padding: 0px; font-size: 13px;">
Dear ${object.partner_id.name}<br/><br/>
Thank you for your payment.
Here is your payment receipt <strong>${(object.name or '').replace('/','-')}</strong> amounting
to <strong>${format_amount(object.amount, object.currency_id)}</strong> from ${object.company_id.name}.
<br /><br />
Do not hesitate to contact us if you have any questions.
<br/><br/>
Best regards,
% if user.signature:
<br/>
${user.signature | safe}
% endif
</p>
</div>
</field>
<field name="report_template" ref="account.action_report_payment_receipt"/>
<field name="report_name">${(object.name or '').replace('/','-')}</field>
<field name="lang">${object.partner_id.lang}</field>
<field name="auto_delete" eval="True"/>
</record>
<record id="account_send_payment_receipt_by_email_action" model="ir.actions.act_window">
<field name="name">Send receipt by email</field>
<field name="res_model">mail.compose.message</field>
<field name="view_mode">form</field>
<field name="target">new</field>
<field name="context" eval="{
'mail_post_autofollow': True,
'default_composition_mode': 'comment',
'default_use_template': True,
'default_template_id': ref('account.mail_template_data_payment_receipt'),
'custom_layout': 'mail.mail_notification_light',
}"/>
<field name="binding_model_id" ref="model_account_payment"/>
<field name="binding_view_types">form</field>
<field name="groups_id" eval="[(4, ref('account.group_account_invoice'))]"/>
</record>
<record id="account_send_payment_receipt_by_email_action_multi" model="ir.actions.act_window">
<field name="name">Send receipts by email</field>
<field name="res_model">mail.compose.message</field>
<field name="view_mode">form</field>
<field name="target">new</field>
<field name="context" eval="{
'mail_post_autofollow': True,
'default_composition_mode': 'mass_mail',
'default_use_template': True,
'default_template_id': ref('account.mail_template_data_payment_receipt'),
'custom_layout': 'mail.mail_notification_light',
}"/>
<field name="binding_model_id" ref="model_account_payment"/>
<field name="binding_view_types">list</field>
</record>
</data>
</odoo>
@@ -365,6 +365,39 @@
records.action_post()
</field>
</record>
</data>
<data noupdate="1">
<record id="account_send_payment_receipt_by_email_action" model="ir.actions.act_window">
<field name="name">Send receipt by email</field>
<field name="res_model">mail.compose.message</field>
<field name="view_mode">form</field>
<field name="target">new</field>
<field name="context" eval="{
'mail_post_autofollow': True,
'default_composition_mode': 'comment',
'default_use_template': True,
'default_template_id': ref('account.mail_template_data_payment_receipt'),
'custom_layout': 'mail.mail_notification_light',
}"/>
<field name="binding_model_id" ref="model_account_payment"/>
<field name="binding_view_types">form</field>
<field name="groups_id" eval="[(4, ref('account.group_account_invoice'))]"/>
</record>
<record id="account_send_payment_receipt_by_email_action_multi" model="ir.actions.act_window">
<field name="name">Send receipts by email</field>
<field name="res_model">mail.compose.message</field>
<field name="view_mode">form</field>
<field name="target">new</field>
<field name="context" eval="{
'mail_post_autofollow': True,
'default_composition_mode': 'mass_mail',
'default_use_template': True,
'default_template_id': ref('account.mail_template_data_payment_receipt'),
'custom_layout': 'mail.mail_notification_light',
}"/>
<field name="binding_model_id" ref="model_account_payment"/>
<field name="binding_view_types">list</field>
</record>
</data>
</odoo>