@ -71,6 +71,7 @@ class KalachakraEvent(models.Model):
find_out_more_link = fields . Char ( ' Find out more link ' )
city = fields . Char ( ' city ' , related = " address_id.city " )
no_online_payment = fields . Boolean ( ' no online payment ' )
no_onthespot_payment = fields . Boolean ( ' no on the spot payment ' )
@api.depends ( ' seats_unconfirmed ' , ' seats_reserved ' , ' seats_used ' )
def _compute_seats_expected ( self ) :
@ -145,21 +146,12 @@ class KalachakraEvent(models.Model):
child_event . cover_properties = self . cover_properties
child_event . tag_ids = self . tag_ids
child_event . description = self . description
#child_event.is_published=self.is_published
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.event_mail_ids=self.event_mail_ids
def _compute_generated_events ( self ) :
for rec in self :
rec . generated_events = False
@ -193,73 +185,67 @@ class KalachakraEvent(models.Model):
def generate_events ( self ) :
for rec in self :
if rec . duration > 1 : raise Warning ( ' action cancelled: the duration f the event is more than 1 days ! ' )
if self . duration > 1 : raise Warning ( ' action cancelled: the duration f the event is more than 1 days ! ' )
if rec . end_generation_date < datetime . now ( ) : raise Warning ( ' action cancelled: the end generation date must be in the future ! ' )
delta = rec . end_generation_date - rec . date_begin
if self . end_generation_date < datetime . now ( ) : raise Warning ( ' action cancelled: the end generation date must be in the future ! ' )
delta = self . end_generation_date - self . date_begin
if delta . days > 200 : raise Warning ( ' action cancelled: the duration f the event is more than 6 months ! ' )
if rec . frequency == ' daily ' : d = 1
if self . frequency == ' daily ' : d = 1
if rec . frequency == ' weekly ' : d = 7
if self . frequency == ' weekly ' : d = 7
start_date_event = rec . date_begin + timedelta ( days = d )
end_date_event = rec . date_end + timedelta ( days = d )
while start_date_event < = rec . end_generation_date :
start_date_event = self . date_begin + timedelta ( days = d )
end_date_event = self . date_end + timedelta ( days = d )
i = 1
while start_date_event < = self . end_generation_date :
if not start_date_event . weekday ( ) in ( 5 , 6 ) :
#avant de dupliquer l'événement on regarde si celui-ci n'a pas déjà été crée !
evt = self . env [ ' event.event ' ] . search ( [ ( ' date_begin ' , ' = ' , start_date_event ) , ( ' parent_event_id ' , ' = ' , int ( self . id ) ) ] )
if evt : raise Warning ( ' action cancelled: event already generated with this date : ' + str ( start_date_event ) )
dup = self . _create_event ( rec , start_date_event , end_date_event )
dup = self . _create_event ( start_date_event , end_date_event )
dup . add_event_to_google_agenda ( )
end_date_event = end_date_event + timedelta ( days = d )
start_date_event = start_date_event + timedelta ( days = d )
i = i + 1
def _create_event ( self , rec , start_date_event , end_date_event ) :
def _create_event ( self , start_date_event , end_date_event ) :
vals = { }
vals [ ' name ' ] = rec . name
vals [ ' name ' ] = self . name
vals [ ' date_begin ' ] = start_date_event
vals [ ' date_end ' ] = end_date_event
vals [ ' description ' ] = rec . description
vals [ ' tag_ids ' ] = rec . tag_ids
vals [ ' event_mail_ids ' ] = rec . event_mail_ids
vals [ ' event_logo ' ] = rec . event_logo
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 ' ] = rec . free_participation
vals [ ' participation_product_id ' ] = int ( rec . participation_product_id )
vals [ ' participation_standard_price ' ] = rec . participation_standard_price
vals [ ' participation_member_price ' ] = rec . participation_member_price
vals [ ' participation_super_member_price ' ] = rec . participation_super_member_price
vals [ ' subscription_product_id ' ] = int ( rec . subscription_product_id )
# vals['subscription_standard_price']=rec.subscription_standard_price
# vals['subscription_member_price']=rec.subscription_member_price
# vals['subscription_super_member_price']=rec.subscription_super_member_price
vals [ ' recurring_event ' ] = rec . recurring_event
vals [ ' recurring_event_newsletter_id ' ] = int ( rec . recurring_event_newsletter_id )
vals [ ' online_event ' ] = rec . online_event
vals [ ' online_link ' ] = rec . online_link
vals [ ' online_id ' ] = rec . online_id
vals [ ' no_online_payment ' ] = rec . no_online_payment
vals [ ' online_password ' ] = rec . online_password
vals [ ' parent_event_id ' ] = int ( rec . id )
vals [ ' cover_properties ' ] = rec . cover_properties
vals [ ' free_participation ' ] = self . free_participation
vals [ ' participation_product_id ' ] = int ( self . participation_product_id )
vals [ ' participation_standard_price ' ] = self . participation_standard_price
vals [ ' participation_member_price ' ] = self . participation_member_price
vals [ ' participation_super_member_price ' ] = self . participation_super_member_price
vals [ ' subscription_product_id ' ] = int ( self . subscription_product_id )
vals [ ' recurring_event ' ] = self . recurring_event
vals [ ' recurring_event_newsletter_id ' ] = int ( self . recurring_event_newsletter_id )
vals [ ' online_event ' ] = self . online_event
vals [ ' online_link ' ] = self . online_link
vals [ ' online_id ' ] = self . online_id
vals [ ' no_online_payment ' ] = self . no_online_payment
vals [ ' online_password ' ] = self . online_password
vals [ ' parent_event_id ' ] = int ( self . id )
vals [ ' cover_properties ' ] = self . cover_properties
ev = self . env [ ' event.event ' ] . create ( vals )
return ev
def _compute_duration ( self ) :