diff --git a/erpnext/accounts/doctype/journal_voucher/journal_voucher.js b/erpnext/accounts/doctype/journal_voucher/journal_voucher.js index ff42169e66..25a65572ac 100644 --- a/erpnext/accounts/doctype/journal_voucher/journal_voucher.js +++ b/erpnext/accounts/doctype/journal_voucher/journal_voucher.js @@ -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); } diff --git a/erpnext/accounts/party.py b/erpnext/accounts/party.py index 5713a90409..eb6dc02443 100644 --- a/erpnext/accounts/party.py +++ b/erpnext/accounts/party.py @@ -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 diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py index 3abbd03f1b..404dfa741b 100644 --- a/erpnext/controllers/accounts_controller.py +++ b/erpnext/controllers/accounts_controller.py @@ -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 diff --git a/erpnext/controllers/selling_controller.py b/erpnext/controllers/selling_controller.py index e34f159baa..9f5306b9ca 100644 --- a/erpnext/controllers/selling_controller.py +++ b/erpnext/controllers/selling_controller.py @@ -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 diff --git a/erpnext/public/js/feature_setup.js b/erpnext/public/js/feature_setup.js index 157de292ae..a45b602da1 100644 --- a/erpnext/public/js/feature_setup.js +++ b/erpnext/public/js/feature_setup.js @@ -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')); } diff --git a/erpnext/public/js/transaction.js b/erpnext/public/js/transaction.js index 65d91c28d3..1ee06f7caf 100644 --- a/erpnext/public/js/transaction.js +++ b/erpnext/public/js/transaction.js @@ -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() {