fix client creation

This commit is contained in:
Casey 2025-12-13 08:23:03 -06:00
parent 0d7976b140
commit 0c1bb52f1b
9 changed files with 305 additions and 161 deletions

View file

@ -1,5 +1,6 @@
import os
import subprocess
import sys
import frappe
from .utils import create_module
@ -70,6 +71,15 @@ def add_custom_fields():
print("\n🔧 Adding custom fields to Address doctype...")
custom_fields = {
"Lead": [
dict(
fieldname="customer_type",
label="Customer Type",
fieldtype="Select",
options="Individual\nCompany\nPartnership",
insert_after="lead_name"
)
],
"Address": [
dict(
fieldname="full_address",
@ -315,21 +325,29 @@ def update_address_fields():
filled_length = int(bar_length * index // total_addresses)
bar = '' * filled_length + '' * (bar_length - filled_length)
# Print a three-line, refreshing progress block to avoid terminal wrap
# Print a three-line, refreshing progress block without adding new lines each loop
progress_line = f"📊 Progress: [{bar}] {progress_percentage:3d}% ({index}/{total_addresses})"
counters_line = f" Fields updated: {total_field_updates} | Addresses updated: {addresses_updated}"
detail_line = f" Processing: {name[:40]}..."
if index == 1:
# Save cursor position at the start of the progress block
print("\033[s", end='')
# First render: write the three lines
sys.stdout.write(
f"\r\033[K{progress_line}\n"
f"\033[K{counters_line}\n"
f"\033[K{detail_line}"
)
else:
# Restore to the saved cursor position to rewrite the three-line block
print("\033[u", end='')
# Move cursor up 3 lines, then rewrite each line in place
sys.stdout.write("\033[2F")
sys.stdout.write(f"\r\033[K{progress_line}\n")
sys.stdout.write(f"\033[K{counters_line}\n")
sys.stdout.write(f"\033[K{detail_line}")
print(f"\r\033[K{progress_line}")
print(f"\r\033[K{counters_line}")
print(f"\r\033[K{detail_line}", end='' if index != total_addresses else '\n', flush=True)
if index == total_addresses:
sys.stdout.write("\n")
sys.stdout.flush()
should_update = False
address = frappe.get_doc("Address", name)