From 9ae59380f610afa83c5cdd42e50e936fbfab9731 Mon Sep 17 00:00:00 2001 From: "robin.keunen" Date: Fri, 10 Apr 2020 18:20:29 +0200 Subject: [PATCH] [REM] easy_my_coop_online_payment : not in v12 --- easy_my_coop_online_payment/__init__.py | 2 - easy_my_coop_online_payment/__openerp__.py | 40 ------- .../controllers/__init__.py | 1 - .../controllers/main.py | 112 ------------------ easy_my_coop_online_payment/i18n/fr.po | 65 ---------- .../models/__init__.py | 2 - easy_my_coop_online_payment/models/coop.py | 26 ---- .../models/payment_transaction.py | 47 -------- .../views/online_payment_template.xml | 25 ---- .../views/subscription_request_view.xml | 28 ----- 10 files changed, 348 deletions(-) delete mode 100644 easy_my_coop_online_payment/__init__.py delete mode 100644 easy_my_coop_online_payment/__openerp__.py delete mode 100644 easy_my_coop_online_payment/controllers/__init__.py delete mode 100644 easy_my_coop_online_payment/controllers/main.py delete mode 100644 easy_my_coop_online_payment/i18n/fr.po delete mode 100644 easy_my_coop_online_payment/models/__init__.py delete mode 100644 easy_my_coop_online_payment/models/coop.py delete mode 100644 easy_my_coop_online_payment/models/payment_transaction.py delete mode 100644 easy_my_coop_online_payment/views/online_payment_template.xml delete mode 100644 easy_my_coop_online_payment/views/subscription_request_view.xml diff --git a/easy_my_coop_online_payment/__init__.py b/easy_my_coop_online_payment/__init__.py deleted file mode 100644 index af57e79..0000000 --- a/easy_my_coop_online_payment/__init__.py +++ /dev/null @@ -1,2 +0,0 @@ -from . import models -from . import controllers \ No newline at end of file diff --git a/easy_my_coop_online_payment/__openerp__.py b/easy_my_coop_online_payment/__openerp__.py deleted file mode 100644 index d2eb18f..0000000 --- a/easy_my_coop_online_payment/__openerp__.py +++ /dev/null @@ -1,40 +0,0 @@ -# -*- coding: utf-8 -*- -############################################################################## -# -# Copyright (C) 2013-2017 Open Architects Consulting SPRL. -# Copyright (C) 2018- Coop IT Easy SCRLfs. -# -# 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": "Easy My Coop Online Payment", - "version": "1.0", - "depends": ["easy_my_coop", - "website_payment", - "payment_paypal"], - "author": "Houssine BAKKALI ", - "category": "Cooperative management", - 'website': "www.coopiteasy.be", - "description": """ - This module allows the cooperator to pay the subscribed shares online - during the subscription process - """, - 'data': [ - "views/online_payment_template.xml", - "views/subscription_request_view.xml", - ], - 'installable': False, - 'application': False, -} diff --git a/easy_my_coop_online_payment/controllers/__init__.py b/easy_my_coop_online_payment/controllers/__init__.py deleted file mode 100644 index 12a7e52..0000000 --- a/easy_my_coop_online_payment/controllers/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from . import main diff --git a/easy_my_coop_online_payment/controllers/main.py b/easy_my_coop_online_payment/controllers/main.py deleted file mode 100644 index f32f746..0000000 --- a/easy_my_coop_online_payment/controllers/main.py +++ /dev/null @@ -1,112 +0,0 @@ -# -*- coding: utf-8 -*- - -from openerp import http -from openerp.http import request -from openerp.tools.translate import _ - -from openerp.addons.easy_my_coop.controllers.main import WebsiteSubscription -from openerp.addons.website_payment.controllers.main import website_payment - - -class SubscriptionOnlinePayment(WebsiteSubscription): - - def fill_values(self, values, is_company, load_from_user=False): - values = super(SubscriptionOnlinePayment, self).fill_values(values, is_company, load_from_user) - fields_desc = request.env['subscription.request'].sudo().fields_get(['payment_type']) - values['payment_types'] = fields_desc['payment_type']['selection'] - - return values - - def get_subscription_response(self, values, kwargs): - subscription = values.get('subscription_id', False) - if kwargs.get('payment_type') == 'online': - invoice = subscription.validate_subscription_request()[0] - acquirer = request.env['payment.acquirer'].search([('website_published', '=', True)])[0] - return website_payment().pay(reference=invoice.number, amount=invoice.residual, currency_id=invoice.currency_id.id, acquirer_id=acquirer.id) - else: - values = self.preRenderThanks(values, kwargs) - return request.website.render(kwargs.get("view_callback", "easy_my_coop.cooperator_thanks"), values) - - return True - - -class SubscriptionWebsitePayment(website_payment): - - @http.route(['/website_payment/transaction'], - type='json', - auth="public", website=True) - def transaction(self, reference, amount, currency_id, acquirer_id): - inv_obj = request.env['account.invoice'] - partner_id = request.env.user.partner_id.id if request.env.user.partner_id != request.website.partner_id else False - capital_release_request = inv_obj.sudo().search([('release_capital_request', '=', True), - ('number', '=', reference)]) - - values = { - 'acquirer_id': int(acquirer_id), - 'reference': reference, - 'amount': float(amount), - 'currency_id': int(currency_id), - 'partner_id': partner_id, - 'release_capital_request': capital_release_request.id, - } - - if len(capital_release_request) > 0: - values['partner_id'] = capital_release_request.partner_id.id - values['release_capital_request'] = capital_release_request.id - - tx = request.env['payment.transaction'].sudo().create(values) - request.session['website_payment_tx_id'] = tx.id - return tx.id - - @http.route(['/website_payment/confirm'], - type='http', - auth='public', website=True) - def confirm(self, **kw): - tx_id = request.session.pop('website_payment_tx_id', False) - if tx_id: - tx = request.env['payment.transaction'].sudo().browse(tx_id) - status = (tx.state == 'done' and 'success') or 'danger' - message = (tx.state == 'done' and 'Your payment was successful! It may take some time to be validated on our end.') or 'OOps! There was a problem with your payment.' - return request.website.render('website_payment.confirm', {'tx': tx, 'status': status, 'message': message}) - else: - return request.redirect('/my/home') - - @http.route(['/website_payment/pay'], - type='http', - auth='public', website=True) - def pay(self, reference='', amount=False, currency_id=None, - acquirer_id=None, **kw): - env = request.env - user = env.user.sudo() - - currency_id = currency_id and int(currency_id) or user.company_id.currency_id.id - currency = env['res.currency'].browse(currency_id) - - # Try default one then fallback on first - acquirer_id = acquirer_id and int(acquirer_id) or \ - env['ir.values'].get_default('payment.transaction', 'acquirer_id', company_id=user.company_id.id) or \ - env['payment.acquirer'].search([('website_published', '=', True), ('company_id', '=', user.company_id.id)])[0].id - - acquirer = env['payment.acquirer'].with_context(submit_class='btn btn-primary pull-right', - submit_txt=_('Pay Now')).browse(acquirer_id) - # auto-increment reference with a number suffix if the reference already exists - reference = request.env['payment.transaction'].get_next_reference(reference) - - partner_id = user.partner_id.id if user.partner_id.id != request.website.partner_id.id else False - capital_release_request = request.env['account.invoice'].sudo().search( - [('release_capital_request', '=', True), - ('number', '=', reference)] - ) - - if len(capital_release_request) > 0: - partner_id = capital_release_request.partner_id.id - - payment_form = acquirer.sudo().render(reference, float(amount), currency.id, values={'return_url': '/website_payment/confirm', 'partner_id': partner_id})[0] - values = { - 'reference': reference, - 'acquirer': acquirer, - 'currency': currency, - 'amount': float(amount), - 'payment_form': payment_form, - } - return request.website.render('website_payment.pay', values) diff --git a/easy_my_coop_online_payment/i18n/fr.po b/easy_my_coop_online_payment/i18n/fr.po deleted file mode 100644 index f5342f8..0000000 --- a/easy_my_coop_online_payment/i18n/fr.po +++ /dev/null @@ -1,65 +0,0 @@ -# Translation of Odoo Server. -# This file contains the translation of the following modules: -# * easy_my_coop_online_payment -# -msgid "" -msgstr "" -"Project-Id-Version: Odoo Server 9.0c\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2017-01-18 21:56+0000\n" -"PO-Revision-Date: 2017-01-18 23:19+0100\n" -"Last-Translator: <>\n" -"Language-Team: \n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"Plural-Forms: nplurals=2; plural=(n > 1);\n" -"X-Generator: Poedit 1.6.5\n" -"Language: fr\n" - -#. module: easy_my_coop_online_payment -#: model:ir.ui.view,arch_db:easy_my_coop_online_payment.SubscriptionOnlinePayment -msgid " Pay Now" -msgstr " Pay Now" - -#. module: easy_my_coop_online_payment -#: selection:subscription.request,payment_type:0 -msgid "Deferred" -msgstr "Différé" - -#. module: easy_my_coop_online_payment -#: selection:subscription.request,payment_type:0 -msgid "Online" -msgstr "En ligne" - -#. module: easy_my_coop_online_payment -#: code:addons/easy_my_coop_online_payment/controllers/main.py:86 -#: model:ir.ui.view,arch_db:easy_my_coop_online_payment.SubscriptionOnlinePayment -#, python-format -msgid "Pay Now" -msgstr "Payer Maintenant" - -#. module: easy_my_coop_online_payment -#: model:ir.model,name:easy_my_coop_online_payment.model_payment_transaction -msgid "Payment Transaction" -msgstr "Transaction" - -#. module: easy_my_coop_online_payment -#: model:ir.model.fields,field_description:easy_my_coop_online_payment.field_subscription_request_payment_type -msgid "Payment Type" -msgstr "Type de paiement" - -#. module: easy_my_coop_online_payment -#: model:ir.ui.view,arch_db:easy_my_coop_online_payment.subscription_payment_type -msgid "Payment type" -msgstr "Type de paiement" - -#. module: easy_my_coop_online_payment -#: model:ir.model.fields,field_description:easy_my_coop_online_payment.field_payment_transaction_release_capital_request -msgid "Release Capital request" -msgstr "Demande de libération de capital" - -#. module: easy_my_coop_online_payment -#: model:ir.model,name:easy_my_coop_online_payment.model_subscription_request -msgid "Subscription Request" -msgstr "Demande de souscription" diff --git a/easy_my_coop_online_payment/models/__init__.py b/easy_my_coop_online_payment/models/__init__.py deleted file mode 100644 index 2e8c044..0000000 --- a/easy_my_coop_online_payment/models/__init__.py +++ /dev/null @@ -1,2 +0,0 @@ -from . import payment_transaction -from . import coop diff --git a/easy_my_coop_online_payment/models/coop.py b/easy_my_coop_online_payment/models/coop.py deleted file mode 100644 index 3bf7aa8..0000000 --- a/easy_my_coop_online_payment/models/coop.py +++ /dev/null @@ -1,26 +0,0 @@ -# -*- coding: utf-8 -*- -from openerp import fields, models - - -class SubscriptionRequest(models.Model): - _inherit = 'subscription.request' - - payment_type = fields.Selection([('online', 'Online'), - ('deferred', 'Deferred')], - string='Payment Type', - default="deferred") - - def send_capital_release_request(self, inv): - if self.payment_type == 'deferred': - super(SubscriptionRequest, self).send_capital_release_request(inv) - return True - - -class AccountInvoice(models.Model): - _inherit = 'account.invoice' - - def post_process_confirm_paid(self, effective_date): - if self.subscription_request.payment_type == 'deferred': - self.set_cooperator_effective(effective_date) - - return True diff --git a/easy_my_coop_online_payment/models/payment_transaction.py b/easy_my_coop_online_payment/models/payment_transaction.py deleted file mode 100644 index 312177e..0000000 --- a/easy_my_coop_online_payment/models/payment_transaction.py +++ /dev/null @@ -1,47 +0,0 @@ -# -*- coding: utf-8 -*- -from datetime import datetime -import logging - -from openerp import api, fields, models - -_logger = logging.getLogger(__name__) - - -class PaymentTransaction(models.Model): - - _inherit = 'payment.transaction' - - release_capital_request = fields.Many2one('account.invoice', - string="Release Capital request") - - @api.model - def process_online_payment_reception(self, tx): - release_capital_request = tx.release_capital_request - release_capital_request.subscription_request[0].state = 'paid' - effective_date = datetime.now().strftime("%d/%m/%Y") - release_capital_request.sudo().set_cooperator_effective(effective_date) - - return True - - @api.v7 - def _paypal_form_validate(self, cr, uid, tx, data, context=None): - status = data.get('payment_status') - res = { - 'acquirer_reference': data.get('txn_id'), - 'paypal_txn_type': data.get('payment_type'), - } - if status in ['Completed', 'Processed']: - _logger.info('Validated Paypal payment for tx %s: set as done' % (tx.reference)) - res.update(state='done', date_validate=fields.Datetime.now()) - result = tx.write(res) - self.process_online_payment_reception(cr, uid, tx) - return result - elif status in ['Pending', 'Expired']: - _logger.info('Received notification for Paypal payment %s: set as pending' % (tx.reference)) - res.update(state='pending', state_message=data.get('pending_reason', '')) - return tx.write(res) - else: - error = 'Received unrecognized status for Paypal payment %s: %s, set as error' % (tx.reference, status) - _logger.info(error) - res.update(state='error', state_message=error) - return tx.write(res) diff --git a/easy_my_coop_online_payment/views/online_payment_template.xml b/easy_my_coop_online_payment/views/online_payment_template.xml deleted file mode 100644 index a447e9a..0000000 --- a/easy_my_coop_online_payment/views/online_payment_template.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - diff --git a/easy_my_coop_online_payment/views/subscription_request_view.xml b/easy_my_coop_online_payment/views/subscription_request_view.xml deleted file mode 100644 index ffcb357..0000000 --- a/easy_my_coop_online_payment/views/subscription_request_view.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - subscription.request.tree - subscription.request - - - - - - - - - - subscription.request.tree - subscription.request - - - - - - - - - - \ No newline at end of file