Browse Source

inscription

dev-rcn
root 3 years ago
parent
commit
7b67c5757d
9 changed files with 237 additions and 10 deletions
  1. +3
    -1
      __manifest__.py
  2. +48
    -7
      controllers/kalachakra.py
  3. +32
    -0
      models/event.py
  4. +0
    -1
      models/membership.py
  5. +1
    -1
      models/partner.py
  6. +51
    -0
      views/event.xml
  7. +28
    -0
      views/event_templates_list.xml
  8. +29
    -0
      views/event_templates_page_registration.xml
  9. +45
    -0
      views/website_event_registration.xml

+ 3
- 1
__manifest__.py View File

@ -39,7 +39,9 @@
#'report/report.xml'
'views/event.xml',
'views/event_templates_list.xml',
'views/membership.xml'
'views/membership.xml',
'views/website_event_registration.xml',
'views/event_templates_page_registration.xml'
],
# only loaded in demonstration mode


+ 48
- 7
controllers/kalachakra.py View File

@ -8,8 +8,12 @@ from dateutil.relativedelta import relativedelta
from odoo.exceptions import UserError
from odoo.addons.website_event.controllers.main import WebsiteEventController
from odoo.addons.payment.controllers.portal import PaymentProcessing
from odoo.addons.auth_signup.controllers.main import AuthSignupHome
from odoo.addons.sale.controllers.portal import CustomerPortal
from odoo.addons.portal.controllers.portal import pager as portal_pager, get_records_pager
class kalachakra_event(WebsiteEventController,PaymentProcessing):
class kalachakra_event(WebsiteEventController,PaymentProcessing,AuthSignupHome):
def _extract_searched_event_tags(self, searches):
tags = request.env['event.tag']
@ -41,6 +45,43 @@ class kalachakra_event(WebsiteEventController,PaymentProcessing):
return http.request.redirect('https://www.dropbox.com/s/ijsd6n82oyp0gw8/programme_Paris.pdf?dl=0')
@http.route(['/event/registration/step1'], type='http', auth='user', website=True, sitemap=False,csrf=False)
def event_registration_step1(self,event_id,*args,**kw):
#contact lié à l'utilisateur
userid=request.env.context.get('uid')
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)
#si le pays n'est pas renseigné, on le renseigne avec France
#c'est indispensable pour pouvoir régléer le devis
if not partner.country_id:
country=request.env['res.country'].search([('name','=','France')])
partner.country_id=country.id
data={}
data['partner']=partner
#évenement
request.session['event_id']=int(event_id)
event=request.env['event.event'].sudo().search([('id','=',int(event_id))])
data['event']=event
data['status']=partner.member_status
if data['status']=='not member':data['status']='standard'
#prix
data['price']=''
if data['status']=='standard':data['price']=event.booking_price
if data['status']=='member':data['price']=event.booking_member_price
if data['status']=='super member':data['price']=event.booking_super_member_price
if event.online_event:
return http.request.render('kalachakra.registration_distancial',data)
@http.route(['/kalachakra/makedonation'], type='http', auth='public', website=True, sitemap=False,csrf=False)
def makedonation(self,**post):
data={}
@ -154,12 +195,12 @@ class kalachakra_event(WebsiteEventController,PaymentProcessing):
@http.route(['/kalachakra/payment_choice'], type='http', auth='public', website=True, sitemap=False,csrf=False)
def payment_choice(self,**post):
#gestion du retour page précédente depuis page de paiement
#gestion du retour page précédente depuis page de paiement : on supprime les éléments générés ( don , adhésion)
if not post.get('product_id'):
if request.session['kalachakra_transaction']=='donation':
request.env['donation.donation'].search(['id','=',int(request.session['donation_id'])]).unlink()
request.env['donation.donation'].search([('id','=',int(request.session['donation_id']))]).unlink()
if request.session['kalachakra_transaction']=='membership':
request.env['kalachakra.membership'].search(['id','=',int(request.session['membership_id'])]).unlink()
request.env['kalachakra.membership'].search([('id','=',int(request.session['membership_id']))]).unlink()
return request.redirect('/kalachakra/participation?type='+request.session['kalachakra_transaction'])
@ -191,7 +232,7 @@ class kalachakra_event(WebsiteEventController,PaymentProcessing):
data={}
if request.session['kalachakra_transaction']=='donation':
data['submit_txt']='Donate now'
if request.session['kalachakra_transaction'] in ['membership'] :
if request.session['kalachakra_transaction']=='membership':
data['submit_txt']='Pay now'
data['success_url']='/kalachakra/payment/success'
@ -253,10 +294,12 @@ class kalachakra_event(WebsiteEventController,PaymentProcessing):
#create membership
if request.session['kalachakra_transaction'] in ['membership']:
vals={}
vals['partner_id']=partner.id
vals['product_id']=int(post.get('product_id'))
vals['start_date']=datetime.now()
vals['end_date']=datetime.now()+relativedelta(years=1)
vals['amount']=post.get('amount')
membership=request.env['kalachakra.membership'].sudo().create(vals)
data['order_id']=membership.id
request.session['membership_id'] = membership.id
@ -279,8 +322,6 @@ class kalachakra_event(WebsiteEventController,PaymentProcessing):
# Ensure a payment acquirer is selected
if not acquirer_id:
return False


+ 32
- 0
models/event.py View File

@ -32,6 +32,38 @@ class EventEvent(models.Model):
calendar_id=fields.Char('calendar id')
calendar_event_id=fields.Char('event id')
free_participation=fields.Boolean('Free participation')
participation_product_id=fields.Many2one('product.product',string='participation product')
participation_standard_price=fields.Monetary('Standard Price',currency_field='currency_id')
participation_member_price=fields.Monetary('Member price',currency_field='currency_id')
participation_super_member_price=fields.Monetary('Super member price',currency_field='currency_id')
subscription_product_id=fields.Many2one('product.product',string='subscription product')
subscription_standard_price=fields.Monetary('Standard Price',currency_field='currency_id')
subscription_member_price=fields.Monetary('Member price',currency_field='currency_id')
subscription_super_member_price=fields.Monetary('Super member price',currency_field='currency_id')
recurring_event=fields.Boolean('Recurring event')
recurring_event_newsletter_id=fields.Many2one('mailing.list',string='Recurring event Newsletter')
online_event=fields.Boolean('Online event')
online_link=fields.Char('link')
online_id=fields.Char('id')
online_password=fields.Char('password')
@api.model
def _default_currency(self):
company = self.env['res.company']._company_default_get(
'event.event')
return company.currency_id
currency_id = fields.Many2one(
'res.currency',
string='Currency',
required=True,
track_visibility='onchange',
ondelete='restrict',
default=_default_currency
)
def add_event_to_google_agenda(self):


+ 0
- 1
models/membership.py View File

@ -37,7 +37,6 @@ class kalachakra_membership(models.Model):
amount = fields.Monetary(
string="Amount",
currency_field="currency_id",
readonly=True,
tracking=True,
)


+ 1
- 1
models/partner.py View File

@ -63,7 +63,7 @@ class partner(models.Model):
def _compute_member_status(self):
for rec in self:
member=rec.env['kalachakra.membership'].search([('partner_id','=',rec.id),('end_date','<=',datetime.now())])
member=rec.env['kalachakra.membership'].search([('partner_id','=',rec.id),('end_date','>=',datetime.now()),('state','=','done')])
if member : rec.member_status='member'
else :rec.member_status='not member'
if rec.super_member: rec.member_status='super member'


+ 51
- 0
views/event.xml View File

@ -25,6 +25,57 @@
<button name="remove_event_to_google_agenda" attrs="{'invisible':[('calendar_event_id','=',False)]}" type="object" string="Remove event from google agenda" class="btn btn-danger"/>
<field name="calendar_event_id" invisible="1"/>
</xpath>
<xpath expr="//field[@name='tag_ids']" position="after">
<field name="online_event"/>
<field name="free_participation"/>
<field name="recurring_event"/>
<field name="recurring_event_newsletter_id" attrs="{'invisible':[('recurring_event','=',False)]}"/>
</xpath>
<xpath expr="//page[@name='event_communication']" position="before">
<page string="Participations" name="Participations" attrs="{'invisible':[('free_participation','=',True)]}">
<group style="width:40%%">
<field name="participation_product_id" attrs="{'required': [('free_participation','=', False)]}"/>
<field name="participation_standard_price" attrs="{'required': [('free_participation','=', False)]}"/>
<field name="participation_member_price" attrs="{'required': [('free_participation','=', False)]}"/>
<field name="participation_super_member_price" attrs="{'required': [('free_participation','=', False)]}"/>
</group>
</page>
</xpath>
<xpath expr="//page[@name='Participations']" position="after">
<page string="Subscriptions" name="Subscriptions" attrs="{'invisible':[('recurring_event','=',False)]}">
<group style="width:40%%">
<field name="subscription_product_id" attrs="{'required': [('recurring_event','=', False)]}"/>
<field name="subscription_standard_price" attrs="{'required': [('recurring_event','=', False)]}"/>
<field name="subscription_member_price" attrs="{'required': [('recurring_event','=', False)]}"/>
<field name="subscription_super_member_price" attrs="{'required': [('recurring_event','=', False)]}"/>
</group>
</page>
</xpath>
<xpath expr="//page[@name='Subscriptions']" position="after">
<page string="Online options" name="Online" attrs="{'invisible':[('online_event','=',False)]}">
<group style="width:80%%">
<field name="online_link" attrs="{'required': [('online_event','=', True)]}"/>
<field name="online_id"/>
<field name="online_password" attrs="{'required': [('online_event','=', True)]}"/>
</group>
</page>
</xpath>
</field>
</record>


+ 28
- 0
views/event_templates_list.xml View File

@ -47,5 +47,33 @@
</xpath>
</template>
<template id="kalachakra.events_list" inherit_id="website_event.events_list">
<xpath expr="//time[@itemprop='startDate']" position="after">
<t t-if="not event.free_participation">
<time itemprop="endDate" t-att-datetime="event.date_end">
<span t-field="event.with_context(tz=event.date_tz).date_end" t-options="{'date_only': 'true', 'format': 'long'}"/>
</time>
<br/>
<h7><font style="color: rgb(255, 0, 0)">Not member : <span t-esc="int(event.participation_standard_price)"/></font></h7>
<h7><font style="color: rgb(255, 0, 0)"> Member : <span t-esc="int(event.participation_member_price)"/></font></h7>
<h7><font style="color: rgb(255, 0, 0);">Super member : <span t-esc="int(event.participation_super_member_price)"/></font></h7>
</t>
<t t-if="event.free_participation">
<time itemprop="endDate" t-att-datetime="event.date_end">
<span t-field="event.with_context(tz=event.date_tz).date_end" t-options="{'date_only': 'true', 'format': 'long'}"/>
</time>
<br/>
<h7><b><font style="color: rgb(255, 0, 0)">Free participation</font></b></h7>
</t>
</xpath>
</template>
</data>
</odoo>

+ 29
- 0
views/event_templates_page_registration.xml View File

@ -0,0 +1,29 @@
<odoo>
<template id="kalachakra.event_registration_template" inherit_id="website_event.registration_template">
<xpath expr="//div[@class='col-lg-4 pt-3 pt-lg-0 pl-2 pl-lg-0']" position="replace">
<t t-if="not event.booking_event">
<div class="col-lg-4 pt-3 pt-lg-0 pl-2 pl-lg-0">
<a t-attf-id="#{event.id}" t-attf-href="/event/registration/step1?event_id={{event.id}}" class="btn btn-primary btn-block" data-original-title="" title="" aria-describedby="tooltip34075">Register</a>
</div>
<t t-if="event.seats_limited and event.seats_max and event.seats_available &lt;= (event.seats_max * 0.2)">
(only <t t-esc="event.seats_available"/> available)
</t>
</t>
</xpath>
<!-- on bloque la qte à 1 -->
<xpath expr="//select[@class='w-auto custom-select']" position="replace">
<select t-att-name="'nb_register-%s' % (tickets.id if tickets else 0)" class="w-auto custom-select">
<t t-set="seats_max_ticket" t-value="(not tickets or not tickets.seats_limited or tickets.seats_available &gt; 9) and 10 or tickets.seats_available + 1"/>
<t t-set="seats_max_event" t-value="(not event.seats_limited or event.seats_available &gt; 9) and 10 or event.seats_available + 1"/>
<t t-set="seats_max" t-value="min(seats_max_ticket, seats_max_event) if tickets else seats_max_event"/>
<option t-esc="1"/>
</select>
</xpath>
</template>
</odoo>

+ 45
- 0
views/website_event_registration.xml View File

@ -0,0 +1,45 @@
<odoo>
<template id="kalachakra.registration_distancial" name="Distancial Event Form">
<t t-call="website.layout">
<div class="container-fluid">
<div class="form-group s_website_form_field col-12 s_website_form_custom " data-type="selection" data-name="Field">
<div class="row s_col_no_resize s_col_no_bgcolor">
<label class=" col-sm-auto s_website_form_label " style="width: 200px" for="2bp1hybvcoe">
<span class="s_website_form_label_content"></span>
</label>
<div class="col-sm">
<div class="row s_col_no_resize s_col_no_bgcolor s_website_form_multiple" data-display="vertical">
<div class="radio col-12">
<div class="form-check">
<input type="radio" class="s_website_form_input form-check-input" id="2bp1hybvcoe0" name="Custom Bouton radio" value="Option 1"/>
<label class="form-check-label s_website_form_check_label" for="2bp1hybvcoe0">
Je participerai au centre Kalachakra
</label>
</div>
</div>
<div class="radio col-12">
<div class="form-check">
<input type="radio" class="s_website_form_input form-check-input" id="2bp1hybvcoe1" name="Custom Bouton radio" value="Option 2"/>
<label class="form-check-label s_website_form_check_label" for="2bp1hybvcoe1">
Je participerai sur Zoom
</label>
</div>
</div>
<div class="radio col-12">
<div class="form-check">
<input type="radio" class="s_website_form_input form-check-input" id="2bp1hybvcoe2" name="Custom Bouton radio" value="Option 3"/>
<label class="form-check-label s_website_form_check_label" for="2bp1hybvcoe2">
Je choisirai plus tard
</label>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</t>
</template>
</odoo>

Loading…
Cancel
Save