Browse Source

[PEP8] make the code comply with PEP8

pull/1/head
houssine 6 years ago
parent
commit
2c9a31e57e
  1. 72
      easy_my_coop_online_payment/controllers/main.py

72
easy_my_coop_online_payment/controllers/main.py

@ -1,55 +1,55 @@
# -*- coding: utf-8 -*-
# import datetime
# import re
import werkzeug
import werkzeug.urls
from openerp import http, SUPERUSER_ID
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)
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)
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)
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)
@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 = request.env['account.invoice'].sudo().search([('release_capital_request','=',True),('number','=',reference)])
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,
'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
@ -57,8 +57,10 @@ class SubscriptionWebsitePayment(website_payment):
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)
@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:
@ -68,9 +70,12 @@ class SubscriptionWebsitePayment(website_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):
@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()
@ -88,11 +93,14 @@ class SubscriptionWebsitePayment(website_payment):
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)])
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,
@ -101,4 +109,4 @@ class SubscriptionWebsitePayment(website_payment):
'amount': float(amount),
'payment_form': payment_form,
}
return request.website.render('website_payment.pay', values)
return request.website.render('website_payment.pay', values)
Loading…
Cancel
Save