From 5153b2d281fd1af5529c6347faf3c95da83571b2 Mon Sep 17 00:00:00 2001 From: Julien Legros Date: Fri, 3 Oct 2014 11:26:48 +0200 Subject: [PATCH] [FIX] website_quote: use dedicated email template if a quote template exists --- .../data/website_quotation_data.xml | 96 +++++++++++++++++++ addons/website_quote/models/order.py | 17 ++++ 2 files changed, 113 insertions(+) diff --git a/addons/website_quote/data/website_quotation_data.xml b/addons/website_quote/data/website_quotation_data.xml index d0d07afc4e3..86b831d6449 100644 --- a/addons/website_quote/data/website_quotation_data.xml +++ b/addons/website_quote/data/website_quotation_data.xml @@ -83,4 +83,100 @@ + + + + + + Sales Order - Send by Email (Online Quote) + ${(object.user_id.email or '')|safe} + ${object.company_id.name|safe} ${object.state in ('draft', 'sent') and 'Quotation' or 'Order'} (Ref ${object.name or 'n/a' }) + ${object.partner_invoice_id.id} + + + + ${(object.name or '').replace('/','_')}_${object.state == 'draft' and 'draft' or ''} + ${object.partner_id.lang} + + + +

Hello ${object.partner_id.name},

+ +

Here is your ${object.state in ('draft', 'sent') and 'quotation' or 'order confirmation'} from ${object.company_id.name}:

+ +

+   REFERENCES
+   Order number: ${object.name}
+   Order total: ${object.amount_total} ${object.pricelist_id.currency_id.name}
+   Order date: ${object.date_order}
+ % if object.origin: +   Order reference: ${object.origin}
+ % endif + % if object.client_order_ref: +   Your reference: ${object.client_order_ref}
+ % endif + % if object.user_id: +   Your contact: ${object.user_id.name} + % endif +

+ + <% set signup_url = object.get_signup_url() %> + % if signup_url: +

+ You can access this document and pay online via our Customer Portal: +

+ View ${object.state in ('draft', 'sent') and 'Quotation' or 'Order'} + % endif + + % if object.paypal_url: +
+

It is also possible to directly pay with Paypal:

+ + + + % endif + +
+

If you have any question, do not hesitate to contact us.

+

Thank you for choosing ${object.company_id.name or 'us'}!

+
+
+
+

+ ${object.company_id.name}

+
+
+ + % if object.company_id.street: + ${object.company_id.street}
+ % endif + % if object.company_id.street2: + ${object.company_id.street2}
+ % endif + % if object.company_id.city or object.company_id.zip: + ${object.company_id.zip} ${object.company_id.city}
+ % endif + % if object.company_id.country_id: + ${object.company_id.state_id and ('%s, ' % object.company_id.state_id.name) or ''} ${object.company_id.country_id.name or ''}
+ % endif +
+ % if object.company_id.phone: +
+ Phone:  ${object.company_id.phone} +
+ % endif + % if object.company_id.website: + + % endif +

+
+ + ]]>
+
+
diff --git a/addons/website_quote/models/order.py b/addons/website_quote/models/order.py index 9362476e998..4c5e025139a 100644 --- a/addons/website_quote/models/order.py +++ b/addons/website_quote/models/order.py @@ -223,6 +223,23 @@ class sale_order(osv.osv): 'res_id': id, } + def action_quotation_send(self, cr, uid, ids, context=None): + action = super(sale_order, self).action_quotation_send(cr, uid, ids, context=context) + ir_model_data = self.pool.get('ir.model.data') + quote_template_id = self.read(cr, uid, ids, ['template_id'], context=context)[0]['template_id'] + if quote_template_id: + try: + template_id = ir_model_data.get_object_reference(cr, uid, 'website_quote', 'email_template_edi_sale')[1] + except ValueError: + pass + else: + action['context'].update({ + 'default_template_id': template_id, + 'default_use_template': True + }) + + return action + class sale_quote_option(osv.osv): _name = "sale.quote.option"