Skip to Content
Menu
This question has been flagged

HI.

I want to know inside sales quotations, how to contect sale_order_template_id (quotation template) with use template ( from mail.template) in a way that if I select one quotation template then gets an specific  mail template.

Im willing to do it on python code but im a little lost,

 any help is well received;

Avatar
Discard
Best Answer

Hi,

Override the action_quotation_send function and pass the required mail template with condition of selected quotation template.

def action_quotation_send(self):
self.ensure_one()
if self.sale_order_template_id.id == 'condition':
template_id = self._find_mail_template()# select the required mail template id
lang = self.env.context.get('lang')
template = self.env['mail.template'].browse(template_id)
template.attachment_ids.unlink()
if template.lang:
lang = template._render_lang(self.ids)[self.id]
ctx = {
'default_model': 'sale.order',
'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,
'custom_layout': "mail.mail_notification_paynow",
'proforma': self.env.context.get('proforma', False),
'force_email': True,
'model_description': self.with_context(lang=lang).type_name,
'default_attachment_name': [(6, 0, self.designer_attachment_ids.ids)]
}
return {
'type': 'ir.actions.act_window',
'view_mode': 'form',
'res_model': 'mail.compose.message',
'views': [(False, 'form')],
'view_id': False,
'target': 'new',
'context': ctx,
}

Regards

Avatar
Discard
Related Posts Replies Views Activity
0
Aug 22
4577
2
Jun 24
7592
0
Apr 20
1140
2
Oct 17
3125
8
Jul 24
20274