Odoo Help

Welcome!

This community 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.

0

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

By
Nico Sap
on 8/25/14, 2:52 PM 5,158 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
1

Pascal Tremblay

--Pascal Tremblay--
1312
| 5 2 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')
        try:
            template_id = irmodeldataaa.get_object_reference(cr, uid, 'sale', 'email_template_edi_sale')[1]
        except ValueError:
            template_id = False
        try:
            compose_form_id = irmodeldataaa.get_object_reference(cr, uid, 'mail', 'email_compose_message_wizard_form')[1]
        except ValueError:
            compose_form_id = False        ctx = dict()

        ctx.update({
            '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

Raffaele
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
0
PY
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.

Raffaele
on 10/28/15, 8:20 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

3 follower(s)

Stats

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