|
|
@ -212,6 +212,11 @@ class kalachakra_event(WebsiteEventController,PaymentProcessing): |
|
|
|
if data['status']=='member':data['participation_amount']=int(event.participation_member_price) |
|
|
|
if data['status']=='super member':data['participation_amount']=int(event.participation_super_member_price) |
|
|
|
|
|
|
|
membership_product=request.env['product.product'].sudo().search([('membership_product','=',True)],limit=1) |
|
|
|
if not membership_product: raise UserError(_('No membership product, please add one')) |
|
|
|
data['membership_amount']=membership_product.list_price |
|
|
|
data['membership_and_participation_amount']=data['membership_amount']+data['participation_amount'] |
|
|
|
|
|
|
|
#enregistrement de l'inscription si pas déjà inscrit : |
|
|
|
res=request.env['event.registration'].sudo().search([('event_id','=',int(request.session['event_id'])),('partner_id','=',int(request.session['partner_id']))],limit=1) |
|
|
|
data['already_registered']=True |
|
|
@ -227,7 +232,8 @@ class kalachakra_event(WebsiteEventController,PaymentProcessing): |
|
|
|
|
|
|
|
res=request.env['event.registration'].sudo().create(vals) |
|
|
|
#création de la facture à régler |
|
|
|
invoice_id=request.env['event.registration'].sudo().action_generate_participation_invoice(int(res.id),'CB') |
|
|
|
membership=False |
|
|
|
invoice_id=request.env['event.registration'].sudo().action_generate_participation_invoice(int(res.id),'CB',membership) |
|
|
|
|
|
|
|
request.session['res_id']=res.id |
|
|
|
|
|
|
@ -266,18 +272,50 @@ class kalachakra_event(WebsiteEventController,PaymentProcessing): |
|
|
|
|
|
|
|
return http.request.render('kalachakra.onthespotpayment') |
|
|
|
|
|
|
|
@http.route(['/kalachakra/participation'], type='http', auth='user', website=True, sitemap=False,csrf=False) |
|
|
|
@http.route(['/kalachakra/participation'], type='http', auth='public', website=True, sitemap=False,csrf=False) |
|
|
|
def participation(self,type=None,**post): |
|
|
|
data={} |
|
|
|
request.session['kalachakra_transaction']='' |
|
|
|
|
|
|
|
if type=='participation': |
|
|
|
#event=request.env['event.event'].search([('id','=',request.session['event_id'])]) |
|
|
|
res=request.env['event.registration'].sudo().search([('id','=',request.session['res_id'])]) |
|
|
|
invoice_id=res.invoice_id |
|
|
|
invoice=request.env['account.move'].sudo().search([('id','=',int(invoice_id))]).unlink() |
|
|
|
invoice.state='posted' |
|
|
|
#redirection sur la page de paiement de la facture : |
|
|
|
url="/my/invoices/"+str(int(res.invoice_id)) |
|
|
|
return request.redirect(url) |
|
|
|
|
|
|
|
if type=='membership_and_participation': |
|
|
|
res=request.env['event.registration'].sudo().search([('id','=',request.session['res_id'])]) |
|
|
|
#suppression de la facture sans adhésion |
|
|
|
invoice_id=res.invoice_id |
|
|
|
res.invoice_id=False |
|
|
|
request.env['account.move'].sudo().search([('id','=',int(invoice_id))]).unlink() |
|
|
|
|
|
|
|
#creation de la facture avec adhésion |
|
|
|
membership=True |
|
|
|
invoice_id=request.env['event.registration'].sudo().action_generate_participation_invoice(int(res.id),'CB',membership) |
|
|
|
invoice=request.env['account.move'].sudo().search([('id','=',int(invoice_id))]) |
|
|
|
res.invoice_id=invoice.id |
|
|
|
res.with_membership=True |
|
|
|
invoice.state='posted' |
|
|
|
|
|
|
|
#création de l'adhésion à régler |
|
|
|
#ajout de l'adhésion |
|
|
|
membership_product=request.env['product.product'].sudo().search([('membership_product','=',True)],limit=1) |
|
|
|
if not membership_product: raise UserError(_('No membership product, please add one')) |
|
|
|
vals={} |
|
|
|
vals['invoice_id']=int(invoice.id) |
|
|
|
vals['partner_id']=int(res.partner_id) |
|
|
|
vals['product_id']=int(membership_product.id) |
|
|
|
vals['start_date']=datetime.now() |
|
|
|
vals['end_date']=datetime.now()+relativedelta(years=1) |
|
|
|
vals['amount']=membership_product.list_price |
|
|
|
membership=request.env['kalachakra.membership'].sudo().create(vals) |
|
|
|
|
|
|
|
#redirection sur la page de paiement de la facture : |
|
|
|
url="/my/invoices/"+str(int(res.invoice_id))#+"?access_token="+str(invoice.access_token) |
|
|
|
url="/my/invoices/"+str(int(res.invoice_id)) |
|
|
|
return request.redirect(url) |
|
|
|
|
|
|
|
|
|
|
@ -398,9 +436,23 @@ class kalachakra_event(WebsiteEventController,PaymentProcessing): |
|
|
|
vals['country_id']=int(post.get('country_id')) |
|
|
|
vals['phone']=post.get('phone') |
|
|
|
partner=request.env['res.partner'].sudo().create(vals) |
|
|
|
#création du compte utilisateur |
|
|
|
user=request.env['res.users'].sudo().search([('email','=',partner.email)]) |
|
|
|
group_portal=request.env.ref('base.group_portal') |
|
|
|
if not user: |
|
|
|
request.env['res.users'].sudo().create({ |
|
|
|
'name': partner.name, |
|
|
|
'login': partner.email, |
|
|
|
'email': partner.email, |
|
|
|
'partner_id':partner.id, |
|
|
|
'groups_id': [(4, group_portal.id)] |
|
|
|
}) |
|
|
|
user.sudo().action_reset_password() |
|
|
|
|
|
|
|
#si le contact existe : |
|
|
|
#on met à jour ses informations |
|
|
|
else: |
|
|
|
|
|
|
|
vals={} |
|
|
|
|
|
|
|
vals['name']=post.get('name') |
|
|
@ -412,6 +464,19 @@ class kalachakra_event(WebsiteEventController,PaymentProcessing): |
|
|
|
vals['country_id']=int(post.get('country_id')) |
|
|
|
vals['phone']=post.get('phone') |
|
|
|
partner.sudo().write(vals) |
|
|
|
user=request.env['res.users'].sudo().search([('email','=',partner.email)]) |
|
|
|
group_portal=request.env.ref('base.group_portal') |
|
|
|
#création du compte utilisateur |
|
|
|
if not user: |
|
|
|
request.env['res.users'].sudo().create({ |
|
|
|
'name': partner.name, |
|
|
|
'login': partner.email, |
|
|
|
'email': partner.email, |
|
|
|
'partner_id':partner.id, |
|
|
|
'groups_id': [(4, group_portal.id)] |
|
|
|
}) |
|
|
|
user.sudo().action_reset_password() |
|
|
|
|
|
|
|
#on vérifie qu'il n'est pas déjà adhérent si demande d'adhésion |
|
|
|
if partner.member_status in ('member','super member') and request.session['kalachakra_transaction']=='membership': |
|
|
|
data={} |
|
|
|