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
|
"company": doc.company
|
||||||
},
|
},
|
||||||
callback: function(r) {
|
callback: function(r) {
|
||||||
frappe.model.clear_table("Journal Voucher Detail", "Journal Voucher",
|
frappe.model.clear_table(doc, "entries");
|
||||||
doc.name, "entries");
|
|
||||||
if(r.message) {
|
if(r.message) {
|
||||||
update_jv_details(doc, r);
|
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":
|
if party_type=="Customer":
|
||||||
out["sales_team"] = [{
|
out["sales_team"] = [{
|
||||||
"sales_person": d.sales_person,
|
"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")]
|
} for d in party.get("sales_team")]
|
||||||
|
|
||||||
return out
|
return out
|
||||||
|
|||||||
@ -122,17 +122,8 @@ class AccountsController(TransactionBase):
|
|||||||
|
|
||||||
tax_doctype = self.meta.get_field(tax_parentfield).options
|
tax_doctype = self.meta.get_field(tax_parentfield).options
|
||||||
|
|
||||||
from frappe.model import default_fields
|
self.extend(tax_parentfield,
|
||||||
tax_master = frappe.get_doc(tax_master_doctype, self.get(tax_master_field))
|
get_taxes_and_charges(tax_doctype, self.get(tax_master_field)), tax_parentfield)
|
||||||
|
|
||||||
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)
|
|
||||||
|
|
||||||
def set_other_charges(self):
|
def set_other_charges(self):
|
||||||
self.set("other_charges", [])
|
self.set("other_charges", [])
|
||||||
@ -457,3 +448,20 @@ class AccountsController(TransactionBase):
|
|||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def get_tax_rate(account_head):
|
def get_tax_rate(account_head):
|
||||||
return frappe.db.get_value("Account", account_head, "tax_rate")
|
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):
|
def set_missing_lead_customer_details(self):
|
||||||
if getattr(self, "customer", None):
|
if getattr(self, "customer", None):
|
||||||
from erpnext.accounts.party import _get_party_details
|
from erpnext.accounts.party import _get_party_details
|
||||||
self.update_if_missing(_get_party_details(self.customer,
|
party_details = _get_party_details(self.customer,
|
||||||
ignore_permissions=getattr(self, "ignore_permissions", None)))
|
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):
|
elif getattr(self, "lead", None):
|
||||||
from erpnext.selling.doctype.lead.lead import get_lead_details
|
from erpnext.selling.doctype.lead.lead import get_lead_details
|
||||||
|
|||||||
@ -121,12 +121,12 @@ pscript.feature_dict = {
|
|||||||
'Sales BOM': {'fields':['currency']},
|
'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']}
|
'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': {
|
'fs_imports': {
|
||||||
'Purchase Invoice': {
|
'Purchase Invoice': {
|
||||||
'fields': ['conversion_rate', 'currency', 'grand_total',
|
'fields': ['conversion_rate', 'currency', 'grand_total',
|
||||||
'in_words', 'net_total', 'other_charges_added',
|
'in_words', 'net_total', 'other_charges_added',
|
||||||
'other_charges_deducted'],
|
'other_charges_deducted'],
|
||||||
'entries': ['base_price_list_rate', 'base_amount','base_rate']
|
'entries': ['base_price_list_rate', 'base_amount','base_rate']
|
||||||
},
|
},
|
||||||
'Purchase Order': {
|
'Purchase Order': {
|
||||||
@ -144,7 +144,7 @@ pscript.feature_dict = {
|
|||||||
'fields':['conversion_rate','currency']
|
'fields':['conversion_rate','currency']
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
'fs_item_advanced': {
|
'fs_item_advanced': {
|
||||||
'Item': {'fields':['item_customer_details']}
|
'Item': {'fields':['item_customer_details']}
|
||||||
},
|
},
|
||||||
@ -188,7 +188,7 @@ pscript.feature_dict = {
|
|||||||
|
|
||||||
$(document).bind('form_refresh', function() {
|
$(document).bind('form_refresh', function() {
|
||||||
for(var sys_feat in sys_defaults) {
|
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
|
&& (sys_feat in pscript.feature_dict)) { //"Features to hide" exists
|
||||||
|
|
||||||
if(cur_frm.doc.doctype in pscript.feature_dict[sys_feat]) {
|
if(cur_frm.doc.doctype in pscript.feature_dict[sys_feat]) {
|
||||||
@ -196,7 +196,7 @@ $(document).bind('form_refresh', function() {
|
|||||||
if(fort=='fields') {
|
if(fort=='fields') {
|
||||||
hide_field(pscript.feature_dict[sys_feat][cur_frm.doc.doctype][fort]);
|
hide_field(pscript.feature_dict[sys_feat][cur_frm.doc.doctype][fort]);
|
||||||
} else if(cur_frm.fields_dict[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 {
|
} else {
|
||||||
msgprint(__('Grid "')+fort+__('" does not exists'));
|
msgprint(__('Grid "')+fort+__('" does not exists'));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -702,15 +702,20 @@ erpnext.TransactionController = erpnext.stock.StockController.extend({
|
|||||||
var me = this;
|
var me = this;
|
||||||
if(this.frm.doc.taxes_and_charges) {
|
if(this.frm.doc.taxes_and_charges) {
|
||||||
return this.frm.call({
|
return this.frm.call({
|
||||||
doc: this.frm.doc,
|
method: "erpnext.controllers.accounts_controller.get_taxes_and_charges",
|
||||||
method: "set_other_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) {
|
callback: function(r) {
|
||||||
if(!r.exc) {
|
if(!r.exc) {
|
||||||
|
me.frm.set_value(me.other_fname, r.message);
|
||||||
me.calculate_taxes_and_totals();
|
me.calculate_taxes_and_totals();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
show_item_wise_taxes: function() {
|
show_item_wise_taxes: function() {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user