[IMP] payment: renamed message in pre_msg, msg displayed before

payment. Added post_msg, message displayed after payment.
[IMP] payment_transfer: added a default value (generated at create) for
post_msg, that contains bank accounts details. bank accounts linked to the
current company and used in report footer are shown.
[FIX] payment_*: make the buttons noupdate.
[IMP] payment: portal_published -> website_published + propagation
[IMP] payment: added process selection field that will be used for some
control in the website, telling w hether we want to refresh a payment
validation page or not.

bzr revid: tde@openerp.com-20140124134652-cc0nz08znnlmftw4
This commit is contained in:
Thibault Delavallée 2014-01-24 14:46:52 +01:00
parent a21495916b
commit cc793480fc
11 changed files with 54 additions and 19 deletions

View File

@ -55,13 +55,18 @@ class PaymentAcquirer(osv.Model):
_columns = {
'name': fields.char('Name', required=True),
'company_id': fields.many2one('res.company', 'Company', required=True),
'message': fields.html('Message', help='Message displayed to help payment and validation'),
'pre_msg': fields.html('Message', 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.'),
'process': fields.selection(
[('static', 'Static'), ('dynamic', 'Dynamic')],
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),
'env': fields.selection(
[('test', 'Test'), ('prod', 'Production')],
string='Environment'),
'portal_published': fields.boolean(
'Visible in Portal',
'website_published': fields.boolean(
'Visible in Portal / Website',
help="Make this payment acquirer available (Customer invoices, etc.)"),
# Fees
'fees_active': fields.boolean('Compute fees'),
@ -74,7 +79,8 @@ class PaymentAcquirer(osv.Model):
_defaults = {
'company_id': lambda self, cr, uid, obj, ctx=None: self.pool['res.users'].browse(cr, uid, uid).company_id.id,
'env': 'test',
'portal_published': True,
'process': 'dynamic',
'website_published': True,
}
def _check_required_if_provider(self, cr, uid, ids, context=None):
@ -272,7 +278,7 @@ class PaymentAcquirer(osv.Model):
def render_payment_block(self, cr, uid, reference, amount, currency_id, tx_id=None, partner_id=False, partner_values=None, tx_values=None, context=None):
html_forms = []
# TDE FIXME: change this domain, see with CHM about 'dynamic/static' acquirer
acquirer_ids = self.search(cr, uid, [('portal_published', '=', True), ('name', '!=', 'transfer')], context=context)
acquirer_ids = self.search(cr, uid, [('website_published', '=', True), ('name', '!=', 'transfer')], context=context)
for acquirer_id in acquirer_ids:
button = self.render(
cr, uid, acquirer_id,

View File

@ -17,7 +17,7 @@
<group>
<field name="name"/>
<field name="company_id"/>
<field name="portal_published"/>
<field name="website_published"/>
<field name="env"/>
</group>
<group>
@ -33,7 +33,8 @@
</group>
</group>
<group name="acquirer_display">
<field name="message"/>
<field name="pre_msg"/>
<field name="post_msg"/>
<label for="view_template_id"/>
<div>
<field name="view_template_id" nolabel="1"/>
@ -65,7 +66,7 @@
<field name="arch" type="xml">
<tree string="Payment Acquirers">
<field name="name"/>
<field name="portal_published"/>
<field name="website_published"/>
<field name="env"/>
</tree>
</field>

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data noupdate="0">
<data noupdate="1">
<template id="adyen_acquirer_button">
<form t-if="acquirer.adyen_merchant_account" t-att-action="tx_url" method="post" target="_self">

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data noupdate="0">
<data noupdate="1">
<template id="ogone_acquirer_button">
<form t-if="acquirer" t-att-action="tx_url" method="post" target="_self">

View File

@ -7,7 +7,7 @@
<field name="company_id" ref="base.main_company"/>
<field name="view_template_id" ref="paypal_acquirer_button"/>
<field name="env">test</field>
<field name="message"><![CDATA[
<field name="pre_msg"><![CDATA[
<p>You will be redirected to the Paypal website after cliking on the payment button.</p>]]></field>
<field name="paypal_email_account">dummy</field>
<field name="paypal_seller_account">dummy</field>

View File

@ -10,7 +10,7 @@ class ResCompany(osv.Model):
Acquirer = self.pool['payment.acquirer']
company_id = self.pool['res.users'].browse(cr, uid, uid, context=context).company_id.id
paypal_ids = Acquirer.search(cr, uid, [
('portal_published', '=', True),
('website_published', '=', True),
('name', 'ilike', 'paypal'),
('company_id', '=', company_id),
], limit=1, context=context)
@ -24,7 +24,7 @@ class ResCompany(osv.Model):
company_id = self.pool['res.users'].browse(cr, uid, uid, context=context).company_id.id
paypal_account = self.browse(cr, uid, id, context=context).paypal_account
paypal_ids = Acquirer.search(cr, uid, [
('portal_published', '=', True),
('website_published', '=', True),
('paypal_email_account', '=', paypal_account),
('company_id', '=', company_id),
], context=context)

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data noupdate="0">
<data noupdate="1">
<template id="paypal_acquirer_button">
<form t-if="acquirer.paypal_email_account" t-att-action="tx_url" method="post" target="_self">

View File

@ -6,9 +6,9 @@
<field name="name">transfer</field>
<field name="view_template_id" ref="transfer_acquirer_button"/>
<field name="env">test</field>
<field name="portal_published" eval="True"/>
<field name="message"><![CDATA[
<p>Please use the account 001-002-003 to make the payment.</p>]]>
<field name="website_published" eval="True"/>
<field name="pre_msg"><![CDATA[
<p>Transfer information will be provided after choosing the payment mode.</p>]]>
</field>
</record>

View File

@ -3,6 +3,7 @@
from openerp.addons.payment.models.payment_acquirer import ValidationError
from openerp.osv import osv
from openerp.tools.float_utils import float_compare
from openerp.tools.translate import _
import logging
import pprint
@ -16,6 +17,33 @@ class TransferPaymentAcquirer(osv.Model):
def transfer_get_form_action_url(self, cr, uid, id, context=None):
return '/payment/transfer/feedback'
def _format_transfer_data(self, cr, uid, context=None):
bank_ids = [bank.id for bank in self.pool['res.users'].browse(cr, uid, uid, context=context).company_id.bank_ids]
# filter only bank accounts marked as visible
bank_ids = self.pool['res.partner.bank'].search(cr, uid, [('id', 'in', bank_ids), ('footer', '=', True)], context=context)
accounts = self.pool['res.partner.bank'].name_get(cr, uid, bank_ids, context=context)
bank_title = _('Bank Accounts') if len(accounts) > 1 else _('Bank Account')
bank_accounts = ''.join(['<ul>'] + ['<li>%s</li>' % name for id, name in accounts] + ['</ul>'])
post_msg = '''<div>
<h3>Please use the following transfer details</h3>
<h4>%(bank_title)s</h4>
%(bank_accounts)s
<h4>Communication</h4>
<p>Please use the order name as communication reference.</p>
</div>''' % {
'bank_title': bank_title,
'bank_accounts': bank_accounts,
}
return post_msg
def create(self, cr, uid, values, context=None):
""" Hook in create to create a default post_msg. This is done in create
to have access to the name and other creation values. If no post_msg
or a void post_msg is given at creation, generate a default one. """
if values.get('name') == 'transfer' and not values.get('post_msg'):
values['post_msg'] = self._format_transfer_data(cr, uid, context=context)
return super(TransferPaymentAcquirer, self).create(cr, uid, values, context=context)
class TransferPaymentTransaction(osv.Model):
_inherit = 'payment.transaction'

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data noupdate="0">
<data noupdate="1">
<template id="transfer_acquirer_button">
<form t-if="acquirer" t-att-action="tx_url" method="post" target="_self">

View File

@ -564,7 +564,7 @@ class Ecommerce(http.Controller):
if tx:
acquirer_ids = [tx.acquirer_id.id]
else:
acquirer_ids = payment_obj.search(cr, SUPERUSER_ID, [('portal_published', '=', True)], context=context)
acquirer_ids = payment_obj.search(cr, SUPERUSER_ID, [('website_published', '=', True)], context=context)
values['acquirers'] = payment_obj.browse(cr, uid, acquirer_ids, context=context)
render_ctx = dict(context, submit_class='btn btn-primary', submit_txt='Pay Now')
for acquirer in values['acquirers']: