44 lines
2.4 KiB
Python
44 lines
2.4 KiB
Python
import sys
|
|
import traceback
|
|
try:
|
|
user = env["res.users"].search([("login", "=", "demo.student")], limit=1)
|
|
|
|
c = env["res.company"].search([], limit=1)
|
|
campus = env["education.campus"].search([], limit=1) or env["education.campus"].create({"name": "Test", "company_id": c.id})
|
|
dept = env["education.department"].search([], limit=1) or env["education.department"].create({"name": "Test", "company_id": c.id, "campus_id": campus.id})
|
|
level = env["education.academic.level"].search([], limit=1) or env["education.academic.level"].create({"name": "Test", "company_id": c.id})
|
|
prog = env["education.program"].search([], limit=1) or env["education.program"].create({"name": "Test", "code": "T", "department_id": dept.id, "level_id": level.id})
|
|
year = env["education.academic.year"].search([], limit=1) or env["education.academic.year"].create({"name": "Test", "company_id": c.id, "start_date": "2026-01-01", "end_date": "2026-12-31"})
|
|
term = env["education.academic.term"].search([], limit=1) or env["education.academic.term"].create({"name": "Test", "academic_year_id": year.id, "start_date": "2026-01-01", "end_date": "2026-12-31"})
|
|
batch = env["education.batch"].search([], limit=1) or env["education.batch"].create({"name": "Test", "program_id": prog.id, "academic_year_id": year.id})
|
|
sem = env["education.semester"].search([], limit=1) or env["education.semester"].create({"name": "Test", "program_id": prog.id, "academic_year_id": year.id, "sequence": 1})
|
|
|
|
student = env["education.student"].create({
|
|
"full_name": "Demo Student",
|
|
"first_name": "Demo",
|
|
"last_name": "Student",
|
|
"email": "demo.student@example.com",
|
|
"portal_user_id": user.id,
|
|
"company_id": c.id,
|
|
"campus_id": campus.id,
|
|
"department_id": dept.id,
|
|
"level_id": level.id,
|
|
"program_id": prog.id,
|
|
"academic_year_id": year.id,
|
|
"academic_term_id": term.id,
|
|
"batch_id": batch.id,
|
|
"semester_id": sem.id,
|
|
"current_semester_id": sem.id,
|
|
"date_of_birth": "2000-01-01",
|
|
"gender": "other",
|
|
"admission_number": "ADM-9999",
|
|
"student_id": "STU-9999",
|
|
"status": "active"
|
|
})
|
|
env.cr.commit()
|
|
with open('/mnt/extra-addons/error.log', 'w') as f:
|
|
f.write("SUCCESS: " + str(student.id))
|
|
except Exception as e:
|
|
with open('/mnt/extra-addons/error.log', 'w') as f:
|
|
f.write(traceback.format_exc())
|