[IMP] sale, account, portal_sale: factor the paypal_url in the templates into function fields
bzr revid: rco@openerp.com-20121214113132-skqi1tddmkjybwpn
This commit is contained in:
parent
95a3a0677b
commit
01bffef548
|
@ -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'
|
||||
|
|
|
@ -50,23 +50,10 @@
|
|||
% endif
|
||||
</p>
|
||||
|
||||
% 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:
|
||||
<br/>
|
||||
<p>It is also possible to directly pay with Paypal:</p>
|
||||
<a style="margin-left: 120px;" href="${paypal_url}">
|
||||
<a style="margin-left: 120px;" href="${object.paypal_url}">
|
||||
<img class="oe_edi_paypal_button" src="https://www.paypal.com/en_US/i/btn/btn_paynowCC_LG.gif"/>
|
||||
</a>
|
||||
% endif
|
||||
|
|
|
@ -45,23 +45,10 @@
|
|||
href="${signup_url}">View ${object.state in ('draft', 'sent') and 'Quotation' or 'Order'}</a>
|
||||
% 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:
|
||||
<br/>
|
||||
<p>It is also possible to directly pay with Paypal:</p>
|
||||
<a style="margin-left: 120px;" href="${paypal_url}">
|
||||
<a style="margin-left: 120px;" href="${object.paypal_url}">
|
||||
<img class="oe_edi_paypal_button" src="https://www.paypal.com/en_US/i/btn/btn_paynowCC_LG.gif"/>
|
||||
</a>
|
||||
% endif
|
||||
|
@ -144,23 +131,10 @@
|
|||
href="${signup_url}">View Invoice</a>
|
||||
% 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:
|
||||
<br/>
|
||||
<p>It is also possible to directly pay with Paypal:</p>
|
||||
<a style="margin-left: 120px;" href="${paypal_url}">
|
||||
<a style="margin-left: 120px;" href="${object.paypal_url}">
|
||||
<img class="oe_edi_paypal_button" src="https://www.paypal.com/en_US/i/btn/btn_paynowCC_LG.gif"/>
|
||||
</a>
|
||||
% endif
|
||||
|
|
|
@ -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'
|
||||
|
||||
|
|
|
@ -52,23 +52,10 @@
|
|||
% endif
|
||||
</p>
|
||||
|
||||
% 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:
|
||||
<br/>
|
||||
<p>It is also possible to directly pay with Paypal:</p>
|
||||
<a style="margin-left: 120px;" href="${paypal_url}">
|
||||
<a style="margin-left: 120px;" href="${object.paypal_url}">
|
||||
<img class="oe_edi_paypal_button" src="https://www.paypal.com/en_US/i/btn/btn_paynowCC_LG.gif"/>
|
||||
</a>
|
||||
% endif
|
||||
|
|
Loading…
Reference in New Issue