gestion des demandes d'évolution pour le centre kalachakra non géré dans les module booking et opendons
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

190 lines
8.4 KiB

# -*- coding: utf-8 -*-
from odoo import http
from odoo.http import request
import werkzeug
from odoo.tools import format_datetime, format_date, is_html_empty
from odoo.exceptions import UserError
from odoo.addons.website_event.controllers.main import WebsiteEventController
from odoo.osv import expression
class kalachakra(WebsiteEventController):
def _extract_searched_event_tags(self, searches):
tags = request.env['event.tag']
if searches.get('tags'):
tags = request.env['event.tag'].search([('name', '=', searches['tags'])])
return tags
@http.route(['/kalachakra/calendar'], type='http', auth='public', website=True, sitemap=False,csrf=False)
def eventCalendar(self,**post):
url='https://calendar.google.com/calendar/embed?height=600&wkst=2&bgcolor=%23ffffff&ctz=Europe%2FParis&mode=WEEK&src=aXRrYWxhY2hha3JhQGdtYWlsLmNvbQ&src=bjYxODA1OXQ2dmRwNmp0Y3Foa3FjMTMwdWtAZ3JvdXAuY2FsZW5kYXIuZ29vZ2xlLmNvbQ&src=MnJzc2VvY3MzcGNiaDliaGFvNXZ1a3JpM3NAZ3JvdXAuY2FsZW5kYXIuZ29vZ2xlLmNvbQ&src=cGJ0YjBtbTBja2NsMDZmdTNvb2ViMDJpOXNAZ3JvdXAuY2FsZW5kYXIuZ29vZ2xlLmNvbQ&src=ZnIuZnJlbmNoI2hvbGlkYXlAZ3JvdXAudi5jYWxlbmRhci5nb29nbGUuY29t&color=%23039BE5&color=%238E24AA&color=%23E4C441&color=%237CB342&color=%230B8043" style="border:solid 1px #777" width="800" height="600" frameborder="0" scrolling="no"'
#url='https://calendar.google.com/calendar/embed?height=600&wkst=1&bgcolor=%23ffffff&ctz=Europe%2FParis&src=cmF5bmFsZC5jYW5kZWxpZXJAZ21haWwuY29t&src=Z3I4aGdpbm5hYjNwZ2ExY3M4MTAxczVlcjhAZ3JvdXAuY2FsZW5kYXIuZ29vZ2xlLmNvbQ&src=ZnIuZnJlbmNoI2hvbGlkYXlAZ3JvdXAudi5jYWxlbmRhci5nb29nbGUuY29t&color=%23039BE5&color=%23D50000&color=%237986CB'
return http.request.render('kalachakra.event_calendar',{'url':url})
@http.route(['/event/calendartui'], type='http', auth='public', website=True, sitemap=False,csrf=False)
def eventCalendartui(self,**post):
return http.request.render('kalachakra.event_calendartui')
@http.route(['/kalachakra/contactus'], type='http', auth='public', website=True, sitemap=False,csrf=False)
def kalachakracontactus(self,**post):
return http.request.render('kalachakra.contactus')
@http.route(['/kalachakra/programme'], type='http', auth='public', website=True, sitemap=False,csrf=False)
def kalachakraprogramme(self,**post):
return http.request.redirect('https://www.dropbox.com/s/ijsd6n82oyp0gw8/programme_Paris.pdf?dl=0')
@http.route(['/kalachakra/makedonation'], type='http', auth='public', website=True, sitemap=False,csrf=False)
def makedonation(self,**post):
data={}
userid=request.env.context.get('uid')
#title options
title=request.env['res.partner.title'].sudo().search([])
data['titles']=title
title_male=request.env['res.partner.title'].sudo().search([('name','=','Monsieur')])
#country options
country=request.env['res.country'].sudo().search([])
data['countries']=country
country_france=request.env['res.country'].sudo().search([('name','=','France')])
if userid:
user=request.env['res.users'].search([('id','=',int(userid))])
partner=request.env['res.partner'].sudo().search([('id','=',int(user.partner_id))])
request.session['partner_id']=int(partner.id)
data['partner']=partner
else:
partner=request.env['res.partner']
partner.email=''
partner.title=title_male.id
partner.country_id=country_france.id
partner.firstname=''
partner.name=''
partner.street=''
partner.street2=''
partner.zip=''
data['partner']=partner
data['amount']=10
data['acquirers'] = list(request.env['payment.acquirer'].search([
('state', 'in', ['enabled', 'test']),('company_id', '=', request.env.company.id)
]))
#récupération du jeton de paiement
# data['tokens'] = request.env['payment.token'].search([
# ('acquirer_id', 'in', acquirers.ids),('partner_id', '=', partner.id)]])
payment_tokens = partner.payment_token_ids
payment_tokens |= partner.commercial_partner_id.sudo().payment_token_ids
data['payment_tokens']=payment_tokens
return http.request.render('kalachakra.makedonation_form',data)
http.route('/kalachakra/payment/token', type='http', auth='public', website=True, sitemap=False)
def payment_token(self, pm_id=None, **kwargs):
""" Method that handles payment using saved tokens
:param int pm_id: id of the payment.token that we want to use to pay.
"""
order = request.website.sale_get_order()
# do not crash if the user has already paid and try to pay again
if not order:
return request.redirect('/shop/?error=no_order')
assert order.partner_id.id != request.website.partner_id.id
try:
pm_id = int(pm_id)
except ValueError:
return request.redirect('/shop/?error=invalid_token_id')
# We retrieve the token the user want to use to pay
if not request.env['payment.token'].sudo().search_count([('id', '=', pm_id)]):
return request.redirect('/shop/?error=token_not_found')
# Create transaction
vals = {'payment_token_id': pm_id, 'return_url': '/shop/payment/validate'}
tx = order._create_payment_transaction(vals)
PaymentProcessing.add_payment_transaction(tx)
return request.redirect('/payment/process')
@http.route(['/kalachakra/payment/process'], type="http", auth="public", website=True, sitemap=False)
def payment_status_page(self, **kwargs):
# When the customer is redirect to this website page,
# we retrieve the payment transaction list from his session
tx_ids_list = self.get_payment_transaction_ids()
payment_transaction_ids = request.env['payment.transaction'].sudo().browse(tx_ids_list).exists()
render_ctx = {
'payment_tx_ids': payment_transaction_ids.ids,
}
return request.render("payment.payment_process_page", render_ctx)
@http.route('/shop/payment/validate', type='http', auth="public", website=True, sitemap=False)
def payment_validate(self, transaction_id=None, sale_order_id=None, **post):
""" Method that should be called by the server when receiving an update
for a transaction. State at this point :
- UDPATE ME
"""
if sale_order_id is None:
order = request.website.sale_get_order()
else:
order = request.env['sale.order'].sudo().browse(sale_order_id)
assert order.id == request.session.get('sale_last_order_id')
if transaction_id:
tx = request.env['payment.transaction'].sudo().browse(transaction_id)
assert tx in order.transaction_ids()
elif order:
tx = order.get_portal_last_transaction()
else:
tx = None
if not order or (order.amount_total and not tx):
return request.redirect('/shop')
if order and not order.amount_total and not tx:
order.with_context(send_email=True).action_confirm()
return request.redirect(order.get_portal_url())
# clean context and session, then redirect to the confirmation page
request.website.sale_reset()
if tx and tx.state == 'draft':
return request.redirect('/shop')
PaymentProcessing.remove_payment_transaction(tx)
return request.redirect('/shop/confirmation')
@http.route(['/shop/confirmation'], type='http', auth="public", website=True, sitemap=False)
def payment_confirmation(self, **post):
""" End of checkout process controller. Confirmation is basically seing
the status of a sale.order. State at this point :
- should not have any context / session info: clean them
- take a sale.order id, because we request a sale.order and are not
session dependant anymore
"""
sale_order_id = request.session.get('sale_last_order_id')
if sale_order_id:
order = request.env['sale.order'].sudo().browse(sale_order_id)
return request.render("website_sale.confirmation", {'order': order})
else:
return request.redirect('/shop')