big update

This commit is contained in:
Casey 2026-01-13 08:11:58 -06:00
parent 6853950cc5
commit 992672b51b
11 changed files with 647 additions and 64 deletions

View file

@ -72,6 +72,36 @@ def add_custom_fields():
print("\n🔧 Adding custom fields to doctypes...")
custom_fields = {
"Customer": [
dict(
fieldname="companies",
label="Companies",
fieldtype="Table",
options="Customer Company Link",
insert_after="customer_type"
),
dict(
fieldname="from_lead",
label="From Lead",
fieldname="Link",
options="Lead",
insert_after="customer_name"
),
dict(
fieldname="properties",
label="Properties",
fieldtype="Table",
options="Customer Address Link",
insert_after="customer_name"
),
dict(
fieldname="contacts",
label="Contacts",
fieldtype="Table",
options="Customer Contact Link",
insert_after="properties"
)
],
"Lead": [
dict(
fieldname="customer_type",
@ -139,6 +169,20 @@ def add_custom_fields():
label="Lead Name",
fieldtype="Data",
insert_after="custom_customer_to_bill"
),
dict(
fieldname="customer_type",
label="Customer Type",
fieldtype="Select",
options="Customer\nLead",
insert_after="lead_name"
),
dict(
fieldname="customer_name",
label="Customer Name",
fieldtype="Dynamic Link",
options="customer_type",
insert_after="customer_type"
)
],
"Contact": [
@ -185,6 +229,34 @@ def add_custom_fields():
fieldtype="Link",
options="Employee",
insert_after="status"
),
dict(
fieldname="company",
label="Company",
fieldtype="Link",
options="Company",
insert_after="assigned_employee"
),
dict(
fieldname="party_type",
label="Party Type",
fieldtype="Select",
options="Customer\nLead",
insert_after="company"
),
dict(
fieldname="party_name",
label="Party Name",
fieldtype="Dynamic Link",
options="party_type",
insert_after="party_type"
),
dict(
fieldname="contact",
label="Contact",
fieldtype="Link",
options="Contact",
insert_after="party_name"
)
],
"Quotation": [
@ -220,6 +292,13 @@ def add_custom_fields():
insert_after="custom_installation_address",
description="The address where the job will be performed.",
allow_on_submit=1
),
dict(
fieldname="from_onsite_meeting",
label="From On-Site Meeting",
fieldtype="Link",
options="On-Site Meeting",
insert_after="custom_job_address"
)
],
"Sales Order": [
@ -357,10 +436,12 @@ def update_address_fields():
quotations = frappe.get_all("Quotation", pluck="name")
addresses = frappe.get_all("Address", pluck="name")
sales_orders = frappe.get_all("Sales Order", pluck="name")
tasks = frappe.get_all("Task", pluck="name")
total_addresses = len(addresses)
total_quotations = len(quotations)
total_sales_orders = len(sales_orders)
total_doctypes = total_addresses + total_quotations + total_sales_orders
total_tasks = len(tasks)
total_doctypes = total_addresses + total_quotations + total_sales_orders + total_tasks
combined_doctypes = []
for sales_order in sales_orders:
combined_doctypes.append({"doctype": "Sales Order", "name": sales_order})
@ -368,9 +449,10 @@ def update_address_fields():
combined_doctypes.append({"doctype": "Quotation", "name": quotation})
for address in addresses:
combined_doctypes.append({"doctype": "Address", "name": address})
for task in tasks:
combined_doctypes.append({"doctype": "Task", "name": task})
print(f"\n📍 Updating field values for {total_addresses} addresses, {total_quotations} quotations, and {total_sales_orders} sales orders...")
print(f"\n📍 Updating field values for {total_addresses} addresses, {total_quotations} quotations, {total_sales_orders} sales orders, and {total_tasks} tasks...")
# Field update counters
field_counters = {
@ -389,7 +471,8 @@ def update_address_fields():
'quotations_updated': 0,
'sales_orders_updated': 0,
'customers_updated': 0,
'contacts_updated': 0
'contacts_updated': 0,
'tasks_updated': 0
}
onsite_meta = frappe.get_meta("On-Site Meeting")
@ -537,7 +620,7 @@ def update_address_fields():
updates['custom_payment_received_status'] = payment_received
field_counters['custom_payment_received_status'] += 1
field_counters['total_field_updates'] += 1
if updates:
frappe.db.set_value("Address", doc['name'], updates)
field_counters['addresses_updated'] += 1
@ -553,7 +636,16 @@ def update_address_fields():
address_doc.save(ignore_permissions=True)
field_counters['address_linked_to_customer'] += 1
field_counters['total_field_updates'] += 1
if doc['doctype'] == "Task":
for task_name in tasks:
property = frappe.get_value("Task", task_name, "custom_property")
project = frappe.get_value("Task", task_name, "project")
project_address = frappe.get_value("Project", project, "custom_installation_address")
alt_project_address = frappe.get_value("Project", project, "custom_address")
if project_address or alt_project_address:
frappe.db.set_value("Task", task_name, "custom_property", project_address if project_address else alt_project_address)
field_counters['tasks_updated'] += 1
field_counters['total_field_updates'] += 1
@ -570,6 +662,7 @@ def update_address_fields():
print(f" • Sales Orders updated: {field_counters['sales_orders_updated']:,}")
print(f" • Customers updated: {field_counters['customers_updated']:,}")
print(f" • Total field updates: {field_counters['total_field_updates']:,}")
print(f" • Tasks Updated: {field_counters['tasks_updated']:,}")
print(f"\n📝 Field-specific updates:")
print(f" • Full Address: {field_counters['full_address']:,}")
print(f" • On-Site Meeting Status: {field_counters['custom_onsite_meeting_scheduled']:,}")