asynchronus issue in get_party_details
This commit is contained in:
parent
1e6c32e95f
commit
6b03914731
@ -227,8 +227,7 @@ cur_frm.cscript.voucher_type = function(doc, cdt, cdn) {
|
||||
"company": doc.company
|
||||
},
|
||||
callback: function(r) {
|
||||
frappe.model.clear_table("Journal Voucher Detail", "Journal Voucher",
|
||||
doc.name, "entries");
|
||||
frappe.model.clear_table(doc, "entries");
|
||||
if(r.message) {
|
||||
update_jv_details(doc, r);
|
||||
}
|
||||
|
@ -39,7 +39,8 @@ def _get_party_details(party=None, account=None, party_type="Customer", company=
|
||||
if party_type=="Customer":
|
||||
out["sales_team"] = [{
|
||||
"sales_person": d.sales_person,
|
||||
"sales_designation": d.sales_designation
|
||||
"sales_designation": d.sales_designation,
|
||||
"allocated_percentage": d.allocated_percentage
|
||||
} for d in party.get("sales_team")]
|
||||
|
||||
return out
|
||||
|
@ -122,17 +122,8 @@ class AccountsController(TransactionBase):
|
||||
|
||||
tax_doctype = self.meta.get_field(tax_parentfield).options
|
||||
|
||||
from frappe.model import default_fields
|
||||
tax_master = frappe.get_doc(tax_master_doctype, self.get(tax_master_field))
|
||||
|
||||
for i, tax in enumerate(tax_master.get(tax_parentfield)):
|
||||
tax = tax.as_dict()
|
||||
|
||||
for fieldname in default_fields:
|
||||
if fieldname in tax:
|
||||
del tax[fieldname]
|
||||
|
||||
self.append(tax_parentfield, tax)
|
||||
self.extend(tax_parentfield,
|
||||
get_taxes_and_charges(tax_doctype, self.get(tax_master_field)), tax_parentfield)
|
||||
|
||||
def set_other_charges(self):
|
||||
self.set("other_charges", [])
|
||||
@ -457,3 +448,20 @@ class AccountsController(TransactionBase):
|
||||
@frappe.whitelist()
|
||||
def get_tax_rate(account_head):
|
||||
return frappe.db.get_value("Account", account_head, "tax_rate")
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_taxes_and_charges(master_doctype, master_name, tax_parentfield):
|
||||
from frappe.model import default_fields
|
||||
tax_master = frappe.get_doc(master_doctype, master_name)
|
||||
|
||||
taxes_and_charges = []
|
||||
for i, tax in enumerate(tax_master.get(tax_parentfield)):
|
||||
tax = tax.as_dict()
|
||||
|
||||
for fieldname in default_fields:
|
||||
if fieldname in tax:
|
||||
del tax[fieldname]
|
||||
|
||||
taxes_and_charges.append(tax)
|
||||
|
||||
return taxes_and_charges
|
||||
|
@ -33,8 +33,12 @@ class SellingController(StockController):
|
||||
def set_missing_lead_customer_details(self):
|
||||
if getattr(self, "customer", None):
|
||||
from erpnext.accounts.party import _get_party_details
|
||||
self.update_if_missing(_get_party_details(self.customer,
|
||||
ignore_permissions=getattr(self, "ignore_permissions", None)))
|
||||
party_details = _get_party_details(self.customer,
|
||||
ignore_permissions=getattr(self, "ignore_permissions", None))
|
||||
if not self.meta.get_field("sales_team"):
|
||||
party_details.pop("sales_team")
|
||||
|
||||
self.update_if_missing(party_details)
|
||||
|
||||
elif getattr(self, "lead", None):
|
||||
from erpnext.selling.doctype.lead.lead import get_lead_details
|
||||
|
@ -121,12 +121,12 @@ pscript.feature_dict = {
|
||||
'Sales BOM': {'fields':['currency']},
|
||||
'Sales Order': {'fields':['conversion_rate','currency','grand_total','in_words','rounded_total'],'sales_order_details':['base_price_list_rate','base_amount','base_rate']}
|
||||
},
|
||||
|
||||
|
||||
'fs_imports': {
|
||||
'Purchase Invoice': {
|
||||
'fields': ['conversion_rate', 'currency', 'grand_total',
|
||||
'in_words', 'net_total', 'other_charges_added',
|
||||
'other_charges_deducted'],
|
||||
'other_charges_deducted'],
|
||||
'entries': ['base_price_list_rate', 'base_amount','base_rate']
|
||||
},
|
||||
'Purchase Order': {
|
||||
@ -144,7 +144,7 @@ pscript.feature_dict = {
|
||||
'fields':['conversion_rate','currency']
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
'fs_item_advanced': {
|
||||
'Item': {'fields':['item_customer_details']}
|
||||
},
|
||||
@ -188,7 +188,7 @@ pscript.feature_dict = {
|
||||
|
||||
$(document).bind('form_refresh', function() {
|
||||
for(var sys_feat in sys_defaults) {
|
||||
if(sys_defaults[sys_feat]=='0'
|
||||
if(sys_defaults[sys_feat]=='0'
|
||||
&& (sys_feat in pscript.feature_dict)) { //"Features to hide" exists
|
||||
|
||||
if(cur_frm.doc.doctype in pscript.feature_dict[sys_feat]) {
|
||||
@ -196,7 +196,7 @@ $(document).bind('form_refresh', function() {
|
||||
if(fort=='fields') {
|
||||
hide_field(pscript.feature_dict[sys_feat][cur_frm.doc.doctype][fort]);
|
||||
} else if(cur_frm.fields_dict[fort]) {
|
||||
cur_frm.fields_dict[fort].grid.set_column_disp(pscript.feature_dict[sys_feat][cur_frm.doc.doctype][fort], false);
|
||||
cur_frm.fields_dict[fort].grid.set_column_disp(pscript.feature_dict[sys_feat][cur_frm.doc.doctype][fort], false);
|
||||
} else {
|
||||
msgprint(__('Grid "')+fort+__('" does not exists'));
|
||||
}
|
||||
|
@ -702,15 +702,20 @@ erpnext.TransactionController = erpnext.stock.StockController.extend({
|
||||
var me = this;
|
||||
if(this.frm.doc.taxes_and_charges) {
|
||||
return this.frm.call({
|
||||
doc: this.frm.doc,
|
||||
method: "set_other_charges",
|
||||
method: "erpnext.controllers.accounts_controller.get_taxes_and_charges",
|
||||
args: {
|
||||
"master_doctype": "Sales Taxes and Charges Master",
|
||||
"master_name": this.frm.doc.taxes_and_charges,
|
||||
"tax_parentfield": this.other_fname
|
||||
},
|
||||
callback: function(r) {
|
||||
if(!r.exc) {
|
||||
me.frm.set_value(me.other_fname, r.message);
|
||||
me.calculate_taxes_and_totals();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
show_item_wise_taxes: function() {
|
||||
|
Loading…
Reference in New Issue
Block a user