big updates
This commit is contained in:
parent
34f2c110d6
commit
03a230b8f7
14 changed files with 2417 additions and 242 deletions
|
|
@ -10,11 +10,14 @@ def after_install():
|
|||
|
||||
def after_migrate():
|
||||
add_custom_fields()
|
||||
update_onsite_meeting_fields()
|
||||
frappe.db.commit()
|
||||
|
||||
# Proper way to refresh metadata
|
||||
frappe.clear_cache(doctype="Address")
|
||||
frappe.reload_doctype("Address")
|
||||
frappe.clear_cache(doctype="On-Site Meeting")
|
||||
frappe.reload_doctype("On-Site Meeting")
|
||||
|
||||
update_address_fields()
|
||||
build_frontend()
|
||||
|
|
@ -111,6 +114,36 @@ def add_custom_fields():
|
|||
default="Not Started",
|
||||
insert_after="job_status"
|
||||
)
|
||||
],
|
||||
"On-Site Meeting": [
|
||||
dict(
|
||||
fieldname="notes",
|
||||
label="Notes",
|
||||
fieldtype="Small Text",
|
||||
insert_after="address"
|
||||
),
|
||||
dict(
|
||||
fieldname="assigned_employee",
|
||||
label="Assigned Employee",
|
||||
fieldtype="Link",
|
||||
options="Employee",
|
||||
insert_after="notes"
|
||||
),
|
||||
dict(
|
||||
fieldname="status",
|
||||
label="Status",
|
||||
fieldtype="Select",
|
||||
options="Unscheduled\nScheduled\nCompleted\nCancelled",
|
||||
default="Unscheduled",
|
||||
insert_after="start_time"
|
||||
),
|
||||
dict(
|
||||
fieldname="completed_by",
|
||||
label="Completed By",
|
||||
fieldtype="Link",
|
||||
options="Employee",
|
||||
insert_after="status"
|
||||
)
|
||||
]
|
||||
}
|
||||
|
||||
|
|
@ -132,6 +165,35 @@ def add_custom_fields():
|
|||
print(f"❌ Error creating custom fields: {str(e)}")
|
||||
frappe.log_error(message=str(e), title="Custom Fields Creation Failed")
|
||||
raise
|
||||
|
||||
def update_onsite_meeting_fields():
|
||||
"""Update On-Site Meeting doctype fields to make start_time and end_time optional."""
|
||||
print("\n🔧 Updating On-Site Meeting doctype fields...")
|
||||
|
||||
try:
|
||||
# Get the doctype
|
||||
doctype = frappe.get_doc("DocType", "On-Site Meeting")
|
||||
|
||||
# Find and update start_time and end_time fields
|
||||
updated_fields = []
|
||||
for field in doctype.fields:
|
||||
if field.fieldname in ['start_time', 'end_time']:
|
||||
if field.reqd == 1:
|
||||
field.reqd = 0
|
||||
updated_fields.append(field.fieldname)
|
||||
|
||||
if updated_fields:
|
||||
# Save the doctype
|
||||
doctype.save(ignore_permissions=True)
|
||||
print(f"✅ Updated fields: {', '.join(updated_fields)} (set to not required)")
|
||||
else:
|
||||
print("✅ Fields already configured correctly")
|
||||
|
||||
print("🔧 On-Site Meeting field update complete.\n")
|
||||
except Exception as e:
|
||||
print(f"❌ Error updating On-Site Meeting fields: {str(e)}")
|
||||
frappe.log_error(message=str(e), title="On-Site Meeting Field Update Failed")
|
||||
# Don't raise - this is not critical enough to stop migration
|
||||
|
||||
def update_address_fields():
|
||||
addresses = frappe.get_all("Address", pluck="name")
|
||||
|
|
@ -214,14 +276,14 @@ def update_address_fields():
|
|||
job_status = "Not Started"
|
||||
payment_received = "Not Started"
|
||||
|
||||
onsite_meetings = frappe.get_all("On-Site Meeting", filters={"address": address.address_title})
|
||||
onsite_meetings = frappe.get_all("On-Site Meeting", fields=["docstatus"],filters={"address": address.address_title})
|
||||
if onsite_meetings and onsite_meetings[0]:
|
||||
onsite_meeting = "Completed"
|
||||
onsite_meeting = "Completed" if onsite_meetings[0]["docstatus"] == 1 else "In Progress"
|
||||
|
||||
estimates = frappe.get_all("Quotation", fields=["custom_sent"], filters={"custom_installation_address": address.address_title})
|
||||
if estimates and estimates[0] and estimates[0]["custom_sent"] == 1:
|
||||
estimates = frappe.get_all("Quotation", fields=["custom_sent", "docstatus"], filters={"custom_installation_address": address.address_title})
|
||||
if estimates and estimates[0] and estimates[0]["custom_sent"] == 1 and estimates[0]["docstatus"] == 1:
|
||||
estimate_sent = "Completed"
|
||||
elif estimates and estimates[0]:
|
||||
elif estimates and estimates[0] and estimates[0]["docstatus"] != 1:
|
||||
estimate_sent = "In Progress"
|
||||
|
||||
jobs = frappe.get_all("Project", fields=["status"], filters={"custom_installation_address": address.address_title, "project_template": "SNW Install"})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue