From 04e6a95cd5363f97db4e0acacdfbe5444d552917 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Fri, 8 Nov 2013 10:44:44 +0100 Subject: [PATCH] [ADD] [MOV] payment_acquirer: added transfer payment acquirer Only dummy module currently. Allowed to remove some old stuff from payment_acquirer. bzr revid: tde@openerp.com-20131108094444-to0kgzkl2agqkdps --- addons/payment_acquirer/__openerp__.py | 1 - .../data/payment_acquirer_data.xml | 64 -------- .../models/payment_acquirer.py | 3 +- .../views/payment_acquirer_views.xml | 1 + addons/payment_acquirer_transfer/__init__.py | 22 +++ .../payment_acquirer_transfer/__openerp__.py | 35 +++++ .../data/transfer.xml | 13 ++ .../models/__init__.py | 22 +++ .../models/payment_acquirer.py | 36 +++++ .../tests/__init__.py | 22 +++ .../payment_acquirer_transfer/tests/common.py | 66 ++++++++ .../views/transfer.xml | 148 ++++++++++++++++++ 12 files changed, 367 insertions(+), 66 deletions(-) delete mode 100644 addons/payment_acquirer/data/payment_acquirer_data.xml create mode 100644 addons/payment_acquirer_transfer/__init__.py create mode 100644 addons/payment_acquirer_transfer/__openerp__.py create mode 100644 addons/payment_acquirer_transfer/data/transfer.xml create mode 100644 addons/payment_acquirer_transfer/models/__init__.py create mode 100644 addons/payment_acquirer_transfer/models/payment_acquirer.py create mode 100644 addons/payment_acquirer_transfer/tests/__init__.py create mode 100644 addons/payment_acquirer_transfer/tests/common.py create mode 100644 addons/payment_acquirer_transfer/views/transfer.xml diff --git a/addons/payment_acquirer/__openerp__.py b/addons/payment_acquirer/__openerp__.py index 164e1d77318..06c3aa19d40 100644 --- a/addons/payment_acquirer/__openerp__.py +++ b/addons/payment_acquirer/__openerp__.py @@ -29,7 +29,6 @@ 'depends': ['decimal_precision', 'mail'], 'data': [ 'views/payment_acquirer_views.xml', - 'data/payment_acquirer_data.xml', 'security/ir.model.access.csv', ], 'installable': True, diff --git a/addons/payment_acquirer/data/payment_acquirer_data.xml b/addons/payment_acquirer/data/payment_acquirer_data.xml deleted file mode 100644 index e99186dc922..00000000000 --- a/addons/payment_acquirer/data/payment_acquirer_data.xml +++ /dev/null @@ -1,64 +0,0 @@ - - - - - - - - - - - - - - - - - - diff --git a/addons/payment_acquirer/models/payment_acquirer.py b/addons/payment_acquirer/models/payment_acquirer.py index 0007482aa04..aa9bdeb3f95 100644 --- a/addons/payment_acquirer/models/payment_acquirer.py +++ b/addons/payment_acquirer/models/payment_acquirer.py @@ -168,9 +168,10 @@ class PaymentTransaction(osv.Model): def create(self, cr, uid, values, context=None): if not 'name' in values and 'reference' in values: values['name'] = values['reference'] - if values.get('partner_id'): + if values.get('partner_id'): # @TDENOTE: not sure values.update(self.on_change_partner_id(cr, uid, None, values.get('partner_id'), context=context)['values']) + # call custom create method if defined (i.e. ogone_create for ogone) if values.get('acquirer_id'): acquirer = self.pool['payment.acquirer'].browse(cr, uid, values.get('acquirer_id'), context=context) custom_method_name = '%s_create' % acquirer.name diff --git a/addons/payment_acquirer/views/payment_acquirer_views.xml b/addons/payment_acquirer/views/payment_acquirer_views.xml index 2937e591951..05ac17f3e52 100644 --- a/addons/payment_acquirer/views/payment_acquirer_views.xml +++ b/addons/payment_acquirer/views/payment_acquirer_views.xml @@ -132,5 +132,6 @@ id='payment_transaction_menu' parent='root_payment_menu' sequence='20' /> + diff --git a/addons/payment_acquirer_transfer/__init__.py b/addons/payment_acquirer_transfer/__init__.py new file mode 100644 index 00000000000..d95d47860af --- /dev/null +++ b/addons/payment_acquirer_transfer/__init__.py @@ -0,0 +1,22 @@ +# -*- 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 . +# +############################################################################## + +import models diff --git a/addons/payment_acquirer_transfer/__openerp__.py b/addons/payment_acquirer_transfer/__openerp__.py new file mode 100644 index 00000000000..87e63f2806a --- /dev/null +++ b/addons/payment_acquirer_transfer/__openerp__.py @@ -0,0 +1,35 @@ +# -*- 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': 'Transfer Payment acquirer', + 'category': 'Hidden', + 'summary': 'Transfer Payment acquirer', + 'version': '0.1', + 'description': """Transfer Payment acquirer""", + 'author': 'OpenERP SA', + 'depends': ['payment_acquirer'], + 'data': [ + 'views/transfer.xml', + 'data/transfer.xml', + ], + 'installable': True, +} diff --git a/addons/payment_acquirer_transfer/data/transfer.xml b/addons/payment_acquirer_transfer/data/transfer.xml new file mode 100644 index 00000000000..0ae3258a038 --- /dev/null +++ b/addons/payment_acquirer_transfer/data/transfer.xml @@ -0,0 +1,13 @@ + + + + + + transfer + + test + + + + + diff --git a/addons/payment_acquirer_transfer/models/__init__.py b/addons/payment_acquirer_transfer/models/__init__.py new file mode 100644 index 00000000000..0ce2de595b2 --- /dev/null +++ b/addons/payment_acquirer_transfer/models/__init__.py @@ -0,0 +1,22 @@ +# -*- 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 . +# +############################################################################## + +import payment_acquirer diff --git a/addons/payment_acquirer_transfer/models/payment_acquirer.py b/addons/payment_acquirer_transfer/models/payment_acquirer.py new file mode 100644 index 00000000000..b9abefb1bcc --- /dev/null +++ b/addons/payment_acquirer_transfer/models/payment_acquirer.py @@ -0,0 +1,36 @@ +# -*- 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.osv import osv +# from openerp.osv import fields + +import logging + +_logger = logging.getLogger(__name__) + + +class TransferPaymentAcquirer(osv.Model): + _name = 'payment.acquirer' + _description = 'Online Payment Acquirer' + + +class TransferPaymentTransaction(osv.Model): + _inherit = ['payment.transaction'] diff --git a/addons/payment_acquirer_transfer/tests/__init__.py b/addons/payment_acquirer_transfer/tests/__init__.py new file mode 100644 index 00000000000..8d0bb0195bf --- /dev/null +++ b/addons/payment_acquirer_transfer/tests/__init__.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Business Applications +# Copyright (c) 2012-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 . +# +############################################################################## + +import common diff --git a/addons/payment_acquirer_transfer/tests/common.py b/addons/payment_acquirer_transfer/tests/common.py new file mode 100644 index 00000000000..df368f5b1dd --- /dev/null +++ b/addons/payment_acquirer_transfer/tests/common.py @@ -0,0 +1,66 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Business Applications +# Copyright (c) 20123TODAY 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 . +# +############################################################################## + +from openerp.tests import common + + +class PaymentAcquirerCommon(common.TransactionCase): + + def setUp(self): + super(PaymentAcquirerCommon, self).setUp() + self.payment_acquirer = self.registry('payment.acquirer') + self.payment_transaction = self.registry('payment.transaction') + + self.currency_euro_id = self.registry('res.currency').search( + 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.cr, self.uid, [('code', 'like', 'BE')], limit=1)[0] + + # dict partner values + self.buyer_values = { + 'name': 'Norbert Buyer', + 'lang': 'en_US', + 'email': 'norbert.buyer@example.com', + 'street': 'Huge Street', + 'street2': '2/543', + 'phone': '0032 12 34 56 78', + 'city': 'Sin City', + 'zip': '1000', + 'country_id': country_belgium_id, + 'country_name': 'Belgium', + } + + # test partner + self.buyer_id = self.registry('res.partner').create( + self.cr, self.uid, { + 'name': 'Norbert Buyer', + 'lang': 'en_US', + 'email': 'norbert.buyer@example.com', + 'street': 'Huge Street', + 'street2': '2/543', + 'phone': '0032 12 34 56 78', + 'city': 'Sin City', + 'zip': '1000', + 'country_id': country_belgium_id, + } + ) diff --git a/addons/payment_acquirer_transfer/views/transfer.xml b/addons/payment_acquirer_transfer/views/transfer.xml new file mode 100644 index 00000000000..77bb8adad4b --- /dev/null +++ b/addons/payment_acquirer_transfer/views/transfer.xml @@ -0,0 +1,148 @@ + + + + + + + + payment.acquirer + +
+ +
+
+ +
+

+ 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: +

    +
  • reference: the reference number of the document to pay
  • +
  • currency: the currency record in which the document is issued (e.g. currency.name could be EUR)
  • +
  • amount: the total amount to pay, as a float
  • +
  • amount_str: the total amount to pay, as a string with the account precision
  • +
  • object: the browse record on which the payment form is rendered (usually an invoice or sales order record)
  • +
  • user_id: the current user browse record
  • +
  • context: the current context dictionary
  • +
+ If the template renders to an empty result in a certain context it will be ignored, as if it was inactive. +

+
+ +
+
+
+
+
+ + + payment.acquirer + + + + + + + + + + + payment.acquirer + + + + + + + + + Payment Acquirers + payment.acquirer + form + tree,form + + + + + + payment.transaction + +
+ + + + + + + + + + + + + + +
+
+
+ + + payment.transaction + + + + + + + + + + + + payment.transaction + + + + + + + + + + + Payment Transactions + payment.transaction + form + tree,form + + + + + + + +
+