[IMP] portal,portal_sale: fine-tuning of payment block appearance, added amount, converted paypal example to <form>
bzr revid: odo@openerp.com-20121025113502-fye11iuur4x0ewm2
This commit is contained in:
parent
21e48c3b96
commit
9cfe9b6112
|
@ -25,6 +25,7 @@ from urllib import quote as quote
|
|||
from openerp.osv import osv, fields
|
||||
from openerp.tools import ustr
|
||||
from openerp.tools.translate import _
|
||||
from openerp.tools import float_repr
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
try:
|
||||
|
@ -74,12 +75,18 @@ class acquirer(osv.Model):
|
|||
_logger.exception("failed to render mako template value for payment.acquirer %s: %r", this.name, template)
|
||||
return
|
||||
|
||||
def _wrap_payment_block(self, cr, uid, html_block, context=None):
|
||||
payment_header = _('Pay safely online:')
|
||||
def _wrap_payment_block(self, cr, uid, html_block, amount, currency, context=None):
|
||||
payment_header = _('Pay safely online')
|
||||
amount_str = float_repr(amount, self.pool.get('decimal.precision').precision_get(cr, uid, 'Account'))
|
||||
currency_str = currency.symbol or currency.name
|
||||
amount = u"%s %s" % ((currency_str, amount_str) if currency.position == 'before' else (amount_str, currency_str))
|
||||
result = """<div class="payment_acquirers">
|
||||
<span class="payment_header">%s</span>
|
||||
<div class="payment_header">
|
||||
<div class="payment_amount">%s</div>
|
||||
%s
|
||||
</div>
|
||||
%%s
|
||||
</div>""" % payment_header
|
||||
</div>""" % (amount, payment_header)
|
||||
return result % html_block
|
||||
|
||||
def render_payment_block(self, cr, uid, object, reference, currency, amount, context=None, **kwargs):
|
||||
|
@ -92,5 +99,5 @@ class acquirer(osv.Model):
|
|||
html_forms = []
|
||||
for this in self.browse(cr, uid, acquirer_ids):
|
||||
html_forms.append(this.render(object, reference, currency, amount, context=context, **kwargs))
|
||||
html_block = '\n'.join(html_forms)
|
||||
return self._wrap_payment_block(cr, uid, html_block, context=context)
|
||||
html_block = '\n'.join(filter(None,html_forms))
|
||||
return self._wrap_payment_block(cr, uid, html_block, amount, currency, context=context)
|
||||
|
|
|
@ -33,21 +33,14 @@
|
|||
<field name="name">Paypal</field>
|
||||
<field name="form_template"><![CDATA[
|
||||
% if object.company_id.paypal_account:
|
||||
<%
|
||||
kind = quote(kind.title())
|
||||
comp_name = quote(object.company_id.name)
|
||||
ref = quote(reference)
|
||||
paypal_account = quote(object.company_id.paypal_account)
|
||||
amount = quote(str(object.amount_total))
|
||||
cur_code = quote(currency.name)
|
||||
paypal_url = "https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=%s&item_name=%s%%20%s%%20%s" \
|
||||
"&invoice=%s&amount=%s&currency_code=%s&button_subtype=services&no_note=1" \
|
||||
"&bn=OpenERP_Portal_PayNow_%s" % \
|
||||
(paypal_account,comp_name,kind,ref,ref,amount,cur_code,cur_code)
|
||||
%>
|
||||
<a style="margin-left: 120px;" href="${paypal_url}">
|
||||
<img class="oe_edi_paypal_button" src="https://www.paypal.com/en_US/i/btn/btn_paynowCC_LG.gif"/>
|
||||
</a>
|
||||
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_blank">
|
||||
<input type="hidden" name="cmd" value="_xclick"/>
|
||||
<input type="hidden" name="business" value="${object.company_id.paypal_account}"/>
|
||||
<input type="hidden" name="item_name" value="${object.company_id.name} ${kind.title()} ${reference}"/>
|
||||
<input type="hidden" name="amount" value="${amount}"/>
|
||||
<input type="hidden" name="currency_code" value="${currency.name}"/>
|
||||
<input type="image" name="submit" src="https://www.paypal.com/en_US/i/btn/btn_paynowCC_LG.gif"/>
|
||||
</form>
|
||||
% endif
|
||||
]]></field>
|
||||
</record>
|
||||
|
|
|
@ -25,6 +25,22 @@
|
|||
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.45);
|
||||
}
|
||||
|
||||
.openerp .payment_acquirers form {
|
||||
display: inline-block;
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
.openerp .payment_acquirers form input,
|
||||
.openerp .payment_acquirers form textarea,
|
||||
.openerp .payment_acquirers form select
|
||||
{
|
||||
-webkit-box-shadow: none;
|
||||
box-shadow: none;
|
||||
background: transparent;
|
||||
border: none;
|
||||
padding: none;
|
||||
}
|
||||
|
||||
.openerp .payment_acquirers::after {
|
||||
content: " ";
|
||||
display: block;
|
||||
|
@ -52,9 +68,14 @@
|
|||
}
|
||||
|
||||
.openerp .payment_acquirers .payment_header {
|
||||
display: inline-block;
|
||||
font-weight: bold;
|
||||
font-size: 110%;
|
||||
padding-right: 15px;
|
||||
color: white;
|
||||
text-shadow: 0 1px 1px #729FCF, 0 -1px 1px #3465A4;
|
||||
}
|
||||
.openerp .payment_acquirers .payment_header .payment_amount {
|
||||
font-size: 130%;
|
||||
padding: 6px 0px;
|
||||
}
|
|
@ -34,7 +34,7 @@ class sale_order(osv.Model):
|
|||
result = dict.fromkeys(ids, False)
|
||||
payment_acquirer = self.pool.get('portal.payment.acquirer')
|
||||
for this in self.browse(cr, uid, ids, context=context):
|
||||
if this.state != 'draft':
|
||||
if this.state != 'draft' and not this.invoiced:
|
||||
result[this.id] = payment_acquirer.render_payment_block(cr, uid, this, this.name,
|
||||
this.pricelist_id.currency_id, this.amount_total, context=context)
|
||||
return result
|
Loading…
Reference in New Issue