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
This commit is contained in:
Nabin Hait 2017-10-03 01:09:46 +05:30 committed by GitHub
parent 7eba1a35d3
commit 7b6eaee05b
3 changed files with 30 additions and 27 deletions

View File

@ -101,27 +101,6 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
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 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
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 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
},
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();

View File

@ -13,7 +13,6 @@ class StudentApplicant(Document):
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

View File

@ -696,7 +696,8 @@ def make_purchase_order_for_drop_shipment(source_name, for_supplier, target_doc=
"contact_display",
"contact_mobile",
"contact_email",
"contact_person"
"contact_person",
"taxes_and_charges"
],
"validation": {
"docstatus": ["=", 1]