diff --git a/__manifest__.py b/__manifest__.py index 7cc89aa..671f0d2 100644 --- a/__manifest__.py +++ b/__manifest__.py @@ -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 diff --git a/controllers/kalachakra.py b/controllers/kalachakra.py index 546117c..64786f2 100644 --- a/controllers/kalachakra.py +++ b/controllers/kalachakra.py @@ -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 diff --git a/models/event.py b/models/event.py index 8baee90..4c0a448 100644 --- a/models/event.py +++ b/models/event.py @@ -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): diff --git a/models/membership.py b/models/membership.py index 6b549a4..60d55c0 100644 --- a/models/membership.py +++ b/models/membership.py @@ -37,7 +37,6 @@ class kalachakra_membership(models.Model): amount = fields.Monetary( string="Amount", currency_field="currency_id", - readonly=True, tracking=True, ) diff --git a/models/partner.py b/models/partner.py index 3d1ebd6..cac1987 100644 --- a/models/partner.py +++ b/models/partner.py @@ -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' diff --git a/views/event.xml b/views/event.xml index 4f8d370..14a5994 100644 --- a/views/event.xml +++ b/views/event.xml @@ -25,6 +25,57 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/views/event_templates_list.xml b/views/event_templates_list.xml index 10c63d5..386912b 100644 --- a/views/event_templates_list.xml +++ b/views/event_templates_list.xml @@ -47,5 +47,33 @@ + + + + + + + + + + + Not member : € + Member : € + Super member : € + + + + + + + + Free participation + + + + + + + \ No newline at end of file diff --git a/views/event_templates_page_registration.xml b/views/event_templates_page_registration.xml new file mode 100644 index 0000000..991c45c --- /dev/null +++ b/views/event_templates_page_registration.xml @@ -0,0 +1,29 @@ + + + + + + +Register + + + (only available) + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/views/website_event_registration.xml b/views/website_event_registration.xml new file mode 100644 index 0000000..8e59b1d --- /dev/null +++ b/views/website_event_registration.xml @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + Je participerai au centre Kalachakra + + + + + + + + Je participerai sur Zoom + + + + + + + + Je choisirai plus tard + + + + + + + + + + + \ No newline at end of file