diff --git a/custom_ui/api/db/jobs.py b/custom_ui/api/db/jobs.py index 5efe3a0..5fa2475 100644 --- a/custom_ui/api/db/jobs.py +++ b/custom_ui/api/db/jobs.py @@ -35,6 +35,11 @@ def create_job_from_sales_order(sales_order_name): "custom_company": sales_order.company }) new_job.insert() + # Iterate through new tasks (if any) and set customer, address + # job_tasks = frappe.get_all("Task", filters={"Project": new_job.name}) + # for task in job_tasks: + # task.custom_property = new_job.job_address + # task.save() return build_success_response(new_job.as_dict()) except Exception as e: return build_error_response(str(e), 500) @@ -82,12 +87,15 @@ def get_job_task_table_data(filters={}, sortings={}, page=1, page_size=10): order_by=processed_sortings ) + tableRows = [] for task in tasks: + address_name = frappe.get_value("Project", task.project, "job_address") + full_address = frappe.get_value("Address", address_name, "full_address") tableRow = {} tableRow["id"] = task["name"] tableRow["subject"] = task["subject"] - tableRow["address"] = task.get("custom_property", "") + tableRow["address"] = full_address tableRow["status"] = task.get("status", "") tableRows.append(tableRow) @@ -174,7 +182,7 @@ def get_projects_for_calendar(date, company=None, project_templates=[]): # Parse project_templates if it's a JSON string if isinstance(project_templates, str): project_templates = json.loads(project_templates) - + # put some emojis in the print to make it stand out print("📅📅📅", date, "company:", company, "project_templates:", project_templates, "type:", type(project_templates)) try: @@ -197,4 +205,4 @@ def get_projects_for_calendar(date, company=None, project_templates=[]): unscheduled_projects = [frappe.get_doc("Project", name).as_dict() for name in unscheduled_project_names] return build_success_response({ "projects": projects, "unscheduled_projects": unscheduled_projects }) except Exception as e: - return build_error_response(str(e), 500) \ No newline at end of file + return build_error_response(str(e), 500)