diff --git a/controllers/kalachakra.py b/controllers/kalachakra.py
index b938c27..c6d922b 100755
--- a/controllers/kalachakra.py
+++ b/controllers/kalachakra.py
@@ -157,6 +157,26 @@ class KalaAuthSignupHome(Home):
class kalachakra_event(WebsiteEventController,PaymentProcessing):
+ #afficher la liste des prochains événement sur la home page (sans les retraites ! )
+ @http.route('/event/csv_booking_registrants', website=False, auth='user',methods=['GET'])
+ def export_csv_booking_registrants(self,id,*args,**kw):
+ data=request.env['event.event'].sudo().generate_csv_booking_registrants(id)
+
+
+ #csv = str.encode('Nom & Prénom;Rôle;Options;Montant retraite;Adhésion;Autre options;Montant à payer;Statut commande;Type de paiement;Règlement\n', 'utf-8')
+ #csv =csv+ str.encode('1;2\n', 'utf-8')
+ filename = 'Events - {}.csv'.format(
+ datetime.now().strftime("%m/%d/%Y"))
+
+ headers = [
+ ('Content-Type', 'application/octet-stream'),
+ ('Content-Disposition', 'attachment; filename="%s"' % (filename))
+ ]
+
+ return request.make_response(data, headers=headers)
+
+
+
#afficher la liste des prochains événement sur la home page (sans les retraites ! )
@http.route('/event/get_country_booking_event_list', type='json', auth='public', website=True)
def get_country_booking_events(self, **post):
diff --git a/models/booking_event.py b/models/booking_event.py
index bc6516a..daa927b 100755
--- a/models/booking_event.py
+++ b/models/booking_event.py
@@ -86,6 +86,8 @@ class BookingEvent(models.Model):
)
+
+
@api.onchange('questionnaire_id')
def onchange_questionnaire(self):
@@ -103,8 +105,119 @@ class BookingEvent(models.Model):
self.question_ids = [(0, 0, vals)]
+
+ def csv_booking_registrants(self):
+ act={ 'type': 'ir.actions.act_url',
+ 'url': '/event/csv_booking_registrants?id=%s' % (self.id),
+ 'target': 'self','res_id': self.id}
+ return act
+ def generate_csv_booking_registrants(self,id):
+ booking=self.env['event.event'].search([('id','=',int(id))])
+
+ header_ligne='Nom & Prénom;Rôle;Options;Montant retraite;Adhésion;Autre options;Montant à payer;Statut commande;Type de paiement;Règlement\n'
+ csv_lines=''
+ for reg in booking.registration_ids:
+ name=str(reg.name)
+ role=str(self._compute_member_status(reg))
+ options=str(self._compute_invoice_options(reg))
+ booking_amount=str(self._compute_booking_amount(reg))
+ membership_amount=str(self._compute_membership_amount(reg))
+ csv_lines=csv_lines+name+';'+role+';'+options+';'+booking_amount+';'+membership_amount+'\n'
+
+ return str.encode(header_ligne+csv_lines,'utf-8')
+
+ def _compute_booking_amount(self,rec):
+ membership_product=self.env['product.product'].sudo().search([('membership_product','=',True)],limit=1)
+
+ #si facture sans acompte:
+ booking_amount=0
+ i=1
+ if rec.invoice_id:
+ for line in rec.invoice_id.invoice_line_ids:
+ booking_amount=line.price_subtotal
+ break
+
+
+ #si facture avec acompte:
+
+ if rec.down_payment_invoice_id:
+ for line in rec.down_payment_invoice_id.invoice_line_ids:
+ if line.name==membership_product.name:
+ booking_amount=rec.booking_amount+line.price_subtotal
+ break
+ return booking_amount
+ def _compute_member_status(self,reg):
+
+ if reg.partner_id.email==reg.email:
+ status=reg.partner_id.member_status
+ #le participant n'est pas la personne qui s'est connecté
+
+ else:
+ participant=self.env['res.partner'].sudo().search([('email','=',reg.email)],limit=1)
+ if participant:
+ status=participant.member_status
+ else:
+ status='not member'
+ return status
+
+ def _compute_membership_amount(self,rec):
+ membership_product=self.env['product.product'].sudo().search([('membership_product','=',True)],limit=1)
+
+ #si facture sans acompte:
+ membership_amount=0
+
+ if rec.invoice_id:
+ for line in rec.invoice_id.invoice_line_ids:
+ if line.name==membership_product.name:
+ membership_amount=line.price_subtotal
+
+
+ #si facture avec acompte:
+
+ if rec.balance_invoice_id:
+ for line in rec.balance_invoice_id.invoice_line_ids:
+ if line.name==membership_product.name:
+ membership_amount=line.price_subtotal
+
+ return membership_amount
+
+
+ def _compute_invoice_options(self,rec):
+ membership_product=self.env['product.product'].sudo().search([('membership_product','=',True)],limit=1)
+
+ invoice_options=''
+
+ #si facture sans acompte:
+ i=1
+
+ if rec.invoice_id:
+ for line in rec.invoice_id.invoice_line_ids:
+ if i>1:
+ if line.name!=membership_product.name:
+ invoice_options=invoice_options+str(line.name)+'('+str(line.price_subtotal)+' €)- '
+
+ i=i+1
+ #si facture avec acompte:
+ i=1
+
+ if rec.balance_invoice_id:
+ for line in rec.balance_invoice_id.invoice_line_ids:
+ if i>1:
+ if line.name!=membership_product.name:
+ invoice_options=invoice_options+str(line.name)+'('+str(line.price_subtotal)+' €)- '
+
+ i=i+1
+ i=1
+ if rec.end_of_stay_invoice_id:
+ for line in rec.end_of_stay_invoice_id.invoice_line_ids:
+ if i>1:
+ if line.name!=membership_product.name:
+ invoice_options=invoice_options+str(line.name)+'('+str(line.price_subtotal)+' €)- '
+
+ i=i+1
+ return invoice_options
# booking_option_ids=fields.One2many('booking.option','event_id','booking options')
# @api.model
diff --git a/models/booking_event_registration.py b/models/booking_event_registration.py
index 74a9e7e..2c3e1fd 100755
--- a/models/booking_event_registration.py
+++ b/models/booking_event_registration.py
@@ -102,7 +102,87 @@ class EventRegistration(models.Model):
individual_room=fields.Boolean('Individual room',compute='compute_individual_room')
start_day_individual_booking=fields.Date('Start day individual booking')
end_day_individual_booking=fields.Date('End day individual booking')
+
+ #pour rapport
+ # member_status=fields.Char('member status', compute='_compute_member_status')
+ # invoice_options_amount=fields.Float('invoice options amount',compute='_compute_invoice_options_amount')
+ # membership_amount=fields.Float('membership amount',compute='_compute_membership_amount')
+ # booking_amount=fields.Float('booking amount',compute='_compute_booking_amount')
+ # amount_to_be_paid=fields.Float('booking amount to be paid',compute='_compute_amount_to_be_paid')
+ # amount_paid=fields.Float('booking amount paid',compute='_compute_amount_paid')
+ # invoice_options=fields.Char('invoice options',compute='_compute_invoice_options')
+ # payment_mode=fields.Char('invoice options',compute='_compute_payment_mode')
+
+ def _compute_payment_mode(self):
+ for rec in self:
+ rec.payment_mode=''
+ if rec.invoice_id:
+ rec.payment_mode=rec.invoice_id.payment_mode_id.name
+ if rec.down_payment_invoice_id:
+ rec.payment_mode=rec.down_payment_invoice_id.payment_mode_id.name
+
+ def _compute_amount_paid(self):
+ for rec in self:
+ rec.amount_paid=0
+ if rec.invoice_id:
+ rec.amount_paid=rec.invoice_id.amount_total-rec.invoice_id.amount_residual
+ if rec.down_payment_invoice_id:
+ rec.amount_paid=rec.amount_paid+rec.down_payment_invoice_id.amount_total-rec.down_payment_invoice_id.amount_residual
+ if rec.balance_invoice_id:
+ rec.amount_paid=rec.amount_paid+rec.balance_invoice_id.amount_total-rec.balance_invoice_id.amount_residual
+ if rec.end_of_stay_invoice_id:
+ rec.amount_paid=rec.amount_paid+rec.end_of_stay_invoice_id.amount_total-rec.end_of_stay_invoice_id.amount_residual
+
+ def _compute_amount_to_be_paid(self):
+ for rec in self:
+ rec.amount_to_be_paid=0
+ if rec.invoice_id:
+ rec.amount_to_be_paid=rec.invoice_id.amount_residual
+ if rec.down_payment_invoice_id:
+ rec.amount_to_be_paid=rec.amount_to_be_paid+rec.down_payment_invoice_id.amount_residual
+ if rec.balance_invoice_id:
+ rec.amount_to_be_paid=rec.amount_to_be_paid+rec.balance_invoice_id.amount_residual
+ if rec.end_of_stay_invoice_id:
+ rec.amount_to_be_paid=rec.amount_to_be_paid+rec.end_of_stay_invoice_id.amount_residual
+
+
+
+
+ def _compute_invoice_options_amount(self):
+ membership_product=self.env['product.product'].sudo().search([('membership_product','=',True)],limit=1)
+ for rec in self:
+ rec.invoice_options_amount=0
+ #si facture sans acompte:
+ i=1
+
+ if rec.invoice_id:
+
+ for line in rec.invoice_id.invoice_line_ids:
+ if i>1:
+ if line.name!=membership_product.name:
+ rec.invoice_options_amount=rec.invoice_options_amount+line.price_subtotal
+ i=i+1
+ #si facture avec acompte:
+ i=1
+
+ if rec.balance_invoice_id:
+
+ for line in rec.balance_invoice_id.invoice_line_ids:
+ if i>1:
+ if line.name!=membership_product.name:
+ rec.invoice_options_amount=rec.invoice_options_amount+line.price_subtotal
+ i=i+1
+ i=1
+ if rec.end_of_stay_invoice_id:
+ for line in rec.end_of_stay_invoice_id.invoice_line_ids:
+ if i>1:
+ if line.name!=membership_product.name:
+ rec.invoice_options_amount=rec.invoice_options_amount+line.price_subtotal
+
+ i=i+1
+
+
def compute_individual_room(self):
for rec in self:
@@ -539,7 +619,7 @@ class EventRegistration(models.Model):
invoice.state='posted'
invoice.name='REC'+str(invoice.id)
invoice.payment_reference=invoice.name
- user=self.env['res.users'].search([('email','ilike',reg.partner_id.email)])
+ user=self.env['res.users'].search([('email','ilike',reg.partner_id.email)],limit=1)
invoice.invoice_user_id=user.id
invoice.user_id=user.id
@@ -595,7 +675,7 @@ class EventRegistration(models.Model):
invoice.state='posted'
invoice.name='REC'+str(invoice.id)
invoice.payment_reference=invoice.name
- user=self.env['res.users'].search([('email','ilike',reg.partner_id.email)])
+ user=self.env['res.users'].search([('email','ilike',reg.partner_id.email)],limit=1)
invoice.invoice_user_id=user.id
invoice.user_id=user.id
diff --git a/views/booking_event.xml b/views/booking_event.xml
index 69a369c..b306948 100755
--- a/views/booking_event.xml
+++ b/views/booking_event.xml
@@ -160,6 +160,10 @@
+
+
+
diff --git a/views/booking_event_registration.xml b/views/booking_event_registration.xml
index bac1e74..baa0810 100755
--- a/views/booking_event_registration.xml
+++ b/views/booking_event_registration.xml
@@ -70,6 +70,7 @@
+
@@ -235,6 +236,15 @@
+
+
+
+
diff --git a/views/event.xml b/views/event.xml
index 7210337..acadf17 100755
--- a/views/event.xml
+++ b/views/event.xml
@@ -191,8 +191,7 @@
-
+