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)
This commit is contained in:
marination 2021-08-27 18:06:51 +05:30
parent bf72ec0598
commit 2a3ef03388
5 changed files with 32 additions and 9 deletions

View File

@ -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",

View File

@ -43,8 +43,11 @@ class Supplier(TransactionBase):
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 @@ class Supplier(TransactionBase):
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 @@ class Supplier(TransactionBase):
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)

View File

@ -15,6 +15,7 @@ import "./agriculture/ternary_plot";
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";

View File

@ -12,7 +12,8 @@ frappe.ui.form.SupplierQuickEntryForm = class SupplierQuickEntryForm extends fra
}
get_variant_fields() {
var variant_fields = [{
var variant_fields = [
{
fieldtype: "Section Break",
label: __("Primary Contact Details"),
collapsible: 1

View File

@ -150,8 +150,14 @@ class Customer(TransactionBase):
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 @@ class Customer(TransactionBase):
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: