fixed asynchronus issue in purchase cycle

This commit is contained in:
Nabin Hait 2013-02-28 16:30:53 +05:30
parent b0486b9d33
commit a71ace0d74
6 changed files with 70 additions and 92 deletions

View File

@ -33,6 +33,21 @@ erpnext.buying.PurchaseInvoiceController = erpnext.buying.BuyingController.exten
}
cur_frm.cscript.is_opening(doc);
},
onload_post_render: function(doc, dt, dn) {
var me = this;
var callback1 = function(doc, dt, dn) {
var callback2 = function(doc, dt, dn) {
if(doc.__islocal && doc.supplier) cur_frm.cscript.supplier(doc, dt, dn);
}
me.update_item_details(doc, dt, dn, callback2);
}
// TODO: improve this
if(this.frm.doc.__islocal && this.frm.fields_dict.price_list_name
&& this.frm.doc.price_list_name) {
this.price_list_name(callback1);
}
}
});
@ -46,16 +61,6 @@ cur_frm.cscript.onload = function(doc,dt,dn) {
if(!doc.posting_date) set_multiple(dt,dn,{posting_date:get_today()});
}
cur_frm.cscript.onload_post_render = function(doc, dt, dn) {
var callback = function(doc, dt, dn) {
if(doc.__islocal && doc.supplier) cur_frm.cscript.supplier(doc,dt,dn);
}
// defined in purchase_common.js
cur_frm.cscript.update_item_details(doc, dt, dn, callback);
}
cur_frm.cscript.supplier = function(doc,dt,dn) {
var callback = function(r,rt) {
var doc = locals[cur_frm.doctype][cur_frm.docname];

View File

@ -51,15 +51,9 @@ erpnext.buying.BuyingController = erpnext.utils.Controller.extend({
if(this.frm.fields_dict.currency)
this.set_dynamic_labels();
// TODO: improve this
if(this.frm.doc.__islocal && this.frm.fields_dict.price_list_name
&& this.frm.doc.price_list_name && this.frm.doc.price_list_currency) {
this.price_list_name();
}
},
price_list_name: function() {
price_list_name: function(callback_fn) {
this.frm.toggle_reqd(["price_list_currency", "plc_conversion_rate"],
!!(this.frm.doc.price_list_name));
@ -77,6 +71,8 @@ erpnext.buying.BuyingController = erpnext.utils.Controller.extend({
callback: function(r) {
if(!r.exc) {
me.price_list_currency();
if (callback_fn) callback_fn(me.frm.doc, me.frm.doc.doctype,
me.frm.doc.name);
}
}
});
@ -89,6 +85,7 @@ erpnext.buying.BuyingController = erpnext.utils.Controller.extend({
item_code: function(doc, cdt, cdn) {
var me = this;
var item = locals[cdt][cdn];
if(item.item_code) {
this.frm.call({
method: "buying.utils.get_item_details",
@ -141,11 +138,11 @@ erpnext.buying.BuyingController = erpnext.utils.Controller.extend({
price_list_currency: function() {
this.set_dynamic_labels();
if(this.frm.doc.price_list_currency === this.get_company_currency())
this.frm.set_value("plc_conversion_rate", 1.0);
else if(this.frm.doc.price_list_currency === this.frm.doc.currency)
this.frm.set_value("plc_conversion_rate", this.frm.doc.conversion_rate || 1.0);
this.frm.set_value("plc_conversion_rate", this.frm.doc.conversion_rate || 1.0);
},
set_dynamic_labels: function(doc, dt, dn) {

View File

@ -40,12 +40,22 @@ erpnext.buying.PurchaseOrderController = erpnext.buying.BuyingController.extend(
},
onload_post_render: function(doc, dt, dn) {
var callback = function(doc, dt, dn) {
if(doc.__islocal) cur_frm.cscript.get_default_schedule_date(doc);
onload_post_render: function(doc, dt, dn) {
var me = this;
var callback1 = function(doc, dt, dn) {
var callback2 = function(doc, dt, dn) {
if(doc.__islocal) cur_frm.cscript.get_default_schedule_date(doc);
}
me.update_item_details(doc, dt, dn, callback2);
}
// TODO: improve this
if(this.frm.doc.__islocal && this.frm.fields_dict.price_list_name
&& this.frm.doc.price_list_name) {
this.price_list_name(callback1);
}
this.update_item_details(doc, dt, dn, callback);
}
});
var new_cscript = new erpnext.buying.PurchaseOrderController({frm: cur_frm});
@ -53,7 +63,7 @@ var new_cscript = new erpnext.buying.PurchaseOrderController({frm: cur_frm});
// for backward compatibility: combine new and previous states
$.extend(cur_frm.cscript, new_cscript);
cur_frm.cscript.onload = function(doc, cdt, cdn) {
cur_frm.cscript.onload = function(doc, cdt, cdn) {
// set missing values in parent doc
set_missing_values(doc, {
fiscal_year: sys_defaults.fiscal_year,

View File

@ -27,12 +27,25 @@ erpnext.buying.SupplierQuotationController = erpnext.buying.BuyingController.ext
refresh: function() {
this._super();
cur_frm.cscript.load_taxes(this.frm.doc);
if (this.frm.doc.docstatus === 1) {
cur_frm.add_custom_button("Make Purchase Order", cur_frm.cscript.make_purchase_order);
}
},
onload_post_render: function(doc, dt, dn) {
var me = this;
var callback = function(doc, dt, dn) {
cur_frm.cscript.load_taxes(me.frm.doc);
}
// TODO: improve this
if(this.frm.doc.__islocal && this.frm.fields_dict.price_list_name
&& this.frm.doc.price_list_name) {
this.price_list_name(callback);
}
}
});
var new_cscript = new erpnext.buying.SupplierQuotationController({frm: cur_frm});

View File

@ -1,8 +1,8 @@
[
{
"creation": "2013-02-20 13:26:14",
"creation": "2013-02-21 14:54:43",
"docstatus": 0,
"modified": "2013-02-20 18:14:06",
"modified": "2013-02-28 10:43:02",
"modified_by": "Administrator",
"owner": "Administrator"
},
@ -28,13 +28,14 @@
"permlevel": 0
},
{
"amend": 0,
"doctype": "DocPerm",
"name": "__common__",
"parent": "Item",
"parentfield": "permissions",
"parenttype": "DocType",
"permlevel": 0,
"read": 1,
"report": 1,
"submit": 0
},
{
@ -596,7 +597,6 @@
"label": "Price Lists and Rates"
},
{
"depends_on": "eval:doc.is_sales_item==\"Yes\"",
"description": "Create a price list from Price List master and enter standard ref rates against each of them. On selection of a price list in Quotation, Sales Order or Delivery Note, corresponding ref rate will be fetched for this item.",
"doctype": "DocField",
"fieldname": "ref_rate_details",
@ -812,76 +812,27 @@
"fieldtype": "Text Editor",
"label": "Website Description"
},
{
"cancel": 0,
"create": 0,
"doctype": "DocPerm",
"permlevel": 1,
"report": 0,
"role": "Material Manager",
"write": 0
},
{
"cancel": 0,
"create": 0,
"doctype": "DocPerm",
"permlevel": 0,
"report": 1,
"role": "Material Manager",
"write": 0
},
{
"cancel": 0,
"create": 0,
"doctype": "DocPerm",
"permlevel": 1,
"report": 0,
"role": "Material User",
"write": 0
},
{
"cancel": 0,
"create": 0,
"doctype": "DocPerm",
"permlevel": 0,
"report": 1,
"role": "Material User",
"write": 0
},
{
"cancel": 1,
"create": 1,
"doctype": "DocPerm",
"permlevel": 0,
"report": 1,
"role": "Material Master Manager",
"write": 1
},
{
"amend": 0,
"cancel": 0,
"create": 0,
"doctype": "DocPerm",
"permlevel": 1,
"report": 0,
"role": "Material Master Manager",
"role": "Material Manager",
"write": 0
},
{
"cancel": 1,
"create": 1,
"doctype": "DocPerm",
"permlevel": 0,
"report": 1,
"role": "System Manager",
"write": 1
},
{
"amend": 0,
"cancel": 0,
"create": 0,
"doctype": "DocPerm",
"permlevel": 1,
"report": 0,
"role": "System Manager",
"role": "Material User",
"write": 0
}
]

View File

@ -37,6 +37,18 @@ erpnext.buying.PurchaseReceiptController = erpnext.buying.BuyingController.exten
if(wn.boot.control_panel.country == 'India') {
unhide_field(['challan_no', 'challan_date']);
}
},
onload_post_render: function(doc, dt, dn) {
var me = this;
var callback = function(doc, dt, dn) {
me.update_item_details(doc, dt, dn, function(r,rt) { });
}
// TODO: improve this
if(this.frm.doc.__islocal && this.frm.fields_dict.price_list_name
&& this.frm.doc.price_list_name) {
this.price_list_name(callback);
}
}
});
@ -45,7 +57,6 @@ var new_cscript = new erpnext.buying.PurchaseReceiptController({frm: cur_frm});
// for backward compatibility: combine new and previous states
$.extend(cur_frm.cscript, new_cscript);
//========================== On Load ================================================================
cur_frm.cscript.onload = function(doc, cdt, cdn) {
if(!doc.fiscal_year && doc.__islocal){ wn.model.set_default_values(doc);}
if (!doc.posting_date) doc.posting_date = dateutil.obj_to_str(new Date());
@ -53,15 +64,6 @@ cur_frm.cscript.onload = function(doc, cdt, cdn) {
if (!doc.status) doc.status = 'Draft';
}
cur_frm.cscript.onload_post_render = function(doc, dt, dn) {
var callback = function(doc, dt, dn) {
// defined in purchase_common.js
cur_frm.cscript.update_item_details(doc, dt, dn, function(r,rt) { });
}
cur_frm.cscript.dynamic_label(doc, dt, dn, callback);
}
//Supplier
cur_frm.cscript.supplier = function(doc,dt,dn) {
if (doc.supplier) {
get_server_fields('get_default_supplier_address',