[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:
Olivier Dony 2012-10-25 13:35:02 +02:00
parent 21e48c3b96
commit 9cfe9b6112
4 changed files with 52 additions and 31 deletions

View File

@ -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)

View File

@ -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&amp;business=%s&amp;item_name=%s%%20%s%%20%s" \
"&amp;invoice=%s&amp;amount=%s&amp;currency_code=%s&amp;button_subtype=services&amp;no_note=1" \
"&amp;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>

View File

@ -15,14 +15,30 @@
background: #729FCF;
background-image: -webkit-gradient(linear, left top, left bottom, from(#729FCF), to(#3465A4));
background-image: -webkit-linear-gradient(top, #729FCF, #3465A4);
background-image: -moz-linear-gradient(top, #729FCF, #3465A4);
background-image: -ms-linear-gradient(top, #729FCF, #3465A4);
background-image: -o-linear-gradient(top, #729FCF, #3465A4);
background-image: -moz-linear-gradient(top, #729FCF, #3465A4);
background-image: -ms-linear-gradient(top, #729FCF, #3465A4);
background-image: -o-linear-gradient(top, #729FCF, #3465A4);
background-image: linear-gradient(to bottom, #729FCF, #3465A4);
border-bottom: 1px solid #043574;
-webkit-box-shadow: 0 4px 20px rgba(0, 0, 0, 0.45);
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.45);
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 {
@ -38,13 +54,13 @@
background: #043574;
-webkit-transform: skewY(-45deg);
-moz-transform: skewY(-45deg);
-ms-transform: skewY(-45deg);
-o-transform: skewY(-45deg);
transform: skewY(-45deg);
-moz-transform: skewY(-45deg);
-ms-transform: skewY(-45deg);
-o-transform: skewY(-45deg);
transform: skewY(-45deg);
-webkit-box-shadow: inset 1px -1px 2px black, -1px 1px 3px black;
box-shadow: inset 1px -1px 2px black, -1px 1px 3px black;
box-shadow: inset 1px -1px 2px black, -1px 1px 3px black;
/* push it under all its siblings, just on top of its root
in the z-index stack: div.oe_form_sheetbg */
@ -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;
}

View File

@ -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