[IMP] website_portal_sale: payment from portal
- replace the portal_sale blue ribbon by a website_portal_sale link from the portal home - remove all fields and methods related to banner in portal_sale - remove "validation" field in payment_acquirer since it was only used here
This commit is contained in:
@@ -87,10 +87,6 @@ class PaymentAcquirer(osv.Model):
|
||||
'pre_msg': fields.html('Help Message', translate=True,
|
||||
help='Message displayed to explain and help the payment process.'),
|
||||
'post_msg': fields.html('Thanks Message', help='Message displayed after having done the payment process.'),
|
||||
'validation': fields.selection(
|
||||
[('manual', 'Manual'), ('automatic', 'Automatic')],
|
||||
string='Process Method',
|
||||
help='Static payments are payments like transfer, that require manual steps.'),
|
||||
'view_template_id': fields.many2one('ir.ui.view', 'Form Button Template', required=True),
|
||||
'registration_view_template_id': fields.many2one('ir.ui.view', 'S2S Form Template',
|
||||
domain=[('type', '=', 'qweb')],
|
||||
@@ -338,39 +334,6 @@ class PaymentAcquirer(osv.Model):
|
||||
return method(cr, uid, id, data, context=context)
|
||||
return True
|
||||
|
||||
def _wrap_payment_block(self, cr, uid, html_block, amount, currency_id, context=None):
|
||||
payment_header = _('Pay safely online')
|
||||
currency = self.pool['res.currency'].browse(cr, uid, currency_id, context=context)
|
||||
amount_str = float_repr(amount, currency.decimal_places)
|
||||
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 = u"""<div class="payment_acquirers">
|
||||
<div class="payment_header">
|
||||
<div class="payment_amount">%s</div>
|
||||
%s
|
||||
</div>
|
||||
%%s
|
||||
</div>""" % (amount, payment_header)
|
||||
return result % html_block.decode("utf-8")
|
||||
|
||||
def render_payment_block(self, cr, uid, reference, amount, currency_id, tx_id=None, partner_id=False, partner_values=None, tx_values=None, company_id=None, context=None):
|
||||
html_forms = []
|
||||
domain = [('validation', '=', 'automatic')]
|
||||
if company_id:
|
||||
domain.append(('company_id', '=', company_id))
|
||||
acquirer_ids = self.search(cr, uid, domain, context=context)
|
||||
for acquirer_id in acquirer_ids:
|
||||
button = self.render(
|
||||
cr, uid, acquirer_id,
|
||||
reference, amount, currency_id,
|
||||
tx_id, partner_id, partner_values, tx_values,
|
||||
context)
|
||||
html_forms.append(button)
|
||||
if not html_forms:
|
||||
return ''
|
||||
html_block = '\n'.join(filter(None, html_forms))
|
||||
return self._wrap_payment_block(cr, uid, html_block, amount, currency_id, context=context)
|
||||
|
||||
|
||||
class PaymentTransaction(osv.Model):
|
||||
""" Transaction Model. Each specific acquirer can extend the model by adding
|
||||
|
||||
@@ -43,7 +43,6 @@
|
||||
</div>
|
||||
<group name="acquirer_base" col="2">
|
||||
<group name="acquirer_left">
|
||||
<field name="name"/>
|
||||
<field name="environment" groups="base.group_no_one"/>
|
||||
<field name="company_id" groups="base.group_multi_company" options='{"no_open":True}'/>
|
||||
</group>
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
<field name="provider">transfer</field>
|
||||
<field name="company_id" ref="base.main_company"/>
|
||||
<field name="view_template_id" ref="transfer_acquirer_button"/>
|
||||
<field name="validation">manual</field>
|
||||
<field name="auto_confirm">none</field>
|
||||
<field name="environment">test</field>
|
||||
<field name="website_published" eval="True"/>
|
||||
|
||||
@@ -26,7 +26,6 @@ very handy when used in combination with the module 'share'.
|
||||
'portal_view.xml',
|
||||
'wizard/portal_wizard_view.xml',
|
||||
'security/ir.model.access.csv',
|
||||
'views/portal.xml',
|
||||
],
|
||||
'demo': ['portal_demo.xml'],
|
||||
'auto_install': True,
|
||||
|
||||
@@ -1,87 +0,0 @@
|
||||
|
||||
.openerp .oe_application .oe_form_sheetbg {
|
||||
/* Establish a stacking context on top of which the
|
||||
payment_acquirers::before element can be positioned */
|
||||
position: relative;
|
||||
z-index: 0;
|
||||
}
|
||||
|
||||
|
||||
.openerp .oe_form .oe_form_embedded_html.view_portal_payment_options {
|
||||
overflow: visible;
|
||||
}
|
||||
|
||||
.openerp .payment_acquirers {
|
||||
position: relative;
|
||||
padding: 10px 15px;
|
||||
right: -125px; /* improved margin according bootstrap3 */
|
||||
width: 650px;
|
||||
margin-left: 80px;
|
||||
|
||||
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: 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);
|
||||
}
|
||||
|
||||
.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;
|
||||
width: 10px;
|
||||
height: 20px;
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
right: 1px;
|
||||
|
||||
margin-bottom: -6px;
|
||||
background: #043574;
|
||||
|
||||
-webkit-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;
|
||||
|
||||
/* push it under all its siblings, just on top of its root
|
||||
in the z-index stack: div.oe_form_sheetbg */
|
||||
z-index: -1;
|
||||
}
|
||||
|
||||
.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;
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
<template id="assets_backend" name="portal assets" inherit_id="web.assets_backend">
|
||||
<xpath expr="." position="inside">
|
||||
<link rel="stylesheet" href="/portal/static/src/css/portal.css"/>
|
||||
</xpath>
|
||||
</template>
|
||||
</data>
|
||||
</openerp>
|
||||
@@ -9,23 +9,6 @@ from openerp import SUPERUSER_ID
|
||||
class sale_order(osv.Model):
|
||||
_inherit = 'sale.order'
|
||||
|
||||
# make the real method inheritable
|
||||
_payment_block_proxy = lambda self, *a, **kw: self._portal_payment_block(*a, **kw)
|
||||
|
||||
_columns = {
|
||||
'portal_payment_options': fields.function(_payment_block_proxy, type="html", string="Portal Payment Options"),
|
||||
}
|
||||
|
||||
def _portal_payment_block(self, cr, uid, ids, fieldname, arg, context=None):
|
||||
result = dict.fromkeys(ids, False)
|
||||
payment_acquirer = self.pool['payment.acquirer']
|
||||
for this in self.browse(cr, SUPERUSER_ID, ids, context=context):
|
||||
if this.state not in ('draft', 'cancel', 'done'):
|
||||
result[this.id] = payment_acquirer.render_payment_block(
|
||||
cr, uid, this.name, this.amount_total, this.pricelist_id.currency_id.id,
|
||||
partner_id=this.partner_id.id, company_id=this.company_id.id, context=context)
|
||||
return result
|
||||
|
||||
def action_quotation_send(self, cr, uid, ids, context=None):
|
||||
''' Override to use a modified template that includes a portal signup link '''
|
||||
action_dict = super(sale_order, self).action_quotation_send(cr, uid, ids, context=context)
|
||||
@@ -69,23 +52,6 @@ class sale_order(osv.Model):
|
||||
class account_invoice(osv.Model):
|
||||
_inherit = 'account.invoice'
|
||||
|
||||
# make the real method inheritable
|
||||
_payment_block_proxy = lambda self, *a, **kw: self._portal_payment_block(*a, **kw)
|
||||
|
||||
_columns = {
|
||||
'portal_payment_options': fields.function(_payment_block_proxy, type="html", string="Portal Payment Options"),
|
||||
}
|
||||
|
||||
def _portal_payment_block(self, cr, uid, ids, fieldname, arg, context=None):
|
||||
result = dict.fromkeys(ids, False)
|
||||
payment_acquirer = self.pool.get('payment.acquirer')
|
||||
for this in self.browse(cr, uid, ids, context=context):
|
||||
if this.type == 'out_invoice' and this.state not in ('draft', 'done') and not this.reconciled:
|
||||
result[this.id] = payment_acquirer.render_payment_block(
|
||||
cr, uid, this.number, this.residual, this.currency_id.id,
|
||||
partner_id=this.partner_id.id, company_id=this.company_id.id, context=context)
|
||||
return result
|
||||
|
||||
def action_invoice_sent(self, cr, uid, ids, context=None):
|
||||
''' Override to use a modified template that includes a portal signup link '''
|
||||
action_dict = super(account_invoice, self).action_invoice_sent(cr, uid, ids, context=context)
|
||||
|
||||
@@ -1,28 +1,6 @@
|
||||
<?xml version="1.0"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<!-- Add payment options to sale.order and invoice forms -->
|
||||
<record model="ir.ui.view" id="sale_order_form_payment">
|
||||
<field name="name">sale.order.form.payment</field>
|
||||
<field name="model">sale.order</field>
|
||||
<field name="inherit_id" ref="sale.view_order_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<notebook position="before">
|
||||
<field name="portal_payment_options" groups="portal_sale.group_payment_options" class="view_portal_payment_options"/>
|
||||
</notebook>
|
||||
</field>
|
||||
</record>
|
||||
<record model="ir.ui.view" id="invoice_form_payment">
|
||||
<field name="name">account.invoice.form.payment</field>
|
||||
<field name="model">account.invoice</field>
|
||||
<field name="inherit_id" ref="account.invoice_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<notebook position="before">
|
||||
<field name="portal_payment_options" groups="portal_sale.group_payment_options" class="view_portal_payment_options"/>
|
||||
</notebook>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="view_account_invoice_filter_share" model="ir.ui.view">
|
||||
<field name="name">account.invoice.select.share</field>
|
||||
|
||||
@@ -10,6 +10,7 @@ Add your sales document in the frontend portal. Your customers will be able to c
|
||||
'depends': [
|
||||
'sale',
|
||||
'website_portal',
|
||||
'website_payment',
|
||||
],
|
||||
'data': [
|
||||
'views/templates.xml',
|
||||
|
||||
@@ -109,6 +109,7 @@
|
||||
<th>Invoice Date</th>
|
||||
<th>Due Date</th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
<th>Total</th>
|
||||
</tr>
|
||||
</thead>
|
||||
@@ -130,6 +131,9 @@
|
||||
<span class="label label-default"><i class="fa fa-fw fa-remove"/> Cancelled</span>
|
||||
</t>
|
||||
</td>
|
||||
<td>
|
||||
<a t-if="invoice.state == 'open'" t-attf-href="/website_payment/pay?reference=#{invoice.number}&amount=#{invoice.amount_total}&currency_id=#{invoice.currency_id.id}&partner_id=#{invoice.partner_id.id}&country_id=#{invoice.partner_id.country_id.id}" alt="Pay Now" class="btn btn-xs btn-primary"><i class="fa fa-arrow-circle-right"/> Pay Now</a>
|
||||
</td>
|
||||
<td><span t-esc="invoice.amount_total" t-esc-options='{"widget": "monetary", "display_currency": "invoice.currency_id"}'/></td>
|
||||
</tr>
|
||||
</t>
|
||||
|
||||
@@ -829,11 +829,11 @@ class website_sale(http.Controller):
|
||||
else:
|
||||
tx = request.registry['payment.transaction'].browse(cr, SUPERUSER_ID, tx_ids[0], context=context)
|
||||
state = tx.state
|
||||
flag = True if state == 'pending' and tx.acquirer_id.validation == 'automatic' else False
|
||||
flag = state == 'pending'
|
||||
values.update({
|
||||
'tx_ids': True,
|
||||
'state': state,
|
||||
'validation' : tx.acquirer_id.validation,
|
||||
'validation': tx.acquirer_id.auto_confirm == 'none',
|
||||
'tx_post_msg': tx.acquirer_id.post_msg or None
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user