Good day all,
I am trying a script to automatically load all the academic terms in a child table once an academic year has been chosen.
Here is my script.
class SchoolCalendar(Document):
def __setup__(self):
self.onload()
def onload(self):
self.load_terms()
def load_terms(self):
self.terms = []
terms = frappe.get_all("Academic Term", filters = {"academic_year": self.academic_year}, fields=["name as term", "term_start_date as start", "term_end_date as end"])
for term in terms:
self.append("terms", {
"term": term.term, "start": term.start, "end": term.end, "length": 12
})
def validate(self):
self.terms = []
And I get an error at the frappe.get_all() lines. The self.academic_year is the tripping point.
In the console it works when I replace that self.academic_year with a specific year.
the doctype in question does have the field academic_year.
I have tried to model my script on this one:
I am wondering if it is because I am calling that field before I have even saved the doc.
Any suggestin on what should I changed?
Thanks in advance for any help.