@ -20,6 +20,8 @@ import time
import sib_api_v3_sdk
from sib_api_v3_sdk.rest import ApiException
from pprint import pprint
import logging
_logger = logging . getLogger ( __name__ )
# IF YOU MODIFY THE SCOPE DELETE THE TOKEN.TXT FILE
@ -104,52 +106,56 @@ class KalachakraEvent(models.Model):
default [ ' stage_id ' ] = stage_new . id
return super ( KalachakraEvent , self ) . copy ( default )
def write ( self , vals ) :
res = super ( KalachakraEvent , self ) . write ( vals )
#mise à jour du calendrier google si
#modification date de début ou date de fin
#modification du nom de l'événement
if self . calendar_event_id :
# def write(self,vals) :
# res = super(KalachakraEvent, self).write(vals )
# #mise à jour du calendrier google si
# #modification date de début ou date de fin
# #modification du nom de l'événement
# # if self.calendar_event_id :
if vals . get ( ' date_begin ' ) or vals . get ( ' date_end ' ) or vals . get ( ' name ' ) :
# # if vals.get('date_begin') or vals.get('date_end') or vals.get('name') :
self . update_event_google_agenda ( )
#s'il existe des événements liés à celui-ci, mise à jour de ceux-ci
#uniquement sur les champs suivants : nom, liste de diffusion, lien zoom, type de participation, lien en savoir plus
child_events = self . env [ ' event.event ' ] . search ( [ ( ' parent_event_id ' , ' = ' , int ( self . id ) ) ] )
if child_events :
# # self.update_event_google_agenda()
# #s'il existe des événements liés à celui-ci, mise à jour de ceux-ci
# #uniquement sur les champs suivants : nom, liste de diffusion, lien zoom, type de participation, lien en savoir plus
# _logger.error('id='+str(int(self.id)))
# if not self.parent_event_id:
for child_event in child_events :
child_event . name = self . name
child_event . event_type_id = self . event_type_id
child_event . recurring_event_newsletter_id = self . recurring_event_newsletter_id
child_event . find_out_more_link = self . find_out_more_link
child_event . auto_confirm = self . auto_confirm
child_event . seats_limited = self . seats_limited
child_event . seats_max = self . seats_max
# child_events=self.env['event.event'].search([('parent_event_id','=', int(self.id))])
child_event . user_id = self . user_id
child_event . address_id = self . address_id
child_event . online_only = self . online_only
child_event . no_online_payment = self . no_online_payment
child_event . online_event = self . online_event
child_event . online_link = self . online_link
child_event . online_id = self . online_id
child_event . online_password = self . online_password
# if child_events:
# #raise Warning(self.event_mail_ids)
# for child_event in child_events:
# child_event.event_mail_ids=self.event_mail_ids
# _logger.error(str(child_event.date_begin)+'='+str(child_event.event_mail_ids))
# child_event.name=self.name
# child_event.event_type_id=self.event_type_id
# child_event.recurring_event_newsletter_id=self.recurring_event_newsletter_id
# child_event.find_out_more_link=self.find_out_more_link
# child_event.auto_confirm=self.auto_confirm
# child_event.seats_limited=self.seats_limited
# child_event.seats_max=self.seats_max
child_event . event_logo = self . event_logo
child_event . cover_properties = self . cover_properties
child_event . tag_ids = self . tag_ids
child_event . description = self . description
child_event . participation_product_id = self . participation_product_id
child_event . participation_standard_price = self . participation_standard_price
child_event . participation_member_price = self . participation_member_price
child_event . participation_super_member_price = self . participation_super_member_price
# child_event.user_id=self.user_id
# child_event.address_id=self.address_id
# child_event.online_only=self.online_only
# child_event.no_online_payment=self.no_online_payment
# child_event.online_event=self.online_event
# child_event.online_link=self.online_link
# child_event.online_id=self.online_id
# child_event.online_password=self.online_password
# child_event.event_logo=self.event_logo
# child_event.cover_properties=self.cover_properties
# child_event.tag_ids=self.tag_ids
# child_event.description=self.description
# child_event.participation_product_id=self.participation_product_id
# child_event.participation_standard_price=self.participation_standard_price
# child_event.participation_member_price=self.participation_member_price
# child_event.participation_super_member_price=self.participation_super_member_price
def _compute_generated_events ( self ) :
@ -158,6 +164,59 @@ class KalachakraEvent(models.Model):
evt = rec . env [ ' event.event ' ] . search ( [ ( ' parent_event_id ' , ' = ' , rec . id ) ] )
if evt : rec . generated_events = True
def update_generated_events ( self ) :
for rec in self :
evt = self . env [ ' event.event ' ] . search ( [ ( ' parent_event_id ' , ' = ' , rec . id ) ] )
if evt :
for child_event in evt :
#suppression des mails
child_event . write ( { ' event_mail_ids ' : [ ( 5 ) ] } )
for mail_id in rec . event_mail_ids :
vals = { }
vals [ " notification_type " ] = mail_id . notification_type
vals [ " template_id " ] = int ( mail_id . template_id )
vals [ " sms_template_id " ] = int ( mail_id . sms_template_id )
vals [ " interval_nbr " ] = mail_id . interval_nbr
vals [ " interval_unit " ] = mail_id . interval_unit
vals [ " interval_type " ] = mail_id . interval_type
vals [ " event_id " ] = int ( child_event . id )
#_logger.error(str(vals))
child_event . write ( { ' event_mail_ids ' : [ ( 0 , 0 , vals ) ] } )
child_event . name = rec . name
#_logger.error(str(child_event.event_mail_ids))
#child_event.event_type_id=rec.event_type_id
child_event . recurring_event_newsletter_id = rec . recurring_event_newsletter_id
child_event . find_out_more_link = rec . find_out_more_link
child_event . auto_confirm = rec . auto_confirm
child_event . seats_limited = rec . seats_limited
child_event . seats_max = rec . seats_max
child_event . user_id = rec . user_id
child_event . address_id = rec . address_id
child_event . online_only = rec . online_only
child_event . no_online_payment = rec . no_online_payment
child_event . online_event = rec . online_event
child_event . online_link = rec . online_link
child_event . online_id = rec . online_id
child_event . online_password = rec . online_password
child_event . event_logo = rec . event_logo
child_event . cover_properties = rec . cover_properties
child_event . tag_ids = rec . tag_ids
child_event . description = rec . description
child_event . participation_product_id = rec . participation_product_id
child_event . participation_standard_price = rec . participation_standard_price
child_event . participation_member_price = rec . participation_member_price
child_event . participation_super_member_price = rec . participation_super_member_price
def remove_generated_events ( self ) :
evt = self . env [ ' event.event ' ] . search ( [ ( ' parent_event_id ' , ' = ' , self . id ) ] )
if evt :
@ -225,7 +284,7 @@ class KalachakraEvent(models.Model):
vals [ ' date_end ' ] = end_date_event
vals [ ' description ' ] = self . description
vals [ ' tag_ids ' ] = self . tag_ids
vals [ ' event_mail_ids ' ] = self . event_mail_ids
vals [ ' event_logo ' ] = self . event_logo
vals [ ' is_published ' ] = True
vals [ ' free_participation ' ] = self . free_participation
@ -245,6 +304,21 @@ class KalachakraEvent(models.Model):
vals [ ' cover_properties ' ] = self . cover_properties
ev = self . env [ ' event.event ' ] . create ( vals )
for mail_id in self . event_mail_ids :
vals = { }
vals [ " notification_type " ] = mail_id . notification_type
vals [ " template_id " ] = int ( mail_id . template_id )
vals [ " sms_template_id " ] = int ( mail_id . sms_template_id )
vals [ " interval_nbr " ] = mail_id . interval_nbr
vals [ " interval_unit " ] = mail_id . interval_unit
vals [ " interval_type " ] = mail_id . interval_type
vals [ " event_id " ] = int ( ev . id )
#_logger.error(str(vals))
ev . write ( { ' event_mail_ids ' : [ ( 0 , 0 , vals ) ] } )
return ev