Skip to Content
Menu
This question has been flagged
2 Replies
5048 Views

this is code for the button.

class ticket_requisition(models.Model):

_name='ticket.requisition'

_inherit = ['mail.thread', 'mail.activity.mixin', 'portal.mixin']

_order = 'name desc, id desc'

_description = "Requisition"

@api.multi

def action_quotation_send(self):

'''

This function opens a window to compose an email, with the edi sale template message loaded by default

'''

self.ensure_one()

ir_model_data = self.env['ir.model.data']

try:

template_id = ir_model_data.get_object_reference('sevate_added_fields', 'requisition_email_template')[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': 'ticket.requisition',

'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,

'proforma': self.env.context.get('proforma', False),

'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,

}


this is my email template, body is not showing inside my template and showing Failed to render template

<?xml version="1.0" encoding="utf-8"?>

<odoo>

<data>

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

<field name="name">Requisition email template</field>

<field name="model_id" ref="sevate_added_fields.model_ticket_requisition"/>

<field name="email_from"><![CDATA["${object.company_id.name|safe}" <${(object.company_id.email or user.email)|safe}>]]></field>

<field name="email_to">${object.email|safe}</field>

<field name="subject">Requisition template</field>

<field name="body_html"><![CDATA[

<div style="padding:0px;width:600px;margin:auto;background: #FFFFFF repeat top /100%;color:#777777">

<table cellspacing="0" cellpadding="0" style="width:600px;border-collapse:collapse;background:inherit;color:inherit">

<tbody><tr>

<td valign="center" width="200" style="padding:10px 10px 10px 5px;font-size: 12px">

<img src="/logo.png" style="padding: 0px; margin: 0px; height: auto; width: 80px;" alt="${user.company_id.name}">

</td>

</tr></tbody>

</table>

</div>

<div style="padding:0px;width:600px;margin:auto;background: #FFFFFF repeat top /100%;color:#777777">

<p>Dear,</p>

<p>The Requisition name is ${object.name}</p>

<p>The Requisition Due Date is ${object.due_date}</p>

<p>If you do not expect this, you can safely ignore this email.</p>

<p>Best regards,</p>

</div>

<div style="padding:0px;width:600px;margin:auto; margin-top: 10px; background: #fff repeat top /100%;color:#777777">

${user.signature | safe}

<p style="font-size: 11px; margin-top: 10px;">

<strong>Sent by ${user.company_id.name} style="text-decoration:none; color: #875A7B;"></a></strong>

</p>

% if is_online and not ctx.get('proforma'):

<br/><br/>

<center>

<a href="${access_url}" style="background-color: #1abc9c; padding: 20px; text-decoration: none; color: #fff; border-radius: 5px; font-size: 16px;" class="o_default_snippet_text">${access_name}</a>

<br/><br/><br/>

<span style="color:#888888">(or view attached PDF)</span>

</center>

<br/>

% endif

</div>]]></field>

<field name="user_id.signature" eval="False"/>

</record>

</data>

</odoo>



thanks

Avatar
Discard

Can you add the model ticket_requisition along with the question, when pasting the code try to use the code format

Best Answer

Hi,

Check whether all the fields you have used in the template is there in the corresponding model.


Thanks

Avatar
Discard