Apologies for the lack of response, Covid + other business took me off of solving this part of code.
I have added
def travellerages_dob_change(self, **event_args):
self.tf.travellerform_dob.date = self.travellerages_dob.date
pass
to the sub form TravellerAges
But the corresponding date fields in TravellerForm do not update onchange of the travellerages_dob.date.
I dont get any errors, it just doesnt update the TravellerForm date field.
This is the piece of code that handles all the dates, it is in the main Form Quotation. It is correctly picking up the travellerages_dob.date in the code here, as you can see from the console output, but it isnt updating the travellerform_dob.date at all. I put in 2 travellers, one born 21/5/2000 and one born 20/5/2000.
#This code sets up the ages tuple from the age fields
for traveller_ages in self.cp.get_components():
self.ages1.append(traveller_ages.travellerages_dob.date)
print(self.ages1)
for x in self.ages1:
print(x)
born= (x)
print(“Born :”,born)
born = str(born)
born = datetime.strptime(born, “%Y-%m-%d”).strftime(‘%d/%m/%Y’)
print(born)
#Identify given date as date month and year
born = datetime.strptime(born, “%d/%m/%Y”).date()
#Get today's date
today = date.today()
#ageis = 0
print("Age :",
today.year - born.year - ((today.month,
today.day) < (born.month,
born.day)))
ageis = (today.year - born.year - ((today.month,
today.day) < (born.month,
born.day)))
ageis = int(ageis)
print(ageis)
print(type(ageis))
self.ages.append(ageis)
And this is the console output of it:-
[datetime.date(2000, 5, 20)]
2000-05-20
Born : 2000-05-20
20/05/2000
Age : 21
21
<class ‘int’>
[datetime.date(2000, 5, 20), datetime.date(2000, 5, 21)]
2000-05-20
Born : 2000-05-20
20/05/2000
Age : 21
21
<class ‘int’>
2000-05-21
Born : 2000-05-21
21/05/2000
Age : 21
21
<class ‘int’>
Any help would be appreciated