Browse Source

[PEP8] make the code comply with PEP8

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

46
easy_my_coop_online_payment/controllers/main.py

@ -1,21 +1,17 @@
# -*- 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']
@ -24,22 +20,26 @@ class SubscriptionOnlinePayment(WebsiteSubscription):
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),
@ -47,7 +47,7 @@ class SubscriptionWebsitePayment(website_payment):
'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:
@ -58,7 +58,9 @@ class SubscriptionWebsitePayment(website_payment):
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:
@ -69,8 +71,11 @@ class SubscriptionWebsitePayment(website_payment):
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,7 +93,10 @@ 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

Loading…
Cancel
Save