From e07f8a7519330aa7ac1b1ba66293aa71d96cca62 Mon Sep 17 00:00:00 2001 From: Raphael Collet Date: Thu, 13 Dec 2012 16:37:28 +0100 Subject: [PATCH] [IMP] portal_sale: adapt edi email templates bzr revid: rco@openerp.com-20121213153728-v7yv82x09qtletix --- addons/portal_sale/portal_sale.py | 16 +++++ addons/portal_sale/portal_sale_data.xml | 89 +++++++++++++------------ 2 files changed, 63 insertions(+), 42 deletions(-) diff --git a/addons/portal_sale/portal_sale.py b/addons/portal_sale/portal_sale.py index 62f3f1ff9cc..3556fd5ca0e 100644 --- a/addons/portal_sale/portal_sale.py +++ b/addons/portal_sale/portal_sale.py @@ -74,6 +74,14 @@ class sale_order(osv.Model): mail_obj.send(cr, uid, [mail_id], recipient_ids=[partner.id], context=context) return super(sale_order, self).action_button_confirm(cr, uid, ids, context=context) + def get_signup_url(self, cr, uid, ids, context=None): + assert len(ids) == 1 + document = self.browse(cr, uid, ids[0], context=context) + partner = document.partner_id + action = 'portal_sale.action_quotations_portal' if document.state in ('draft', 'sent') else 'portal_sale.action_orders_portal' + partner.signup_prepare() + return partner._get_signup_url_for_action(action=action, view_type='form', res_id=document.id)[partner.id] + class account_invoice(osv.Model): _inherit = 'account.invoice' @@ -126,6 +134,14 @@ class account_invoice(osv.Model): mail_obj.send(cr, uid, [mail_id], recipient_ids=[partner.id], context=context) return super(account_invoice, self).invoice_validate(cr, uid, ids, context=context) + def get_signup_url(self, cr, uid, ids, context=None): + assert len(ids) == 1 + document = self.browse(cr, uid, ids[0], context=context) + partner = document.partner_id + action = 'portal_sale.portal_action_invoices' + partner.signup_prepare() + return partner._get_signup_url_for_action(action=action, view_type='form', res_id=document.id)[partner.id] + class mail_mail(osv.osv): _inherit = 'mail.mail' diff --git a/addons/portal_sale/portal_sale_data.xml b/addons/portal_sale/portal_sale_data.xml index f40897f6998..bdf51fd2fe7 100644 --- a/addons/portal_sale/portal_sale_data.xml +++ b/addons/portal_sale/portal_sale_data.xml @@ -6,7 +6,7 @@ Sale Order - Send by Email (Portal) - ${object.user_id.email or ''} + ${object.user_id.email or ''|safe} ${object.company_id.name} ${object.state in ('draft', 'sent') and 'Quotation' or 'Order'} (Ref ${object.name or 'n/a' }) ${object.partner_invoice_id.id} @@ -16,7 +16,7 @@ -

Hello${object.partner_id.name and ' ' or ''}${object.partner_id.name or ''},

+

Hello ${object.partner_id.name or ''},

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

@@ -32,38 +32,40 @@   Your reference: ${object.client_order_ref}
% endif % if object.user_id: -   Your contact: ${object.user_id.name} +   Your contact: ${object.user_id.name} % endif

- <% - action = 'portal_sale.action_quotations_portal' if object.state in ('draft', 'sent') else 'portal_sale.action_orders_portal' - object.partner_id.signup_prepare() - signup_url = object.partner_id._get_signup_url_for_action(action=action,view_type='form',res_id=object.id)[object.partner_id.id] - %> + <% 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'} + href="${signup_url|safe}">View ${object.state in ('draft', 'sent') and 'Quotation' or 'Order'} % endif % if object.order_policy in ('prepaid','manual') and object.company_id.paypal_account and object.state != 'draft': - <% - comp_name = quote(object.company_id.name) - order_name = quote(object.name) - paypal_account = quote(object.company_id.paypal_account) - order_amount = quote(str(object.residual)) - cur_name = quote(object.pricelist_id.currency_id.name) - paypal_url = "https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=%s&item_name=%s%%20Order%%20%s" \ - "&invoice=%s&amount=%s&currency_code=%s&button_subtype=services&no_note=1" \ - "&bn=OpenERP_Order_PayNow_%s" % \ - (paypal_account,comp_name,order_name,order_name,order_amount,cur_name,cur_name) + <% set paypal_url = ("https://www.paypal.com/cgi-bin/webscr?cmd=_xclick" + "&business=%(paypal_account)s" + "&item_name=%(company_name)s%%20Order%%20%(order_name)s" + "&invoice=%(order_name)s" + "&amount=%(order_amount)s" + "&currency_code=%(currency)s" + "&button_subtype=services" + "&no_note=1" + "&bn=OpenERP_Order_PayNow_%(currency)s" + % { + 'paypal_account': quote(object.company_id.paypal_account), + 'company_name': quote(object.company_id.name), + 'order_name': quote(object.name), + 'order_amount': quote(str(object.residual)), + 'currency': quote(object.pricelist_id.currency_id.name), + }) %>

It is also possible to directly pay with Paypal:

- + % endif @@ -99,9 +101,9 @@ % endif % if object.company_id.website:
- Web : ${object.company_id.website} + Web : ${object.company_id.website|safe}
- %endif + % endif

@@ -110,7 +112,7 @@ Invoice - Send by Email (Portal) - ${object.user_id.email or object.company_id.email or 'noreply@localhost'} + ${object.user_id.email or object.company_id.email or 'noreply@localhost'|safe} ${object.company_id.name} Invoice (Ref ${object.number or 'n/a' }) ${object.partner_id.id} @@ -120,7 +122,7 @@ -

Hello${object.partner_id.name and ' ' or ''}${object.partner_id.name or ''},

+

Hello ${object.partner_id.name or ''},

A new invoice is available for you:

@@ -133,15 +135,11 @@   Order reference: ${object.origin}
% endif % if object.user_id: -   Your contact: ${object.user_id.name} +   Your contact: ${object.user_id.name} % endif

- <% - action = 'portal_sale.portal_action_invoices' - object.partner_id.signup_prepare() - signup_url = object.partner_id._get_signup_url_for_action(action=action,view_type='form',res_id=object.id)[object.partner_id.id] - %> + <% set signup_url = object.get_signup_url() %> % if signup_url:

You can access the invoice document and pay online via our Customer Portal: @@ -151,19 +149,26 @@ % endif % if object.company_id.paypal_account and object.type in ('out_invoice'): - <% - comp_name = quote(object.company_id.name) - inv_number = quote(object.number) - paypal_account = quote(object.company_id.paypal_account) - inv_amount = quote(str(object.residual)) - cur_name = quote(object.currency_id.name) - paypal_url = "https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=%s&item_name=%s%%20Invoice%%20%s&" \ - "invoice=%s&amount=%s&currency_code=%s&button_subtype=services&no_note=1&bn=OpenERP_Invoice_PayNow_%s" % \ - (paypal_account,comp_name,inv_number,inv_number,inv_amount,cur_name,cur_name) + <% set paypal_url = ("https://www.paypal.com/cgi-bin/webscr?cmd=_xclick" + "&business=%(paypal_account)s" + "&item_name=%(company_name)s%%20Invoice%%20%(inv)s" + "&invoice=%(inv)s" + "&amount=%(amount)s" + "&currency_code=%(currency)s" + "&button_subtype=services" + "&no_note=1" + "&bn=OpenERP_Invoice_PayNow_%(currency)s" + % { + 'paypal_account': quote(object.company_id.paypal_account), + 'company_name': quote(object.company_id.name), + 'inv': quote(object.number), + 'amount': quote(str(object.residual)), + 'currency': quote(object.currency_id.name), + }) %>

It is also possible to directly pay with Paypal:

- + % endif @@ -199,9 +204,9 @@ % endif % if object.company_id.website: - %endif + % endif