form cleanup: fixed callback issues
This commit is contained in:
parent
df78d20fab
commit
6d517ff005
@ -1043,7 +1043,7 @@ div.dialog_head {
|
||||
}
|
||||
|
||||
div.dialog_body {
|
||||
padding: 8px 8px 16px;
|
||||
padding: 8px 4px 16px 4px;
|
||||
border-radius: 5px;
|
||||
-moz-border-radius: 5px;
|
||||
-webkit-border-radius: 5px;
|
||||
|
@ -362,7 +362,7 @@ div.dialog_head {
|
||||
}
|
||||
|
||||
div.dialog_body {
|
||||
padding: 8px 8px 16px;
|
||||
padding: 8px 4px 16px 4px;
|
||||
border-radius: 5px;
|
||||
-moz-border-radius: 5px;
|
||||
-webkit-border-radius: 5px;
|
||||
|
@ -42,27 +42,31 @@ cur_frm.cscript.onload = function(doc,dt,dn) {
|
||||
}
|
||||
|
||||
cur_frm.cscript.onload_post_render = function(doc, dt, dn) {
|
||||
var callback2 = null;
|
||||
if(doc.customer && doc.__islocal) {
|
||||
var callback = function(doc, dt, dn) {
|
||||
// called from mapper, update the account names for items and customer
|
||||
callback2 = function(doc, dt, dn) {
|
||||
$c_obj(make_doclist(doc.doctype,doc.name),
|
||||
'load_default_accounts','',
|
||||
function(r,rt) {
|
||||
refresh_field('entries');
|
||||
cur_frm.cscript.customer(doc,dt,dn,onload=true);
|
||||
}
|
||||
);
|
||||
var callback2 = function(doc, dt, dn) {
|
||||
if(doc.customer && doc.__islocal) {
|
||||
$c_obj(make_doclist(doc.doctype,doc.name),
|
||||
'load_default_accounts','',
|
||||
function(r,rt) {
|
||||
refresh_field('entries');
|
||||
cur_frm.cscript.customer(doc,dt,dn,onload=true);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
// defined in sales_common.js
|
||||
var callback1 = function(doc, dt, dn) {
|
||||
//for previously created sales invoice, set required field related to pos
|
||||
cur_frm.cscript.update_item_details(doc, dt, dn, callback2);
|
||||
}
|
||||
}
|
||||
// defined in sales_common.js
|
||||
var callback1 = function(doc, dt, dn) {
|
||||
//for previously created sales invoice, set required field related to pos
|
||||
cur_frm.cscript.update_item_details(doc, dt, dn, callback2);
|
||||
}
|
||||
|
||||
if(doc.is_pos ==1) cur_frm.cscript.is_pos(doc, dt, dn,callback1);
|
||||
else cur_frm.cscript.update_item_details(doc, dt, dn, callback2);
|
||||
if(doc.is_pos ==1) cur_frm.cscript.is_pos(doc, dt, dn,callback1);
|
||||
else cur_frm.cscript.update_item_details(doc, dt, dn, callback2);
|
||||
}
|
||||
|
||||
cur_frm.cscript.hide_price_list_currency(doc, dt, dn, callback);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -97,16 +101,11 @@ cur_frm.cscript.hide_fields = function(doc, cdt, cdn) {
|
||||
cur_frm.cscript.refresh = function(doc, dt, dn) {
|
||||
cur_frm.cscript.is_opening(doc, dt, dn);
|
||||
cur_frm.cscript.hide_fields(doc, dt, dn);
|
||||
|
||||
var callback = function() {
|
||||
cur_frm.cscript.dynamic_label(doc, dt, dn);
|
||||
}
|
||||
cur_frm.cscript.hide_price_list_currency(doc, dt, dn, callback);
|
||||
|
||||
|
||||
// Show / Hide button
|
||||
cur_frm.clear_custom_buttons();
|
||||
|
||||
if (!cur_frm.cscript.is_onload) cur_frm.cscript.hide_price_list_currency(doc, dt, dn);
|
||||
|
||||
if(doc.docstatus==1) {
|
||||
cur_frm.add_custom_button('View Ledger', cur_frm.cscript['View Ledger Entry']);
|
||||
cur_frm.add_custom_button('Send SMS', cur_frm.cscript['Send SMS']);
|
||||
|
@ -167,16 +167,19 @@ class DocType(TransactionBase):
|
||||
# Item Details
|
||||
# -------------
|
||||
def get_item_details(self, args=None):
|
||||
args = eval(args)
|
||||
if args['item_code']:
|
||||
args = args and eval(args) or {}
|
||||
if args.get('item_code'):
|
||||
ret = get_obj('Sales Common').get_item_details(args, self)
|
||||
return self.get_pos_details(args, ret)
|
||||
else:
|
||||
obj = get_obj('Sales Common')
|
||||
for doc in self.doclist:
|
||||
if doc.fields.get('item_code'):
|
||||
ret = obj.get_item_details(doc.item_code, self)
|
||||
ret = self.get_pos_details(doc.item_code, ret)
|
||||
arg = {'item_code':doc.fields.get('item_code'), 'income_account':doc.fields.get('income_account'),
|
||||
'cost_center': doc.fields.get('cost_center'), 'warehouse': doc.fields.get('warehouse')};
|
||||
|
||||
ret = obj.get_item_details(arg, self)
|
||||
ret = self.get_pos_details(arg, ret)
|
||||
for r in ret:
|
||||
if not doc.fields.get(r):
|
||||
doc.fields[r] = ret[r]
|
||||
@ -205,14 +208,6 @@ class DocType(TransactionBase):
|
||||
get_obj('Sales Common').get_adj_percent(self)
|
||||
|
||||
|
||||
def get_comp_base_currency(self):
|
||||
return get_obj('Sales Common').get_comp_base_currency(self.doc.company)
|
||||
|
||||
def get_price_list_currency(self):
|
||||
return get_obj('Sales Common').get_price_list_currency(self.doc.price_list_name, self.doc.company)
|
||||
|
||||
|
||||
|
||||
# Get tax rate if account type is tax
|
||||
# ------------------------------------
|
||||
def get_rate(self,arg):
|
||||
|
@ -50,8 +50,11 @@ cur_frm.cscript.onload = function(doc, cdt, cdn) {
|
||||
}
|
||||
|
||||
cur_frm.cscript.onload_post_render = function(doc, dt, dn) {
|
||||
// defined in sales_common.js
|
||||
cur_frm.cscript.update_item_details(doc, cdt, cdn);
|
||||
var callback = function(doc, dt, dn) {
|
||||
// defined in sales_common.js
|
||||
cur_frm.cscript.update_item_details(doc, dt, dn);
|
||||
}
|
||||
cur_frm.cscript.hide_price_list_currency(doc, dt, dn, callback);
|
||||
}
|
||||
|
||||
// hide - unhide fields based on lead or customer..
|
||||
@ -83,10 +86,7 @@ cur_frm.cscript.refresh = function(doc, cdt, cdn) {
|
||||
|
||||
cur_frm.clear_custom_buttons();
|
||||
|
||||
var callback = function() {
|
||||
cur_frm.cscript.dynamic_label(doc, cdt, cdn);
|
||||
}
|
||||
cur_frm.cscript.hide_price_list_currency(doc, cdt, cdn, callback);
|
||||
if (!cur_frm.cscript.is_onload) cur_frm.cscript.hide_price_list_currency(doc, cdt, cdn);
|
||||
|
||||
|
||||
if(doc.docstatus == 1 && doc.status!='Order Lost') {
|
||||
|
@ -77,14 +77,16 @@ class DocType(TransactionBase):
|
||||
# Get Item Details
|
||||
# -----------------
|
||||
def get_item_details(self, args=None):
|
||||
args = eval(args)
|
||||
if args['item_code']:
|
||||
args = args and eval(args) or {}
|
||||
if args.get('item_code'):
|
||||
return get_obj('Sales Common').get_item_details(args, self)
|
||||
else:
|
||||
obj = get_obj('Sales Common')
|
||||
for doc in self.doclist:
|
||||
if doc.fields.get('item_code'):
|
||||
ret = obj.get_item_details(doc.item_code, self)
|
||||
arg = {'item_code':doc.fields.get('item_code'), 'income_account':doc.fields.get('income_account'),
|
||||
'cost_center': doc.fields.get('cost_center'), 'warehouse': doc.fields.get('warehouse')};
|
||||
ret = obj.get_item_details(arg, self)
|
||||
for r in ret:
|
||||
if not doc.fields.get(r):
|
||||
doc.fields[r] = ret[r]
|
||||
@ -96,11 +98,6 @@ class DocType(TransactionBase):
|
||||
get_obj('Sales Common').get_adj_percent(self)
|
||||
|
||||
|
||||
def get_comp_base_currency(self):
|
||||
return get_obj('Sales Common').get_comp_base_currency(self.doc.company)
|
||||
|
||||
def get_price_list_currency(self):
|
||||
return get_obj('Sales Common').get_price_list_currency(self.doc.price_list_name, self.doc.company)
|
||||
|
||||
|
||||
# OTHER CHARGES TRIGGER FUNCTIONS
|
||||
|
@ -75,7 +75,6 @@ cur_frm.cscript.update_item_details = function(doc, dt, dn, callback) {
|
||||
|
||||
|
||||
|
||||
|
||||
// ============== Customer and its primary contact Details ============================
|
||||
cur_frm.cscript.customer = function(doc, cdt, cdn) {
|
||||
if(doc.customer){
|
||||
@ -136,17 +135,11 @@ var set_dynamic_label_child = function(doc, cdt, cdn, base_curr) {
|
||||
// Change label dynamically based on currency
|
||||
//------------------------------------------------------------------
|
||||
|
||||
cur_frm.cscript.dynamic_label = function(doc, cdt, cdn) {
|
||||
var callback = function(r, rt) {
|
||||
if (r.message) base_curr = r.message;
|
||||
else base_curr = sys_defaults['currency'];
|
||||
cur_frm.cscript.dynamic_label = function(doc, cdt, cdn, base_curr, callback) {
|
||||
set_dynamic_label_par(doc, cdt, cdn, base_curr);
|
||||
set_dynamic_label_child(doc, cdt, cdn, base_curr);
|
||||
|
||||
set_dynamic_label_par(doc, cdt, cdn, base_curr);
|
||||
set_dynamic_label_child(doc, cdt, cdn, base_curr);
|
||||
}
|
||||
|
||||
if (doc.company == sys_defaults['company']) callback('', '');
|
||||
else $c_obj(make_doclist(doc.doctype, doc.name), 'get_comp_base_currency', '', callback);
|
||||
if (callback) callback(doc, cdt, cdn);
|
||||
}
|
||||
|
||||
|
||||
@ -155,27 +148,30 @@ cur_frm.cscript.dynamic_label = function(doc, cdt, cdn) {
|
||||
|
||||
cur_frm.cscript.hide_price_list_currency = function(doc, cdt, cdn, callback1) {
|
||||
if (doc.price_list_name && doc.currency) {
|
||||
var callback = function(r, rt) {
|
||||
pl_currency = r.message[0]?r.message[0]:[];
|
||||
if (pl_currency.length==1) {
|
||||
if (pl_currency[0] == doc.currency) set_multiple(cdt, cdn, {price_list_currency:doc.currency, plc_conversion_rate:doc.conversion_rate});
|
||||
else if (pl_currency[0] = r.message[1]) set_multiple(cdt, cdn, {price_list_currency:pl_currency[0], plc_conversion_rate:1})
|
||||
hide_field(['price_list_currency', 'plc_conversion_rate']);
|
||||
} else unhide_field(['price_list_currency', 'plc_conversion_rate']);
|
||||
wn.call({
|
||||
method: 'selling.doctype.sales_common.sales_common.get_price_list_currency',
|
||||
args: {'price_list':doc.price_list_name, 'company': doc.company},
|
||||
callback: function(r, rt) {
|
||||
pl_currency = r.message[0]?r.message[0]:[];
|
||||
if (pl_currency.length==1) {
|
||||
if (pl_currency[0] == doc.currency) set_multiple(cdt, cdn, {price_list_currency:doc.currency, plc_conversion_rate:doc.conversion_rate});
|
||||
else if (pl_currency[0] = r.message[1]) set_multiple(cdt, cdn, {price_list_currency:pl_currency[0], plc_conversion_rate:1})
|
||||
hide_field(['price_list_currency', 'plc_conversion_rate']);
|
||||
} else unhide_field(['price_list_currency', 'plc_conversion_rate']);
|
||||
|
||||
if (r.message[1] == doc.currency) {
|
||||
set_multiple(cdt, cdn, {conversion_rate:1});
|
||||
hide_field(['conversion_rate', 'grand_total_export', 'in_words_export', 'rounded_total_export']);
|
||||
} else unhide_field(['conversion_rate', 'grand_total_export', 'in_words_export', 'rounded_total_export']);
|
||||
if (r.message[1] == doc.currency) {
|
||||
set_multiple(cdt, cdn, {conversion_rate:1});
|
||||
hide_field(['conversion_rate', 'grand_total_export', 'in_words_export', 'rounded_total_export']);
|
||||
} else unhide_field(['conversion_rate', 'grand_total_export', 'in_words_export', 'rounded_total_export']);
|
||||
|
||||
if (r.message[1] == doc.price_list_currency) {
|
||||
set_multiple(cdt, cdn, {plc_conversion_rate:1});
|
||||
hide_field('plc_conversion_rate');
|
||||
} else unhide_field('plc_conversion_rate');
|
||||
|
||||
callback1()
|
||||
}
|
||||
$c_obj(make_doclist(doc.doctype, doc.name), 'get_price_list_currency', '', callback);
|
||||
if (r.message[1] == doc.price_list_currency) {
|
||||
set_multiple(cdt, cdn, {plc_conversion_rate:1});
|
||||
hide_field('plc_conversion_rate');
|
||||
} else unhide_field('plc_conversion_rate');
|
||||
|
||||
cur_frm.cscript.dynamic_label(doc, cdt, cdn, r.message[1], callback1);
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@ -213,12 +209,15 @@ cur_frm.cscript.conversion_rate = cur_frm.cscript.currency;
|
||||
cur_frm.cscript.plc_conversion_rate = cur_frm.cscript.currency;
|
||||
|
||||
cur_frm.cscript.company = function(doc, dt, dn) {
|
||||
var callback = function(r, rt) {
|
||||
var doc = locals[dt][dn];
|
||||
set_multiple(doc.doctype, doc.name, {currency:r.message,price_list_currency:r.message});
|
||||
cur_frm.cscript.currency(doc, cdt, cdn);
|
||||
}
|
||||
$c_obj(make_doclist(doc.doctype, doc.name), 'get_comp_base_currency', '', callback);
|
||||
wn.call({
|
||||
method: 'selling.doctype.sales_common.sales_common.get_comp_base_currency',
|
||||
args: {company:doc.company},
|
||||
callback: function(r, rt) {
|
||||
var doc = locals[dt][dn];
|
||||
set_multiple(doc.doctype, doc.name, {currency:r.message, price_list_currency:r.message});
|
||||
cur_frm.cscript.currency(doc, cdt, cdn);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -234,7 +233,6 @@ cur_frm.cscript.price_list_name = function(doc, cdt, cdn) {
|
||||
refresh_field(fname);
|
||||
var doc = locals[cdt][cdn];
|
||||
cur_frm.cscript.recalc(doc,3); //this is to re-calculate BASIC RATE and AMOUNT on basis of changed REF RATE
|
||||
cur_frm.cscript.dynamic_label(doc, cdt, cdn);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
@ -178,18 +178,6 @@ class DocType(TransactionBase):
|
||||
d.export_amount = flt(d.qty)*flt(base_ref_rate)/flt(obj.doc.conversion_rate)
|
||||
|
||||
|
||||
def get_comp_base_currency(self, comp):
|
||||
""" get default currency of company"""
|
||||
return webnotes.conn.sql("select default_currency from `tabCompany` where name = %s", comp)[0][0]
|
||||
|
||||
def get_price_list_currency(self, price_list, comp):
|
||||
""" Get all currency in which price list is maintained"""
|
||||
plc = webnotes.conn.sql("select distinct ref_currency from `tabRef Rate Detail` where price_list_name = %s", price_list)
|
||||
plc = [d[0] for d in plc]
|
||||
base_currency = self.get_comp_base_currency(comp)
|
||||
return plc, base_currency
|
||||
|
||||
|
||||
# Load Default Taxes
|
||||
# ====================
|
||||
def load_default_taxes(self, obj):
|
||||
@ -781,3 +769,17 @@ class StatusUpdater:
|
||||
where
|
||||
name="%(name)s"
|
||||
""" % args)
|
||||
|
||||
|
||||
@webnotes.whitelist()
|
||||
def get_comp_base_currency(arg=None):
|
||||
""" get default currency of company"""
|
||||
return webnotes.conn.sql("select default_currency from `tabCompany` where name = %s", webnotes.form_dict['company'])[0][0]
|
||||
|
||||
@webnotes.whitelist()
|
||||
def get_price_list_currency(arg=None):
|
||||
""" Get all currency in which price list is maintained"""
|
||||
plc = webnotes.conn.sql("select distinct ref_currency from `tabRef Rate Detail` where price_list_name = %s", webnotes.form_dict['price_list'])
|
||||
plc = [d[0] for d in plc]
|
||||
base_currency = get_comp_base_currency(webnotes.form_dict['company'])
|
||||
return plc, base_currency
|
||||
|
@ -41,10 +41,15 @@ cur_frm.cscript.onload = function(doc, cdt, cdn) {
|
||||
}
|
||||
|
||||
cur_frm.cscript.onload_post_render = function(doc, cdt, cdn) {
|
||||
if(doc.__islocal) {
|
||||
// defined in sales_common.js
|
||||
cur_frm.cscript.update_item_details(doc, cdt, cdn);
|
||||
var callback = function(doc, cdt, cdn) {
|
||||
if(doc.__islocal) {
|
||||
// defined in sales_common.js
|
||||
cur_frm.cscript.update_item_details(doc, cdt, cdn);
|
||||
}
|
||||
}
|
||||
|
||||
cur_frm.cscript.hide_price_list_currency(doc, cdt, cdn, callback);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -52,10 +57,8 @@ cur_frm.cscript.onload_post_render = function(doc, cdt, cdn) {
|
||||
//==================
|
||||
cur_frm.cscript.refresh = function(doc, cdt, cdn) {
|
||||
cur_frm.clear_custom_buttons();
|
||||
var callback = function() {
|
||||
cur_frm.cscript.dynamic_label(doc, cdt, cdn);
|
||||
}
|
||||
cur_frm.cscript.hide_price_list_currency(doc, cdt, cdn, callback);
|
||||
|
||||
if (!cur_frm.cscript.is_onload) cur_frm.cscript.hide_price_list_currency(doc, cdt, cdn);
|
||||
|
||||
|
||||
if(doc.docstatus==1) {
|
||||
|
@ -102,14 +102,16 @@ class DocType(TransactionBase):
|
||||
# Get Item Details
|
||||
# ----------------
|
||||
def get_item_details(self, args=None):
|
||||
args = eval(args)
|
||||
if args['item_code']:
|
||||
args = args and eval(args) or {}
|
||||
if args.get('item_code'):
|
||||
return get_obj('Sales Common').get_item_details(args, self)
|
||||
else:
|
||||
obj = get_obj('Sales Common')
|
||||
for doc in self.doclist:
|
||||
if doc.fields.get('item_code'):
|
||||
ret = obj.get_item_details(doc.item_code, self)
|
||||
arg = {'item_code':doc.fields.get('item_code'), 'income_account':doc.fields.get('income_account'),
|
||||
'cost_center': doc.fields.get('cost_center'), 'warehouse': doc.fields.get('warehouse')};
|
||||
ret = obj.get_item_details(arg, self)
|
||||
for r in ret:
|
||||
if not doc.fields.get(r):
|
||||
doc.fields[r] = ret[r]
|
||||
@ -120,13 +122,6 @@ class DocType(TransactionBase):
|
||||
def get_adj_percent(self, arg=''):
|
||||
get_obj('Sales Common').get_adj_percent(self)
|
||||
|
||||
def get_comp_base_currency(self):
|
||||
return get_obj('Sales Common').get_comp_base_currency(self.doc.company)
|
||||
|
||||
def get_price_list_currency(self):
|
||||
return get_obj('Sales Common').get_price_list_currency(self.doc.price_list_name, self.doc.company)
|
||||
|
||||
|
||||
|
||||
|
||||
# Get projected qty of item based on warehouse selected
|
||||
|
@ -43,17 +43,19 @@ cur_frm.cscript.onload = function(doc, dt, dn) {
|
||||
|
||||
cur_frm.cscript.onload_post_render = function(doc, dt, dn) {
|
||||
// defined in sales_common.js
|
||||
if(doc.__islocal) cur_frm.cscript.update_item_details(doc, dt, dn);
|
||||
var callback = function(doc, dt, dn) {
|
||||
if(doc.__islocal) cur_frm.cscript.update_item_details(doc, dt, dn);
|
||||
}
|
||||
|
||||
cur_frm.cscript.hide_price_list_currency(doc, dt, dn, callback);
|
||||
}
|
||||
|
||||
// REFRESH
|
||||
// ================================================================================================
|
||||
cur_frm.cscript.refresh = function(doc, cdt, cdn) {
|
||||
cur_frm.clear_custom_buttons();
|
||||
var callback = function() {
|
||||
cur_frm.cscript.dynamic_label(doc, cdt, cdn);
|
||||
}
|
||||
cur_frm.cscript.hide_price_list_currency(doc, cdt, cdn, callback);
|
||||
|
||||
if (!cur_frm.cscript.is_onload) cur_frm.cscript.hide_price_list_currency(doc, cdt, cdn);
|
||||
|
||||
|
||||
if(doc.per_billed < 100 && doc.docstatus==1) cur_frm.add_custom_button('Make Invoice', cur_frm.cscript['Make Sales Invoice']);
|
||||
|
@ -117,14 +117,16 @@ class DocType(TransactionBase):
|
||||
|
||||
# ***************** Get Item Details ******************************
|
||||
def get_item_details(self, args=None):
|
||||
args = eval(args)
|
||||
if args['item_code']:
|
||||
args = args and eval(args) or {}
|
||||
if args.get('item_code'):
|
||||
return get_obj('Sales Common').get_item_details(args, self)
|
||||
else:
|
||||
obj = get_obj('Sales Common')
|
||||
for doc in self.doclist:
|
||||
if doc.fields.get('item_code'):
|
||||
ret = obj.get_item_details(doc.item_code, self)
|
||||
arg = {'item_code':doc.fields.get('item_code'), 'income_account':doc.fields.get('income_account'),
|
||||
'cost_center': doc.fields.get('cost_center'), 'warehouse': doc.fields.get('warehouse')};
|
||||
ret = obj.get_item_details(arg, self)
|
||||
for r in ret:
|
||||
if not doc.fields.get(r):
|
||||
doc.fields[r] = ret[r]
|
||||
@ -135,13 +137,6 @@ class DocType(TransactionBase):
|
||||
get_obj('Sales Common').get_adj_percent(self)
|
||||
|
||||
|
||||
def get_comp_base_currency(self):
|
||||
return get_obj('Sales Common').get_comp_base_currency(self.doc.company)
|
||||
|
||||
def get_price_list_currency(self):
|
||||
return get_obj('Sales Common').get_price_list_currency(self.doc.price_list_name, self.doc.company)
|
||||
|
||||
|
||||
# ********** Get Actual Qty of item in warehouse selected *************
|
||||
def get_actual_qty(self,args):
|
||||
args = eval(args)
|
||||
|
@ -1 +1 @@
|
||||
753
|
||||
755
|
Loading…
x
Reference in New Issue
Block a user