diff --git a/addons/crm_partner_assign/res_partner_demo.xml b/addons/crm_partner_assign/res_partner_demo.xml
index 776d7d6834c..a0711657810 100644
--- a/addons/crm_partner_assign/res_partner_demo.xml
+++ b/addons/crm_partner_assign/res_partner_demo.xml
@@ -1,21 +1,21 @@
-
- Bronze
- 1
-
-
- Silver
- 2
+
+ Platinum
+ 4Gold3
-
- Platinum
- 4
+
+ Silver
+ 2
+
+
+ Bronze
+ 1
diff --git a/addons/payment_acquirer/models/payment_acquirer.py b/addons/payment_acquirer/models/payment_acquirer.py
index 101510501db..b88601e88f5 100644
--- a/addons/payment_acquirer/models/payment_acquirer.py
+++ b/addons/payment_acquirer/models/payment_acquirer.py
@@ -1,14 +1,15 @@
# -*- coding: utf-'8' "-*-"
-from openerp.osv import osv, fields
-
import logging
+from openerp.osv import osv, fields
+from openerp.tools import float_round
+
_logger = logging.getLogger(__name__)
def _partner_format_address(address1=False, address2=False):
- return ' '.join((address1 or '', address2 or ''))
+ return ' '.join((address1 or '', address2 or '')).strip()
def _partner_split_name(partner_name):
@@ -22,8 +23,9 @@ class ValidationError(ValueError):
class PaymentAcquirer(osv.Model):
""" Acquirer Model. Each specific acquirer can extend the model by adding
- its own fields. Using the required_if_provider='' attribute on fields
- it is possible to have required fields that depend on a specific acquirer.
+ its own fields, using the acquirer_name as a prefix for the new fields.
+ Using the required_if_provider='' attribute on fields it is possible
+ to have required fields that depend on a specific acquirer.
Each acquirer has a link to an ir.ui.view record that is a template of
a button used to display the payment form. See examples in ``payment_acquirer_ogone``
@@ -36,7 +38,10 @@ class PaymentAcquirer(osv.Model):
method that generates the values used to render the form button template.
- ``_get_form_action_url(self, cr, uid, id, context=None):``: method
that returns the url of the button form. It is used for example in
- ecommerce application, if you want to repost some data to the acquirer.
+ ecommerce application, if you want to post some data to the acquirer.
+ - ``_compute_fees(self, cr, uid, id, amount, currency_id, country_id,
+ context=None)``: computed the fees of the acquirer, using generic fields
+ defined on the acquirer model (see fields definition).
Each acquirer should also define controllers to handle communication between
OpenERP and the acquirer. It generally consists in return urls given to the
@@ -54,8 +59,9 @@ class PaymentAcquirer(osv.Model):
'env': fields.selection(
[('test', 'Test'), ('prod', 'Production')],
string='Environment'),
- 'portal_published': fields.boolean('Visible in Portal',
- help="Make this payment acquirer available (Customer invoices, etc.)"),
+ 'portal_published': fields.boolean(
+ 'Visible in Portal',
+ help="Make this payment acquirer available (Customer invoices, etc.)"),
# Fees
'fees_active': fields.boolean('Compute fees'),
'fees_dom_fixed': fields.float('Fixed domestic fees'),
@@ -89,27 +95,91 @@ class PaymentAcquirer(osv.Model):
return getattr(self, '%s_get_form_action_url' % acquirer.name)(cr, uid, id, context=context)
return False
- def form_preprocess_values(self, cr, uid, id, reference, amount, currency_id, tx_id, partner_id, partner_values, tx_custom_values, context=None):
- acquirer = self.browse(cr, uid, id, context=context)
- tx_values = tx_custom_values
+ def form_preprocess_values(self, cr, uid, id, reference, amount, currency_id, tx_id, partner_id, partner_values, tx_values, context=None):
+ """ Pre process values before giving them to the acquirer-specific render
+ methods. Those methods will receive:
- # compute country
- if partner_id:
- partner = self.pool['res.partner'].browse(cr, uid, partner_id, context=context)
- tx_values['country_id'] = partner.country_id.id
- elif partner_values and partner_values.get('country_name'):
- country_ids = self.pool['res.country'].search(cr, uid, [('name', '=', partner_values.get('country_name'))], context=context)
- tx_values['country_id'] = country_ids and country_ids[0] or None
+ - partner_values: will contain name, lang, email, zip, address, city,
+ country_id (int or False), country (browse or False), phone, reference
+ - tx_values: will contain refernece, amount, currency_id (int or False),
+ currency (browse or False), partner (browse or False)
+ """
+ acquirer = self.browse(cr, uid, id, context=context)
+
+ if tx_id:
+ tx = self.browse(cr, uid, id, context=context)
+ tx_data = {
+ 'reference': tx.reference,
+ 'amount': tx.amount,
+ 'currency_id': tx.currency_id.id,
+ 'currency': tx.currency_id,
+ 'partner': tx.partner_id,
+ }
+ partner_data = {
+ 'name': tx.partner_name,
+ 'lang': tx.partner_lang,
+ 'email': tx.partner_email,
+ 'zip': tx.partner_zip,
+ 'address': tx.partner_address,
+ 'city': tx.partner_city,
+ 'country_id': tx.partner_country_id.id,
+ 'country': tx.partner_country_id,
+ 'phone': tx.partner_phone,
+ 'reference': tx.partner_reference,
+ }
else:
- tx_values['country_id'] = False
+ if partner_id:
+ partner = self.pool['res.partner'].browse(cr, uid, partner_id, context=context)
+ partner_data = {
+ 'name': partner.name,
+ 'lang': partner.lang,
+ 'email': partner.email,
+ 'zip': partner.zip,
+ 'city': partner.city,
+ 'address': _partner_format_address(partner.street, partner.street2),
+ 'country_id': partner.country_id.id,
+ 'country': partner.country_id,
+ 'phone': partner.phone,
+ }
+ else:
+ partner, partner_data = False, {}
+ partner_data.update(partner_values)
+
+ if currency_id:
+ currency = self.pool['res.currency'].browse(cr, uid, currency_id, context=context)
+ else:
+ currency = self.pool['res.users'].browse(cr, uid, uid, context=context).company_id.currency_id
+ tx_data = {
+ 'reference': reference,
+ 'amount': amount,
+ 'currency_id': currency.id,
+ 'currency': currency,
+ 'partner': partner,
+ }
+
+ # update tx values
+ tx_data.update(tx_values)
+
+ # update partner values
+ if not partner_data.get('address'):
+ partner_data['address'] = _partner_format_address(partner_data.get('street', ''), partner_data.get('street2', ''))
+ if not partner_data.get('country') and partner_data.get('country_id'):
+ partner_data['country'] = self.pool['res.country'].browse(cr, uid, partner_data.get('country_id'), context=context)
+ partner_data.update({
+ 'first_name': _partner_split_name(partner_data['name'])[0],
+ 'last_name': _partner_split_name(partner_data['name'])[1],
+ })
# compute fees
- if hasattr(self, '%s_compute_fees' % acquirer.name):
- tx_values['fees'] = getattr(self, '%s_compute_fees' % acquirer.name)(cr, uid, id, amount, currency_id, tx_values.get('country_id'), context=None)
+ fees_method_name = '%s_compute_fees' % acquirer.name
+ if hasattr(self, fees_method_name):
+ fees = getattr(self, fees_method_name)(
+ cr, uid, id, tx_data['amount'], tx_data['currency_id'], partner_data['country_id'], context=None)
+ tx_data['fees'] = float_round(fees, 2)
- return tx_values
+ return (partner_data, tx_data)
- def render(self, cr, uid, id, reference, amount, currency_id, tx_id=None, partner_id=False, partner_values=None, tx_custom_values=None, context=None):
+ def render(self, cr, uid, id, reference, amount, currency_id, tx_id=None, partner_id=False, partner_values=None, tx_values=None, context=None):
""" Renders the form template of the given acquirer as a qWeb template.
All templates will receive:
@@ -120,9 +190,9 @@ class PaymentAcquirer(osv.Model):
- reference: reference of the transaction
- partner: the current partner browse record, if any (not necessarily set)
- partner_values: a dictionary of partner-related values
- - tx_custom_values: a dictionary of transaction related values that depends
- on the acquirer. Some specific keys should be managed
- in each provider, depending on the features it offers:
+ - tx_values: a dictionary of transaction related values that depends on
+ the acquirer. Some specific keys should be managed in each
+ provider, depending on the features it offers:
- 'feedback_url': feedback URL, controler that manage answer of the acquirer
(without base url) -> FIXME
@@ -147,38 +217,40 @@ class PaymentAcquirer(osv.Model):
"""
if context is None:
context = {}
- if tx_custom_values is None:
- tx_custom_values = {}
- partner = None
- if partner_id:
- partner = self.pool['res.partner'].browse(cr, uid, partner_id, context=context)
+ if tx_values is None:
+ tx_values = {}
+ if partner_values is None:
+ partner_values = {}
acquirer = self.browse(cr, uid, id, context=context)
- currency = self.pool['res.currency'].browse(cr, uid, currency_id, context=context)
# pre-process values
- tx_values = self.form_preprocess_values(cr, uid, id, reference, amount, currency, tx_id, partner_id, partner_values, tx_custom_values, context=context)
+ amount = float_round(amount, 2)
+ partner_values, tx_values = self.form_preprocess_values(
+ cr, uid, id, reference, amount, currency_id, tx_id, partner_id,
+ partner_values, tx_values, context=context)
# call _form_generate_values to update the tx dict with acqurier specific values
cust_method_name = '%s_form_generate_values' % (acquirer.name)
- if tx_id and hasattr(self.pool['payment.transaction'], cust_method_name):
- method = getattr(self.pool['payment.transaction'], cust_method_name)
- tx_values = method(cr, uid, tx_id, tx_values, context=context)
- elif hasattr(self, cust_method_name):
+ if hasattr(self, cust_method_name):
method = getattr(self, cust_method_name)
- tx_values = method(cr, uid, id, reference, amount, currency, partner_id, partner_values, tx_values, context=context)
+ partner_values, tx_values = method(cr, uid, id, partner_values, tx_values, context=context)
qweb_context = {
+ 'tx_url': context.get('tx_url', self.get_form_action_url(cr, uid, id, context=context)),
+ 'submit_class': context.get('submit_class', 'btn btn-link'),
+ 'submit_txt': context.get('submit_txt'),
'acquirer': acquirer,
'user': self.pool.get("res.users").browse(cr, uid, uid, context=context),
- 'reference': reference,
- 'amount': amount,
- 'currency': currency,
- 'partner': partner,
+ 'reference': tx_values['reference'],
+ 'amount': tx_values['amount'],
+ 'currency': tx_values['currency'],
+ 'partner': tx_values.get('partner'),
'partner_values': partner_values,
'tx_values': tx_values,
'context': context,
}
- # because render accepts view ids but not qweb -> need to find the xml_id
+
+ # because render accepts view ids but not qweb -> need to use the xml_id
return self.pool['ir.ui.view'].render(cr, uid, acquirer.view_template_id.xml_id, qweb_context, engine='ir.qweb', context=context)
@@ -186,12 +258,6 @@ class PaymentTransaction(osv.Model):
""" Transaction Model. Each specific acquirer can extend the model by adding
its own fields.
- Methods that should be added in an acquirer-specific implementation:
-
- - ``_form_generate_values(self, cr, uid, id, tx_custom_values=None,
- context=None)``: method that generates the values used to render the
- form button template.
-
Methods that can be added in an acquirer-specific implementation:
- ``_create``: method receiving values used when creating a new
@@ -230,22 +296,29 @@ class PaymentTransaction(osv.Model):
help='Field used to store error and/or validation messages for information'),
# payment
'amount': fields.float('Amount', required=True,
- help='Amount in cents',
- track_visibility='always'),
- 'fees': fields.float('Fees', help='Fees amount; set by the system because depends on the acquirer'),
+ digits=(16, 2),
+ track_visibility='always',
+ help='Amount in cents'),
+ 'fees': fields.float('Fees',
+ digits=(16, 2),
+ track_visibility='always',
+ help='Fees amount; set by the system because depends on the acquirer'),
'currency_id': fields.many2one('res.currency', 'Currency', required=True),
'reference': fields.char('Order Reference', required=True),
+ 'acquirer_reference': fields.char('Acquirer Order Reference',
+ help='Reference of the TX as stored in the acquirer database'),
# duplicate partner / transaction data to store the values at transaction time
- 'partner_id': fields.many2one('res.partner', 'Partner'),
+ 'partner_id': fields.many2one('res.partner', 'Partner', track_visibility='onchange',),
'partner_name': fields.char('Partner Name'),
'partner_lang': fields.char('Lang'),
'partner_email': fields.char('Email'),
'partner_zip': fields.char('Zip'),
'partner_address': fields.char('Address'),
'partner_city': fields.char('City'),
- 'partner_country_id': fields.many2one('res.country', 'Country'),
+ 'partner_country_id': fields.many2one('res.country', 'Country', required=True),
'partner_phone': fields.char('Phone'),
- 'partner_reference': fields.char('Buyer Reference'),
+ 'partner_reference': fields.char('Partner Reference',
+ help='Reference of the customer in the acquirer database'),
}
_sql_constraints = [
@@ -272,8 +345,9 @@ class PaymentTransaction(osv.Model):
# compute fees
custom_method_name = '%s_compute_fees' % acquirer.name
if hasattr(Acquirer, custom_method_name):
- values['fees'] = getattr(Acquirer, custom_method_name)(
+ fees = getattr(Acquirer, custom_method_name)(
cr, uid, acquirer.id, values.get('amount', 0.0), values.get('currency_id'), values.get('country_id'), context=None)
+ values['fees'] = float_round(fees, 2)
# custom create
custom_method_name = '%s_create' % acquirer.name
@@ -283,30 +357,19 @@ class PaymentTransaction(osv.Model):
return super(PaymentTransaction, self).create(cr, uid, values, context=context)
def on_change_partner_id(self, cr, uid, ids, partner_id, context=None):
+ partner = None
if partner_id:
partner = self.pool['res.partner'].browse(cr, uid, partner_id, context=context)
- values = {
- 'partner_name': partner.name,
- 'partner_lang': partner.lang,
- 'partner_email': partner.email,
- 'partner_zip': partner.zip,
- 'partner_address': _partner_format_address(partner.street, partner.street2),
- 'partner_city': partner.city,
- 'partner_country_id': partner.country_id.id,
- 'partner_phone': partner.phone,
- }
- else:
- values = {
- 'partner_name': False,
- 'partner_lang': 'en_US',
- 'partner_email': False,
- 'partner_zip': False,
- 'partner_address': False,
- 'partner_city': False,
- 'partner_country_id': False,
- 'partner_phone': False,
- }
- return {'values': values}
+ return {'values': {
+ 'partner_name': partner and partner.name or False,
+ 'partner_lang': partner and partner.lang or 'en_US',
+ 'partner_email': partner and partner.email or False,
+ 'partner_zip': partner and partner.zip or False,
+ 'partner_address': _partner_format_address(partner and partner.street or '', partner and partner.street2 or ''),
+ 'partner_city': partner and partner.city or False,
+ 'partner_country_id': partner and partner.country_id.id or False,
+ 'partner_phone': partner and partner.phone or False,
+ }}
# --------------------------------------------------
# FORM RELATED METHODS
diff --git a/addons/payment_acquirer/tests/common.py b/addons/payment_acquirer/tests/common.py
index 5c915f80cbf..93a1820a447 100644
--- a/addons/payment_acquirer/tests/common.py
+++ b/addons/payment_acquirer/tests/common.py
@@ -14,8 +14,10 @@ class PaymentAcquirerCommon(common.TransactionCase):
self.cr, self.uid, [('name', '=', 'EUR')], limit=1)[0]
self.currency_euro = self.registry('res.currency').browse(
self.cr, self.uid, self.currency_euro_id)
- country_belgium_id = self.registry('res.country').search(
+ self.country_belgium_id = self.registry('res.country').search(
self.cr, self.uid, [('code', 'like', 'BE')], limit=1)[0]
+ self.country_france_id = self.registry('res.country').search(
+ self.cr, self.uid, [('code', 'like', 'FR')], limit=1)[0]
# dict partner values
self.buyer_values = {
@@ -27,7 +29,7 @@ class PaymentAcquirerCommon(common.TransactionCase):
'phone': '0032 12 34 56 78',
'city': 'Sin City',
'zip': '1000',
- 'country_id': country_belgium_id,
+ 'country_id': self.country_belgium_id,
'country_name': 'Belgium',
}
@@ -42,6 +44,6 @@ class PaymentAcquirerCommon(common.TransactionCase):
'phone': '0032 12 34 56 78',
'city': 'Sin City',
'zip': '1000',
- 'country_id': country_belgium_id,
+ 'country_id': self.country_belgium_id,
}
)
diff --git a/addons/payment_acquirer/views/payment_acquirer.xml b/addons/payment_acquirer/views/payment_acquirer.xml
index 7377f4aedb3..9f7429d3f22 100644
--- a/addons/payment_acquirer/views/payment_acquirer.xml
+++ b/addons/payment_acquirer/views/payment_acquirer.xml
@@ -38,10 +38,10 @@
- This is an HTML form template to submit a payment through this acquirer.
- The template will be rendered with qWeb, so it may use qWeb expressions.
- The qWeb evaluation context provides:
+ This template renders the acquirer button with all necessary values.
+ It is be rendered with qWeb with the following evaluation context:
+
tx_url: transaction URL to post the form
acquirer: payment.acquirer browse record
user: current user browse record
reference: the transaction reference number
@@ -49,7 +49,7 @@
amount: the transaction amount, a float
partner: the buyer partner browse record, not necessarily set
partner_values: specific values about the buyer, for example coming from a shipping form
+
+
+
+
diff --git a/addons/website_customer_crm_partner_assign/__init__.py b/addons/website_customer_crm_partner_assign/__init__.py
deleted file mode 100644
index eecb359a225..00000000000
--- a/addons/website_customer_crm_partner_assign/__init__.py
+++ /dev/null
@@ -1,20 +0,0 @@
-# -*- coding: utf-8 -*-
-##############################################################################
-#
-# OpenERP, Open Source Management Solution
-# Copyright (C) 2013-Today OpenERP S.A. ().
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as
-# published by the Free Software Foundation, either version 3 of the
-# License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
-#
-##############################################################################
diff --git a/addons/website_customer_crm_partner_assign/__openerp__.py b/addons/website_customer_crm_partner_assign/__openerp__.py
deleted file mode 100644
index 92cb0404f3e..00000000000
--- a/addons/website_customer_crm_partner_assign/__openerp__.py
+++ /dev/null
@@ -1,42 +0,0 @@
-# -*- coding: utf-8 -*-
-##############################################################################
-#
-# OpenERP, Open Source Management Solution
-# Copyright (C) 2013-Today OpenERP S.A. ().
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as
-# published by the Free Software Foundation, either version 3 of the
-# License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
-#
-##############################################################################
-
-{
- 'name': 'Public Customer References + Partner Assign',
- 'category': 'Website',
- 'summary': 'Add Partner Assignment Info to your Customer References',
- 'version': '1.0',
- 'description': """
-OpenERP Customer References + Partner Assign
-============================================
-""",
- 'author': 'OpenERP SA',
- 'depends': [
- 'crm_partner_assign',
- 'website_customer'
- ],
- 'data': [
- 'views/website_customer.xml',
- ],
- 'qweb': [],
- 'installable': False,
- 'auto_install': False,
-}
diff --git a/addons/website_customer_crm_partner_assign/views/website_customer.xml b/addons/website_customer_crm_partner_assign/views/website_customer.xml
deleted file mode 100644
index 0e65885f72c..00000000000
--- a/addons/website_customer_crm_partner_assign/views/website_customer.xml
+++ /dev/null
@@ -1,59 +0,0 @@
-
-
-
-
-
-
-
-
-
-
diff --git a/addons/website_payment/__init__.py b/addons/website_payment/__init__.py
index edccdf73182..ee70d6d3229 100644
--- a/addons/website_payment/__init__.py
+++ b/addons/website_payment/__init__.py
@@ -18,5 +18,3 @@
# along with this program. If not, see .
#
##############################################################################
-
-import controllers
diff --git a/addons/website_payment/__openerp__.py b/addons/website_payment/__openerp__.py
index 01b69d33ddd..e85803182de 100644
--- a/addons/website_payment/__openerp__.py
+++ b/addons/website_payment/__openerp__.py
@@ -1,42 +1,18 @@
# -*- coding: utf-8 -*-
-##############################################################################
-#
-# OpenERP, Open Source Management Solution
-# Copyright (C) 2013-Today OpenERP SA ().
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as
-# published by the Free Software Foundation, either version 3 of the
-# License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
-#
-##############################################################################
{
- 'name': 'Payment: Website Integration (Test Module)',
+ 'name': 'Payment: Website Integration',
'category': 'Website',
- 'summary': 'Payment: Website Integration (Test Module)',
+ 'summary': 'Payment: Website Integration',
'version': '1.0',
- 'description': """Module installing all sub-payment modules and adding some
- controllers and menu entries in order to test them.""",
+ 'description': """Bridge module for acquirers and website.""",
'author': 'OpenERP SA',
'depends': [
'website',
'payment_acquirer',
- 'payment_acquirer_ogone',
- 'payment_acquirer_paypal',
- 'payment_acquirer_transfer',
],
'data': [
'views/website_payment_templates.xml',
],
- 'installable': False,
- 'active': False,
+ 'auto_install': True,
}
diff --git a/addons/website_payment/controllers/main.py b/addons/website_payment/controllers/main.py
deleted file mode 100644
index 4a971975d97..00000000000
--- a/addons/website_payment/controllers/main.py
+++ /dev/null
@@ -1,95 +0,0 @@
-# -*- coding: utf-8 -*-
-##############################################################################
-#
-# OpenERP, Open Source Management Solution
-# Copyright (C) 2013-Today OpenERP SA ().
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as
-# published by the Free Software Foundation, either version 3 of the
-# License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
-#
-##############################################################################
-
-from openerp.addons.web import http
-from openerp.addons.web.http import request
-from openerp.addons.website.models import website
-
-
-class WebsitePayment(http.Controller):
-
- @website.route([
- '/payment/paypal/test',
- ], type='http', auth="public")
- def paypal_test(self, **post):
- """ TODO
- """
- cr, uid, context = request.cr, request.uid, request.context
- acquirer_obj = request.registry['payment.acquirer']
- payment_obj = request.registry['payment.transaction']
- currency_obj = request.registry['res.currency']
-
- paypal_id = acquirer_obj.search(cr, uid, [('name', '=', 'paypal')], limit=1, context=context)[0]
- currency_id = currency_obj.search(cr, uid, [('name', '=', 'EUR')], limit=1, context=context)[0]
-
- nbr_tx = payment_obj.search(cr, uid, [], count=True, context=context)
- tx_id = payment_obj.create(cr, uid, {
- 'reference': 'test_ref_%s' % (nbr_tx),
- 'amount': 1.95,
- 'currency_id': currency_id,
- 'acquirer_id': paypal_id,
- 'partner_name': 'Norbert Buyer',
- 'partner_email': 'norbert.buyer@example.com',
- 'partner_lang': 'fr_FR',
- }, context=context)
-
- paypal_form = acquirer_obj.render(cr, uid, paypal_id, None, None, None, tx_id=tx_id, context=context)
- paypal = acquirer_obj.browse(cr, uid, paypal_id, context=context)
-
- values = {
- 'acquirer': paypal,
- 'acquirer_form': paypal_form,
- }
- return request.website.render("website_payment.index_paypal", values)
-
- @website.route([
- '/payment/ogone/test',
- ], type='http', auth="public")
- def ogone_test(self, **post):
- """ TODO
- """
- cr, uid, context = request.cr, request.uid, request.context
- acquirer_obj = request.registry['payment.acquirer']
- payment_obj = request.registry['payment.transaction']
- currency_obj = request.registry['res.currency']
-
- ogone_id = acquirer_obj.search(cr, uid, [('name', '=', 'ogone')], limit=1, context=context)[0]
- currency_id = currency_obj.search(cr, uid, [('name', '=', 'EUR')], limit=1, context=context)[0]
-
- nbr_tx = payment_obj.search(cr, uid, [], count=True, context=context)
- tx_id = payment_obj.create(cr, uid, {
- 'reference': 'test_ref_%s' % (nbr_tx),
- 'amount': 1.95,
- 'currency_id': currency_id,
- 'acquirer_id': ogone_id,
- 'partner_name': 'Norbert Buyer',
- 'partner_email': 'norbert.buyer@example.com',
- 'partner_lang': 'fr_FR',
- }, context=context)
-
- ogone_form = acquirer_obj.render(cr, uid, ogone_id, None, None, None, tx_id=tx_id, context=context)
- ogone = acquirer_obj.browse(cr, uid, ogone_id, context=context)
-
- values = {
- 'acquirer': ogone,
- 'acquirer_form': ogone_form,
- }
- return request.website.render("website_payment.index_ogone", values)
diff --git a/addons/website_payment/views/website_payment_templates.xml b/addons/website_payment/views/website_payment_templates.xml
index bf6b151326f..a7be06b7117 100644
--- a/addons/website_payment/views/website_payment_templates.xml
+++ b/addons/website_payment/views/website_payment_templates.xml
@@ -1,100 +1,31 @@
-
-
-
-
- Paypal (Test)
- /payment/paypal/test
-
- 90
-
-
-
- Ogone (Test)
- /payment/ogone/test
-
- 91
-
-
-
- Transfer (Test)
- /payment/transfer/test
-
- 92
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Paypal payment: form based
-
-
+
+
+
Paypal payment: server 2 server
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
- Ogone payment
-
-
+
+
+
-
-
-
-
-
-
-
-
-
- Transfer payment
-
-
+
+
+
-
-
+
+
+
+
+
+
-
diff --git a/addons/website_sale/controllers/main.py b/addons/website_sale/controllers/main.py
index 50a035ebe65..6bfa59bf143 100644
--- a/addons/website_sale/controllers/main.py
+++ b/addons/website_sale/controllers/main.py
@@ -121,19 +121,19 @@ class Ecommerce(http.Controller):
return product_obj.browse(request.cr, request.uid, product_ids, context=request.context)
def has_search_filter(self, attribute_id, value_id=None):
- if request.httprequest.args.get('filter'):
- filter = simplejson.loads(request.httprequest.args['filter'])
+ if request.httprequest.args.get('filters'):
+ filters = simplejson.loads(request.httprequest.args['filters'])
else:
- filter = []
- for key_val in filter:
+ filters = []
+ for key_val in filters:
if key_val[0] == attribute_id and (not value_id or value_id in key_val[1:]):
return key_val
return False
- @website.route(['/shop/filter/'], type='http', auth="public", multilang=True)
- def filter(self, **post):
+ @website.route(['/shop/filters/'], type='http', auth="public", multilang=True)
+ def filters(self, **post):
index = []
- filter = []
+ filters = []
for key, val in post.items():
cat = key.split("-")
if len(cat) < 3 or cat[2] in ('max','minmem','maxmem'):
@@ -145,19 +145,19 @@ class Ecommerce(http.Controller):
_max = int(post.pop("att-%s-max" % cat[1]))
_min = int(val)
if (minmem != _min or maxmem != _max) and cat_id not in index:
- filter.append([cat_id , [_min, _max] ])
+ filters.append([cat_id , [_min, _max] ])
index.append(cat_id)
elif cat_id not in index:
- filter.append([ cat_id, int(cat[2]) ])
+ filters.append([ cat_id, int(cat[2]) ])
index.append(cat_id)
else:
cat[2] = int(cat[2])
- if cat[2] not in filter[index.index(cat_id)][1:]:
- filter[index.index(cat_id)].append( cat[2] )
+ if cat[2] not in filters[index.index(cat_id)][1:]:
+ filters[index.index(cat_id)].append( cat[2] )
post.pop(key)
- return request.redirect("/shop/?filter=%s%s%s" % (
- simplejson.dumps(filter),
+ return request.redirect("/shop/?filters=%s%s%s" % (
+ simplejson.dumps(filters),
post.get("search") and ("&search=%s" % post.get("search")) or "",
post.get("category") and ("&category=%s" % post.get("category")) or ""
))
@@ -188,7 +188,7 @@ class Ecommerce(http.Controller):
'/shop/category//',
'/shop/category//page//'
], type='http', auth="public", multilang=True)
- def shop(self, category=0, page=0, filter_domain='', search='', **post):
+ def shop(self, category=0, page=0, filters='', search='', **post):
cr, uid, context = request.cr, request.uid, request.context
product_obj = request.registry.get('product.template')
domain = request.registry.get('website').get_website_sale_domain()
@@ -198,10 +198,10 @@ class Ecommerce(http.Controller):
('description', 'ilike', "%%%s%%" % search)]
if category:
domain.append(('product_variant_ids.public_categ_id', 'child_of', category))
- if filter_domain:
- filter_domain = simplejson.loads(filter_domain)
- if filter_domain:
- ids = self.attributes_to_ids(filter_domain)
+ if filters:
+ filters = simplejson.loads(filters)
+ if filters:
+ ids = self.attributes_to_ids(filters)
domain.append(('id', 'in', ids or [0]))
product_count = product_obj.search_count(cr, uid, domain, context=context)
@@ -228,10 +228,12 @@ class Ecommerce(http.Controller):
values = {
'products': products,
'bins': table_compute().process(products),
+ 'rows': PPR,
+ 'range': range,
'search': {
'search': search,
'category': category,
- 'filter_domain': filter_domain,
+ 'filters': filters,
},
'pager': pager,
'styles': styles,
@@ -242,7 +244,9 @@ class Ecommerce(http.Controller):
return request.website.render("website_sale.products", values)
@website.route(['/shop/product//'], type='http', auth="public", multilang=True)
- def product(self, product, search='', category='', filter_domain='', **kwargs):
+ def product(self, product, search='', category='', filters='', **kwargs):
+ website.preload_records(product, on_error="website_sale.404")
+
category_obj = request.registry.get('product.public.category')
category_ids = category_obj.search(request.cr, request.uid, [], context=request.context)
@@ -263,7 +267,7 @@ class Ecommerce(http.Controller):
'search': {
'search': search,
'category': category and str(category.id),
- 'filter': filter_domain,
+ 'filters': filters,
}
}
return request.website.render("website_sale.product", values)
@@ -600,21 +604,23 @@ class Ecommerce(http.Controller):
# fetch all registered payment means
if tx:
- payment_ids = [tx.acquirer_id.id]
+ acquirer_ids = [tx.acquirer_id.id]
else:
- payment_ids = payment_obj.search(cr, SUPERUSER_ID, [('portal_published', '=', True)], context=context)
- values['payments'] = payment_obj.browse(cr, uid, payment_ids, context=context)
- for pay in values['payments']:
- pay._content = payment_obj.render(
- cr, uid, pay.id,
+ acquirer_ids = payment_obj.search(cr, SUPERUSER_ID, [('portal_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']:
+ render_ctx['tx_url'] = '/shop/payment/transaction/%s' % acquirer.id
+ acquirer.button = payment_obj.render(
+ cr, uid, acquirer.id,
order.name,
order.amount_total,
- order.pricelist_id.currency_id,
+ order.pricelist_id.currency_id.id,
partner_id=shipping_partner_id,
- tx_custom_values={
+ tx_values={
'return_url': '/shop/payment/validate',
},
- context=context)
+ context=render_ctx)
return request.website.render("website_sale.payment", values)
diff --git a/addons/website_sale/static/src/js/website_sale.js b/addons/website_sale/static/src/js/website_sale.js
index 20357dd6973..d5fcd913684 100644
--- a/addons/website_sale/static/src/js/website_sale.js
+++ b/addons/website_sale/static/src/js/website_sale.js
@@ -7,13 +7,6 @@ $(document).ready(function () {
$(".oe_website_sale .js_shipping").toggle();
});
- var $payment = $(".oe_website_sale .js_payment");
- $payment.find("input[name='payment_type']").click(function (ev) {
- var payment_id = $(ev.currentTarget).val();
- $("div[data-id]", $payment).addClass("hidden");
- $("a.btn:last, div[data-id='"+payment_id+"']", $payment).removeClass("hidden");
- });
-
// change for css
$(document).on('mouseup', '.js_publish', function (ev) {
$(ev.currentTarget).parents(".thumbnail").toggleClass("disabled");
diff --git a/addons/website_sale/static/src/js/website_sale_payment.js b/addons/website_sale/static/src/js/website_sale_payment.js
index 3da753c03f9..2821f6380a1 100644
--- a/addons/website_sale/static/src/js/website_sale_payment.js
+++ b/addons/website_sale/static/src/js/website_sale_payment.js
@@ -1,14 +1,11 @@
$(document).ready(function () {
- /* Hitting the payment button: payment transaction process begins
- * We redirect the user to a custom shop page in oder to create the
- * transaction. The form POST data will be used to perform the post
- * query.
- */
- $('input#payment_submit').on('click', function (ev) { // TDEFIXME: change input#ID to input inside payment form, less strict
- var acquirer_id = $(this).closest('form').closest('div.oe_payment_acquirer').data().id || 0;
- var form_action = $(this).closest("form").attr('action');
- console.log('cliking on submit for payment - redirecting from', form_action, 'to shop with acqurier_id', acquirer_id);
- $(this).closest("form").attr("action", '/shop/payment/transaction/' + acquirer_id);
+ // When choosing an acquirer, display its Pay Now button
+ var $payment = $("#payment_method");
+ $payment.find("input[name='acquirer']").click(function (ev) {
+ var payment_id = $(ev.currentTarget).val();
+ $("div.oe_sale_acquirer_button[data-id]", $payment).addClass("hidden");
+ $("div.oe_sale_acquirer_button[data-id='"+payment_id+"']", $payment).removeClass("hidden");
});
+
});
diff --git a/addons/website_sale/views/website_sale.xml b/addons/website_sale/views/website_sale.xml
index d012490b7b4..24328b6dbb9 100644
--- a/addons/website_sale/views/website_sale.xml
+++ b/addons/website_sale/views/website_sale.xml
@@ -4,7 +4,7 @@
-
+
@@ -40,7 +40,7 @@
-
+
@@ -49,7 +49,7 @@