mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-05 22:48:27 +00:00
callback issues and item default get most priority
This commit is contained in:
@@ -21,19 +21,15 @@ cur_frm.cscript.onload = function(doc,dt,dn) {
|
|||||||
if(!doc.currency && sys_defaults.currency) set_multiple(dt,dn,{currency:sys_defaults.currency});
|
if(!doc.currency && sys_defaults.currency) set_multiple(dt,dn,{currency:sys_defaults.currency});
|
||||||
if(!doc.price_list_currency) set_multiple(dt, dn, {price_list_currency: doc.currency, plc_conversion_rate: 1});
|
if(!doc.price_list_currency) set_multiple(dt, dn, {price_list_currency: doc.currency, plc_conversion_rate: 1});
|
||||||
|
|
||||||
hide_field(['customer_address', 'contact_person', 'customer_name', 'address_display', 'contact_display', 'contact_mobile', 'contact_email', 'territory', 'customer_group']);
|
hide_field(['customer_address', 'contact_person','customer_name','address_display', 'contact_display', 'contact_mobile', 'contact_email', 'territory', 'customer_group']);
|
||||||
|
|
||||||
//for previously created sales invoice, set required field related to pos
|
|
||||||
if(doc.is_pos ==1) cur_frm.cscript.is_pos(doc, dt, dn);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cur_frm.cscript.onload_post_render = function(doc, dt, dn) {
|
cur_frm.cscript.onload_post_render = function(doc, dt, dn) {
|
||||||
var callback = null;
|
var callback2 = null;
|
||||||
if(doc.customer && doc.__islocal) {
|
if(doc.customer && doc.__islocal) {
|
||||||
// called from mapper, update the account names for items and customer
|
// called from mapper, update the account names for items and customer
|
||||||
callback = function(doc, dt, dn) {
|
callback2 = function(doc, dt, dn) {
|
||||||
$c_obj(make_doclist(doc.doctype,doc.name),
|
$c_obj(make_doclist(doc.doctype,doc.name),
|
||||||
'load_default_accounts','',
|
'load_default_accounts','',
|
||||||
function(r,rt) {
|
function(r,rt) {
|
||||||
@@ -44,15 +40,20 @@ cur_frm.cscript.onload_post_render = function(doc, dt, dn) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// defined in sales_common.js
|
// defined in sales_common.js
|
||||||
cur_frm.cscript.update_item_details(doc, cdt, cdn, callback);
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Hide Fields
|
// Hide Fields
|
||||||
// ------------
|
// ------------
|
||||||
cur_frm.cscript.hide_fields = function(doc, cdt, cdn) {
|
cur_frm.cscript.hide_fields = function(doc, cdt, cdn) {
|
||||||
par_flds =['project_name', 'due_date', 'posting_time', 'sales_order_main', 'delivery_note_main', 'Get Items', 'is_opening', 'conversion_rate', 'source', 'cancel_reason', 'total_advance', 'gross_profit', 'gross_profit_percent', 'Get Advances Received', 'advance_adjustment_details', 'sales_partner', 'commission_rate', 'total_commission', 'Repair Outstanding Amt'];
|
par_flds = ['project_name', 'due_date', 'posting_time', 'sales_order_main', 'delivery_note_main', 'Get Items', 'is_opening', 'conversion_rate', 'source', 'cancel_reason', 'total_advance', 'gross_profit', 'gross_profit_percent', 'Get Advances Received', 'advance_adjustment_details', 'sales_partner', 'commission_rate', 'total_commission', 'Repair Outstanding Amt'];
|
||||||
|
|
||||||
ch_flds = {'entries': ['sales_order', 'delivery_note']}
|
ch_flds = {'entries': ['sales_order', 'delivery_note']}
|
||||||
|
|
||||||
@@ -107,7 +108,7 @@ cur_frm.cscript.refresh = function(doc, dt, dn) {
|
|||||||
|
|
||||||
//fetch retail transaction related fields
|
//fetch retail transaction related fields
|
||||||
//--------------------------------------------
|
//--------------------------------------------
|
||||||
cur_frm.cscript.is_pos = function(doc,dt,dn){
|
cur_frm.cscript.is_pos = function(doc,dt,dn,callback){
|
||||||
cur_frm.cscript.hide_fields(doc, cdt, cdn);
|
cur_frm.cscript.hide_fields(doc, cdt, cdn);
|
||||||
if(doc.is_pos == 1){
|
if(doc.is_pos == 1){
|
||||||
if (!doc.company) {
|
if (!doc.company) {
|
||||||
@@ -116,10 +117,11 @@ cur_frm.cscript.is_pos = function(doc,dt,dn){
|
|||||||
refresh_field('is_pos');
|
refresh_field('is_pos');
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
var callback = function(r,rt){
|
var callback1 = function(r,rt){
|
||||||
|
if(callback) callback(doc, dt, dn);
|
||||||
cur_frm.refresh();
|
cur_frm.refresh();
|
||||||
}
|
}
|
||||||
$c_obj(make_doclist(dt,dn),'set_pos_fields','',callback);
|
$c_obj(make_doclist(dt,dn),'set_pos_fields','',callback1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -72,9 +72,12 @@ class DocType(TransactionBase):
|
|||||||
if not dtl:
|
if not dtl:
|
||||||
dtl = webnotes.conn.sql("select income_account, warehouse, cost_center from `tabPOS Setting` where ifnull(user,'') = '' and company = '%s'" % (self.doc.company), as_dict=1)
|
dtl = webnotes.conn.sql("select income_account, warehouse, cost_center from `tabPOS Setting` where ifnull(user,'') = '' and company = '%s'" % (self.doc.company), as_dict=1)
|
||||||
for d in getlist(self.doclist,'entries'):
|
for d in getlist(self.doclist,'entries'):
|
||||||
if dtl and dtl[0]['income_account']: d.income_account = dtl[0]['income_account']
|
# overwrite if mentioned in item
|
||||||
if dtl and dtl[0]['cost_center']: d.cost_center = dtl[0]['cost_center']
|
item = webnotes.conn.sql("select default_income_account, default_sales_cost_center, default_warehouse from tabItem where name = '%s'" %(d.item_code), as_dict=1)
|
||||||
if dtl and dtl[0]['warehouse']: d.warehouse = dtl[0]['warehouse']
|
d.income_account = item and item[0]['default_income_account'] or dtl and dtl[0]['income_account'] or ''
|
||||||
|
d.cost_center = item and item[0]['default_sales_cost_center'] or dtl and dtl[0]['cost_center'] or ''
|
||||||
|
d.warehouse = item and item[0]['default_warehouse'] or dtl and dtl[0]['warehouse'] or ''
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Get Account Head to which amount needs to be Debited based on Customer
|
# Get Account Head to which amount needs to be Debited based on Customer
|
||||||
@@ -168,9 +171,9 @@ class DocType(TransactionBase):
|
|||||||
dtl = webnotes.conn.sql("select income_account, warehouse, cost_center from `tabPOS Setting` where user = '%s' and company = '%s'" % (session['user'], self.doc.company), as_dict=1)
|
dtl = webnotes.conn.sql("select income_account, warehouse, cost_center from `tabPOS Setting` where user = '%s' and company = '%s'" % (session['user'], self.doc.company), as_dict=1)
|
||||||
if not dtl:
|
if not dtl:
|
||||||
dtl = webnotes.conn.sql("select income_account, warehouse, cost_center from `tabPOS Setting` where ifnull(user,'') = '' and company = '%s'" % (self.doc.company), as_dict=1)
|
dtl = webnotes.conn.sql("select income_account, warehouse, cost_center from `tabPOS Setting` where ifnull(user,'') = '' and company = '%s'" % (self.doc.company), as_dict=1)
|
||||||
if dtl and dtl[0]['income_account']: ret['income_account'] = dtl and dtl[0]['income_account']
|
if dtl and not ret['income_account'] and dtl[0]['income_account']: ret['income_account'] = dtl and dtl[0]['income_account']
|
||||||
if dtl and dtl[0]['cost_center']: ret['cost_center'] = dtl and dtl[0]['cost_center']
|
if dtl and not ret['cost_center'] and dtl[0]['cost_center']: ret['cost_center'] = dtl and dtl[0]['cost_center']
|
||||||
if dtl and dtl[0]['warehouse']: ret['warehouse'] = dtl and dtl[0]['warehouse']
|
if dtl and not ret['warehouse'] and dtl[0]['warehouse']: ret['warehouse'] = dtl and dtl[0]['warehouse']
|
||||||
if ret['warehouse']:
|
if ret['warehouse']:
|
||||||
actual_qty = webnotes.conn.sql("select actual_qty from `tabBin` where item_code = '%s' and warehouse = '%s'" % (item_code, ret['warehouse']))
|
actual_qty = webnotes.conn.sql("select actual_qty from `tabBin` where item_code = '%s' and warehouse = '%s'" % (item_code, ret['warehouse']))
|
||||||
ret['actual_qty']= actual_qty and flt(actual_qty[0][0]) or 0
|
ret['actual_qty']= actual_qty and flt(actual_qty[0][0]) or 0
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -140,7 +140,6 @@ class DocType(TransactionBase):
|
|||||||
ret['export_rate'] = flt(base_ref_rate)/flt(obj.doc.conversion_rate)
|
ret['export_rate'] = flt(base_ref_rate)/flt(obj.doc.conversion_rate)
|
||||||
ret['base_ref_rate'] = flt(base_ref_rate)
|
ret['base_ref_rate'] = flt(base_ref_rate)
|
||||||
ret['basic_rate'] = flt(base_ref_rate)
|
ret['basic_rate'] = flt(base_ref_rate)
|
||||||
|
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
# ***************** Get Ref rate as entered in Item Master ********************
|
# ***************** Get Ref rate as entered in Item Master ********************
|
||||||
|
|||||||
Reference in New Issue
Block a user