I'm having difficulties to create a template on Odoo 12.0. So, i need to understand how i can create a new template that appears in the panel of select a template in mass mailing when i'm configurating my campaing, because i can't find the ones there are already done in odoo for default as well. If anyone can guide me on this, i will be really grateful. Good day!
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Accounting
- Inventory
- PoS
- Project
- MRP
This question has been flagged
Hi Manuel
The first thing that you need to do is add a dependency to other modules that you’ll need,
'depends': ['mail'],
The next step is to create a new XML record like given are below,
<record id="email_template" model="mail.template">
<field name="name">EMAIL TEMPLATE</field>
<field name="model_id" ref="emai_template.model_example.mail"/>
<field name="auto_delete" eval="True"/>
<field name="email_from">${(object.res_user_id.email}</field>
<field name="email_to">${object.client_name.email}</field>
<field name="report_template" ref="action_example_pdf"/>
<field name="subject">${object.amc}</field>
<field name="body_html"><![CDATA[
<p>Dear ${(object.client_name.name)},<br/><br/>
Good job, you've just created your first e-mail template!<br/></p>
Regards,<br/>
${(object.company_id.name)} ]]></field>
</record>
Odoo e-mail templates come with jinja2 by default. This means that you can access any value on a record and fill it in on the e-mail automatically,
eg:-
<field name="subject">${object.amc}</field>
The next thing is we want to create python function like given below.
@api.multi
def action_send_amc(self):
self.ensure_one()
ir_model_data = self.env['ir.model.data']
try:
template_id = ir_model_data.get_object_reference('module_name', 'template_name')[1]
except ValueError:
template_id = False
try:
compose_form_id = ir_model_data.get_object_reference('mail', 'email_compose_message_wizard_form')[1]
except ValueError:
compose_form_id = False
ctx = {
'default_model': 'exmaple.email',
'default_res_id': self.ids[0],
'default_use_template': bool(template_id),
'default_template_id': template_id,
'default_composition_mode': 'comment',
'mark_so_as_sent': True,
'force_email': True
}
return {
'type': 'ir.actions.act_window',
'view_type': 'form',
'view_mode': 'form',
'res_model': 'mail.compose.message',
'views': [(compose_form_id, 'form')],
'view_id': compose_form_id,
'target': 'new',
'context': ctx,
}
Regards
Thanks for your reply!
I understand what you send me about the coding that i need to do to achieve the part of creating new templates in the module of mass mail.
But what I’m missing is the part of where I can do that? All those steps that you indicated me, are in the configuration panel, in which item?
If you could please guide me on where to do it, I’ll be really grateful.
Regards!
Enjoying the discussion? Don't just read, join in!
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign up