Fixes to handle async events (#11018)
* Fixes to handle async events
* transaction.js code cleanup
* Don't map taxes and charges while making PO from SO for drop-ship
* Removed print
diff --git a/erpnext/public/js/controllers/transaction.js b/erpnext/public/js/controllers/transaction.js
index c83e6df..5b647f8 100644
--- a/erpnext/public/js/controllers/transaction.js
+++ b/erpnext/public/js/controllers/transaction.js
@@ -101,27 +101,6 @@
return me.set_query_for_batch(doc, cdt, cdn)
});
}
- },
- onload: function() {
- var me = this;
- if(this.frm.doc.__islocal) {
- var today = frappe.datetime.get_today(),
- currency = frappe.defaults.get_user_default("currency");
-
- $.each({
- currency: currency,
- price_list_currency: currency,
- status: "Draft",
- is_subcontracted: "No",
- }, function(fieldname, value) {
- if(me.frm.fields_dict[fieldname] && !me.frm.doc[fieldname])
- me.frm.set_value(fieldname, value);
- });
-
- if(this.frm.doc.company && !this.frm.doc.amended_from) {
- this.frm.trigger("company");
- }
- }
if(this.frm.fields_dict["taxes"]) {
this["taxes_remove"] = this.calculate_taxes_and_totals;
@@ -153,11 +132,36 @@
return {
filters: filters
- }
+ };
});
}
+ },
+ onload: function() {
+ var me = this;
this.setup_quality_inspection();
+
+ if(this.frm.doc.__islocal) {
+ var currency = frappe.defaults.get_user_default("currency");
+
+ let set_value = (fieldname, value) => {
+ if(me.frm.fields_dict[fieldname] && !me.frm.doc[fieldname]) {
+ return me.frm.set_value(fieldname, value);
+ }
+ };
+
+ return frappe.run_serially([
+ () => set_value('currency', currency),
+ () => set_value('price_list_currency', currency),
+ () => set_value('status', 'Draft'),
+ () => set_value('is_subcontracted', 'No'),
+ () => {
+ if(this.frm.doc.company && !this.frm.doc.amended_from) {
+ this.frm.trigger("company");
+ }
+ }
+ ]);
+ }
},
setup_quality_inspection: function() {
@@ -195,13 +199,12 @@
},
onload_post_render: function() {
- var me = this;
if(this.frm.doc.__islocal && !(this.frm.doc.taxes || []).length
&& !(this.frm.doc.__onload ? this.frm.doc.__onload.load_after_mapping : false)) {
- this.apply_default_taxes();
+ frappe.after_ajax(() => this.apply_default_taxes());
} else if(this.frm.doc.__islocal && this.frm.doc.company && this.frm.doc["items"]
&& !this.frm.doc.is_pos) {
- me.calculate_taxes_and_totals();
+ frappe.after_ajax(() => this.calculate_taxes_and_totals());
}
if(frappe.meta.get_docfield(this.frm.doc.doctype + " Item", "item_code")) {
this.setup_item_selector();
diff --git a/erpnext/schools/doctype/student_applicant/student_applicant.py b/erpnext/schools/doctype/student_applicant/student_applicant.py
index 081fa06..aeeffce 100644
--- a/erpnext/schools/doctype/student_applicant/student_applicant.py
+++ b/erpnext/schools/doctype/student_applicant/student_applicant.py
@@ -13,7 +13,6 @@
if self.student_admission:
naming_series = frappe.db.get_value('Student Admission', self.student_admission,
'naming_series_for_student_applicant')
- print(naming_series)
if naming_series:
self.naming_series = naming_series
diff --git a/erpnext/selling/doctype/sales_order/sales_order.py b/erpnext/selling/doctype/sales_order/sales_order.py
index 613b0bb..98333c4 100644
--- a/erpnext/selling/doctype/sales_order/sales_order.py
+++ b/erpnext/selling/doctype/sales_order/sales_order.py
@@ -696,7 +696,8 @@
"contact_display",
"contact_mobile",
"contact_email",
- "contact_person"
+ "contact_person",
+ "taxes_and_charges"
],
"validation": {
"docstatus": ["=", 1]