fix: Popup stale build and data consistency
- Include `supplier_quick_entry.js` in erpnext.bundle.js
- Create primary supplier address on update
- Set newly created address (quick entry) in Supplier and Customer
- Clear address set in supplier and customer on delete (dependency)
diff --git a/erpnext/buying/doctype/supplier/supplier.json b/erpnext/buying/doctype/supplier/supplier.json
index 22e689c..c7a5db5 100644
--- a/erpnext/buying/doctype/supplier/supplier.json
+++ b/erpnext/buying/doctype/supplier/supplier.json
@@ -399,7 +399,6 @@
"options": "Contact"
},
{
- "depends_on": "mobile_no",
"fetch_from": "supplier_primary_contact.mobile_no",
"fieldname": "mobile_no",
"fieldtype": "Read Only",
@@ -439,7 +438,7 @@
"link_fieldname": "supplier"
}
],
- "modified": "2021-08-27 13:46:18.212802",
+ "modified": "2021-08-27 18:02:44.314077",
"modified_by": "Administrator",
"module": "Buying",
"name": "Supplier",
diff --git a/erpnext/buying/doctype/supplier/supplier.py b/erpnext/buying/doctype/supplier/supplier.py
index 8252b40..207485e 100644
--- a/erpnext/buying/doctype/supplier/supplier.py
+++ b/erpnext/buying/doctype/supplier/supplier.py
@@ -43,8 +43,11 @@
self.naming_series = ''
self.create_primary_contact()
+ self.create_primary_address()
def validate(self):
+ self.flags.is_new_doc = self.is_new()
+
# validation for Naming Series mandatory field...
if frappe.defaults.get_global_default('supp_master_name') == 'Naming Series':
if not self.naming_series:
@@ -90,9 +93,14 @@
def create_primary_address(self):
from erpnext.selling.doctype.customer.customer import make_address
+ from frappe.contacts.doctype.address.address import get_address_display
if self.flags.is_new_doc and self.get('address_line1'):
- make_address(self)
+ address = make_address(self)
+ address_display = get_address_display(address.name)
+
+ self.db_set("supplier_primary_address", address.name)
+ self.db_set("primary_address", address_display)
def on_trash(self):
if self.supplier_primary_contact:
@@ -100,8 +108,10 @@
UPDATE `tabSupplier`
SET
supplier_primary_contact=null,
+ supplier_primary_address=null,
mobile_no=null,
- email_id=null
+ email_id=null,
+ primary_address=null
WHERE name='{self.name}'""")
delete_contact_and_address('Supplier', self.name)
diff --git a/erpnext/public/js/erpnext.bundle.js b/erpnext/public/js/erpnext.bundle.js
index 9f7f29a..febdb24 100644
--- a/erpnext/public/js/erpnext.bundle.js
+++ b/erpnext/public/js/erpnext.bundle.js
@@ -15,6 +15,7 @@
import "./templates/item_quick_entry.html";
import "./utils/item_quick_entry";
import "./utils/customer_quick_entry";
+import "./utils/supplier_quick_entry";
import "./education/student_button.html";
import "./education/assessment_result_tool.html";
import "./hub/hub_factory";
diff --git a/erpnext/public/js/utils/supplier_quick_entry.js b/erpnext/public/js/utils/supplier_quick_entry.js
index f650d1f..e4a3812 100644
--- a/erpnext/public/js/utils/supplier_quick_entry.js
+++ b/erpnext/public/js/utils/supplier_quick_entry.js
@@ -12,7 +12,8 @@
}
get_variant_fields() {
- var variant_fields = [{
+ var variant_fields = [
+ {
fieldtype: "Section Break",
label: __("Primary Contact Details"),
collapsible: 1
diff --git a/erpnext/selling/doctype/customer/customer.py b/erpnext/selling/doctype/customer/customer.py
index abf146c..05cabcb 100644
--- a/erpnext/selling/doctype/customer/customer.py
+++ b/erpnext/selling/doctype/customer/customer.py
@@ -150,8 +150,14 @@
self.db_set('email_id', self.email_id)
def create_primary_address(self):
+ from frappe.contacts.doctype.address.address import get_address_display
+
if self.flags.is_new_doc and self.get('address_line1'):
- make_address(self)
+ address = make_address(self)
+ address_display = get_address_display(address.name)
+
+ self.db_set("customer_primary_address", address.name)
+ self.db_set("primary_address", address_display)
def update_lead_status(self):
'''If Customer created from Lead, update lead status to "Converted"
@@ -246,9 +252,15 @@
def on_trash(self):
if self.customer_primary_contact:
- frappe.db.sql("""update `tabCustomer`
- set customer_primary_contact=null, mobile_no=null, email_id=null
- where name=%s""", self.name)
+ frappe.db.sql(f"""
+ UPDATE `tabCustomer`
+ SET
+ customer_primary_contact=null,
+ customer_primary_address=null,
+ mobile_no=null,
+ email_id=null,
+ primary_address=null
+ WHERE name='{self.name}'""")
delete_contact_and_address('Customer', self.name)
if self.lead_name: