@ -421,6 +421,25 @@ class KalachakraEvent(models.Model):
)
teaching_html_content_records = fields . Html ( ' teaching content records ' )
def add_registration_to_mailing_list ( self ) :
registrants = self . env [ ' event.registration ' ] . search ( [ ( ' event_id ' , ' = ' , int ( self . id ) ) ] )
if registrants :
for reg in registrants :
if reg . event_id . recurring_event_newsletter_id :
mailing_contact = self . env [ ' mailing.contact ' ] . sudo ( ) . search ( [ ( ' email ' , ' = ' , reg . partner_id . email ) ] , limit = 1 )
#si le contact n'existe pas comme mailing contact, création
if not mailing_contact :
vals = { }
vals [ ' email ' ] = reg . partner_id . email
vals [ ' name ' ] = reg . partner_id . name
vals [ ' title_id ' ] = int ( reg . partner_id . title )
vals [ ' country_id ' ] = int ( reg . partner_id . country_id )
vals [ ' list_ids ' ] = [ ( 4 , int ( reg . event_id . recurring_event_newsletter_id ) ) ]
mailing_contact = self . env [ ' mailing.contact ' ] . sudo ( ) . create ( vals )
else :
#si le contact existe, si la liste de diffusion n'est pas lié au contact, on l'ajoute
if not reg . event_id . recurring_event_newsletter_id in mailing_contact . list_ids :
mailing_contact . sudo ( ) . write ( { ' list_ids ' : [ ( 4 , int ( reg . event_id . recurring_event_newsletter_id ) ) ] } )
def add_event_to_google_agenda ( self ) :