diff --git a/addons/account/edi/invoice.py b/addons/account/edi/invoice.py index 3e27bc5ea99..ca25d4e6e90 100644 --- a/addons/account/edi/invoice.py +++ b/addons/account/edi/invoice.py @@ -19,7 +19,9 @@ # ############################################################################## -from openerp.osv import osv +from urllib import urlencode + +from openerp.osv import osv, fields from edi import EDIMixin INVOICE_LINE_EDI_STRUCT = { @@ -258,6 +260,28 @@ class account_invoice(osv.osv, EDIMixin): pass return action + def _edi_paypal_url(self, cr, uid, ids, field, arg, context=None): + res = dict.fromkeys(ids, False) + for inv in self.browse(cr, uid, ids, context=context): + if inv.type == 'out_invoice' and inv.company_id.paypal_account: + params = { + "cmd": "_xclick", + "business": inv.company_id.paypal_account, + "item_name": inv.company_id.name + " Invoice " + inv.number, + "invoice": inv.number, + "amount": inv.residual, + "currency_code": inv.currency_id.name, + "button_subtype": "services", + "no_note": "1", + "bn": "OpenERP_Invoice_PayNow_" + inv.currency_id.name, + } + res[inv.id] = "https://www.paypal.com/cgi-bin/webscr?" + urlencode(params) + return res + + _columns = { + 'paypal_url': fields.function(_edi_paypal_url, type='char', string='Paypal Url'), + } + class account_invoice_line(osv.osv, EDIMixin): _inherit='account.invoice.line' diff --git a/addons/account/edi/invoice_action_data.xml b/addons/account/edi/invoice_action_data.xml index 93c32b1cdc5..18ac71f55ce 100644 --- a/addons/account/edi/invoice_action_data.xml +++ b/addons/account/edi/invoice_action_data.xml @@ -50,23 +50,10 @@ % endif
- % if object.company_id.paypal_account and object.type in ('out_invoice'): - <% set paypal_url = "https://www.paypal.com/cgi-bin/webscr?" + - urlencode({ - "cmd": "_xclick", - "business": object.company_id.paypal_account, - "item_name": object.company_id.name + " Invoice " + object.number, - "invoice": object.number, - "amount": object.residual, - "currency_code": object.currency_id.name, - "button_subtype": "services", - "no_note": "1", - "bn": "OpenERP_Invoice_PayNow_" + object.currency_id.name, - }) - %> + % if object.paypal_url:It is also possible to directly pay with Paypal:
- +
% endif
diff --git a/addons/portal_sale/portal_sale_data.xml b/addons/portal_sale/portal_sale_data.xml
index 761733ee31e..0ef9b1ec5cc 100644
--- a/addons/portal_sale/portal_sale_data.xml
+++ b/addons/portal_sale/portal_sale_data.xml
@@ -45,23 +45,10 @@
href="${signup_url}">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':
- <% set paypal_url = "https://www.paypal.com/cgi-bin/webscr?" +
- urlencode({
- "cmd": "_xclick",
- "business": object.company_id.paypal_account,
- "item_name": object.company_id.name + " Order " + object.name,
- "invoice": object.name,
- "amount": object.amount_total,
- "currency_code": object.pricelist_id.currency_id.name,
- "button_subtype": "services",
- "no_note": "1",
- "bn": "OpenERP_Order_PayNow_" + object.pricelist_id.currency_id.name,
- })
- %>
+ % if object.paypal_url:
It is also possible to directly pay with Paypal:
- +
% endif
@@ -144,23 +131,10 @@
href="${signup_url}">View Invoice
% endif
- % if object.company_id.paypal_account and object.type in ('out_invoice'):
- <% set paypal_url = "https://www.paypal.com/cgi-bin/webscr?" +
- urlencode({
- "cmd": "_xclick",
- "business": object.company_id.paypal_account,
- "item_name": object.company_id.name + " Invoice " + object.number,
- "invoice": object.number,
- "amount": object.residual,
- "currency_code": object.currency_id.name,
- "button_subtype": "services",
- "no_note": "1",
- "bn": "OpenERP_Invoice_PayNow_" + object.currency_id.name,
- })
- %>
+ % if object.paypal_url:
It is also possible to directly pay with Paypal:
- +
% endif
diff --git a/addons/sale/edi/sale_order.py b/addons/sale/edi/sale_order.py
index 15389f1481c..b906f9a6926 100644
--- a/addons/sale/edi/sale_order.py
+++ b/addons/sale/edi/sale_order.py
@@ -19,7 +19,10 @@
#
##############################################################################
-from openerp.osv import osv
+from urllib import urlencode
+
+from openerp.osv import osv, fields
+from openerp.tools.translate import _
from edi import EDIMixin
SALE_ORDER_LINE_EDI_STRUCT = {
@@ -118,7 +121,6 @@ class sale_order(osv.osv, EDIMixin):
edi_document.pop('partner_address', None) # ignored, that's supposed to be our own address!
return partner_id
-
def _edi_get_pricelist(self, cr, uid, partner_id, currency, context=None):
# TODO: refactor into common place for purchase/sale, e.g. into product module
partner_model = self.pool.get('res.partner')
@@ -180,6 +182,30 @@ class sale_order(osv.osv, EDIMixin):
order_line.pop('price_subtotal', None)
return super(sale_order,self).edi_import(cr, uid, edi_document, context=context)
+ def _edi_paypal_url(self, cr, uid, ids, field, arg, context=None):
+ res = dict.fromkeys(ids, False)
+ for order in self.browse(cr, uid, ids, context=context):
+ if order.order_policy in ('prepaid', 'manual') and \
+ order.company_id.paypal_account and order.state != 'draft':
+ params = {
+ "cmd": "_xclick",
+ "business": order.company_id.paypal_account,
+ "item_name": order.company_id.name + " Order " + order.name,
+ "invoice": order.name,
+ "amount": order.amount_total,
+ "currency_code": order.pricelist_id.currency_id.name,
+ "button_subtype": "services",
+ "no_note": "1",
+ "bn": "OpenERP_Order_PayNow_" + order.pricelist_id.currency_id.name,
+ }
+ res[order.id] = "https://www.paypal.com/cgi-bin/webscr?" + urlencode(params)
+ return res
+
+ _columns = {
+ 'paypal_url': fields.function(_edi_paypal_url, type='char', string='Paypal Url'),
+ }
+
+
class sale_order_line(osv.osv, EDIMixin):
_inherit='sale.order.line'
diff --git a/addons/sale/edi/sale_order_action_data.xml b/addons/sale/edi/sale_order_action_data.xml
index 371233b96c7..f031daf8656 100644
--- a/addons/sale/edi/sale_order_action_data.xml
+++ b/addons/sale/edi/sale_order_action_data.xml
@@ -52,23 +52,10 @@
% endif
- % if object.order_policy in ('prepaid','manual') and object.company_id.paypal_account and object.state != 'draft':
- <% set paypal_url = "https://www.paypal.com/cgi-bin/webscr?" +
- urlencode({
- "cmd": "_xclick",
- "business": object.company_id.paypal_account,
- "item_name": object.company_id.name + " Order " + object.name,
- "invoice": object.name,
- "amount": object.amount_total,
- "currency_code": object.pricelist_id.currency_id.name,
- "button_subtype": "services",
- "no_note": "1",
- "bn": "OpenERP_Order_PayNow_" + object.pricelist_id.currency_id.name,
- })
- %>
+ % if object.paypal_url:
It is also possible to directly pay with Paypal:
- +
% endif