Odoo Help


Can't set default email template in sales.order (not even as a default parameter)

Nico Sap
on 8/25/14, 2:52 PM 7,809 views

I set up a default parameter to load, when i email a quotation. I see it added in my users default parameters, but it still picks nr 5 (portal template) as the default, instead of id:=4.

Any idea on how i can solve this?

users default parameters? Where do you find it?

Pascal Tremblay
on 12/24/14, 8:38 PM

ok! I fave found users default parameters in Settings->Actions->User-Defined defaults Thanks

Pascal Tremblay
on 12/25/14, 11:24 AM
On 7/1/15, 4:51 AM

Here is a working and cleaner solution, I think.

Check out addons/portal_sale/portal_sale.py and search the function action_invoice_sent in the account_invoice class.

If the module portal_sale is installed, this function makes sure the portal version of the email.template for invoices is set dy default.

I just copy pasted this function/class in my module and changed the reference call to point towards my own version.

Hope that helps soemone.

this is a more logical solution, but didn't work for me. The invoice template introduced by the portal_sale module remains the default selected. I even specified a "sequence: 90" directive in the manifest, to make sure that my custom module got loaded after the portal_sale, but nothing changed.

on 10/28/15, 8:20 AM

Pascal Tremblay

--Pascal Tremblay--
| 5 3 7
Alma, Canada
--Pascal Tremblay--

Pascal Tremblay
On 12/28/14, 7:45 AM

Here is our solution to change the default mail template when we click on « send by email » in the sale order form.

  • I have changed the view sale.order.form to modify the « send by email » button. I have changed action for action_quotation_send_pt.

  • I had created a new method with a new name action_quotation_send_pt method. This method is still in the class sale_order (we inherit sale_order). This method is almost the same than the original action_quotation_send but we will change it soon.

import pdb
from openerp.osv import osv
import openerp.pooler
class sale_order(osv.osv):
    _inherit = 'sale.order'

    def action_quotation_send_pt(self, cr, uid, ids, context=None):

        assert len(ids) == 1, 'This option should only be used for a single id at a time.'
        irmodeldataaa = self.pool.get('ir.model.data')
            template_id = irmodeldataaa.get_object_reference(cr, uid, 'sale', 'email_template_edi_sale')[1]
        except ValueError:
            template_id = False
            compose_form_id = irmodeldataaa.get_object_reference(cr, uid, 'mail', 'email_compose_message_wizard_form')[1]
        except ValueError:
            compose_form_id = False        ctx = dict()

            'default_model': 'sale.order',
            'default_res_id': ids[0],
            'default_use_template': bool(template_id),
            'default_template_id': template_id,
            'default_composition_mode': 'comment',
            'mark_so_as_sent': 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,

  • We search for the ID of the mail template that we want by default. Here is 24.
  • We have changed external identifier record id in sale.email_template_edi_sale. The new record ID is now 24. The id of our default mail template that we want.


  • Now, you can see the new « Devis - par courriel », by default, in the « use template » field. It is great!

We are happy!


this solved for me

on 10/28/15, 8:17 AM

I didn't have the external identifier. I just created as explained above and it solved my problem

Gets MSS SA, Stephane Oechslin
on 4/16/16, 1:13 AM

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

3 follower(s)


Asked: 8/25/14, 2:52 PM
Seen: 7809 times
Last updated: 4/16/16, 1:13 AM