From 890707854d7efca4a875b33725dd7f96c5ac5e68 Mon Sep 17 00:00:00 2001 From: Zlash65 Date: Thu, 19 Apr 2018 18:37:29 +0530 Subject: [PATCH] config/utility level changes --- erpnext/accounts/party.py | 24 +++++++------- .../accounts_receivable.py | 12 +++---- .../accounts_receivable_summary.py | 6 ++-- .../purchase_register/purchase_register.py | 8 ++--- .../purchase_analytics/purchase_analytics.js | 32 +++++++++---------- erpnext/config/buying.py | 4 +-- erpnext/demo/setup/setup_data.py | 2 +- .../operations/install_fixtures.py | 16 +++++----- erpnext/startup/report_data_map.py | 6 ++-- erpnext/utilities/user_progress_utils.py | 2 +- 10 files changed, 56 insertions(+), 56 deletions(-) diff --git a/erpnext/accounts/party.py b/erpnext/accounts/party.py index 6f272cf833..652272dbe1 100644 --- a/erpnext/accounts/party.py +++ b/erpnext/accounts/party.py @@ -47,7 +47,7 @@ def _get_party_details(party=None, account=None, party_type="Customer", company= set_contact_details(out, party, party_type) set_other_values(out, party, party_type) set_price_list(out, party, party_type, price_list) - out["taxes_and_charges"] = set_taxes(party.name, party_type, posting_date, company, out.customer_group, out.supplier_type) + out["taxes_and_charges"] = set_taxes(party.name, party_type, posting_date, company, out.customer_group, out.supplier_group) out["payment_terms_template"] = get_pyt_term_template(party.name, party_type, company) if not out.get("currency"): @@ -105,7 +105,7 @@ def set_other_values(out, party, party_type): if party_type=="Customer": to_copy = ["customer_name", "customer_group", "territory", "language"] else: - to_copy = ["supplier_name", "supplier_type", "language"] + to_copy = ["supplier_name", "supplier_group", "language"] for f in to_copy: out[f] = party.get(f) @@ -169,7 +169,7 @@ def set_account_and_due_date(party, account, party_type, company, posting_date, def get_party_account(party_type, party, company): """Returns the account for the given `party`. Will first search in party (Customer / Supplier) record, if not found, - will search in group (Customer Group / Supplier Type), + will search in group (Customer Group / Supplier Group), finally will return default.""" if not company: frappe.throw(_("Please select a Company")) @@ -181,7 +181,7 @@ def get_party_account(party_type, party, company): {"parenttype": party_type, "parent": party, "company": company}, "account") if not account and party_type in ['Customer', 'Supplier']: - party_group_doctype = "Customer Group" if party_type=="Customer" else "Supplier Type" + party_group_doctype = "Customer Group" if party_type=="Customer" else "Supplier Group" group = frappe.db.get_value(party_type, party, scrub(party_group_doctype)) account = frappe.db.get_value("Party Account", {"parenttype": party_group_doctype, "parent": group, "company": company}, "account") @@ -274,8 +274,8 @@ def get_due_date(posting_date, party_type, party, company=None, bill_date=None): due_date = get_due_date_from_template(template_name, posting_date, bill_date).strftime("%Y-%m-%d") else: if party_type == "Supplier": - supplier_type = frappe.db.get_value(party_type, party, fieldname="supplier_type") - template_name = frappe.db.get_value("Supplier Type", supplier_type, fieldname="payment_terms") + supplier_group = frappe.db.get_value(party_type, party, fieldname="supplier_group") + template_name = frappe.db.get_value("Supplier Group", supplier_group, fieldname="payment_terms") if template_name: due_date = get_due_date_from_template(template_name, posting_date, bill_date).strftime("%Y-%m-%d") # If due date is calculated from bill_date, check this condition @@ -321,7 +321,7 @@ def validate_due_date(posting_date, due_date, party_type, party, company=None, b .format(formatdate(default_due_date))) @frappe.whitelist() -def set_taxes(party, party_type, posting_date, company, customer_group=None, supplier_type=None, +def set_taxes(party, party_type, posting_date, company, customer_group=None, supplier_group=None, billing_address=None, shipping_address=None, use_for_shopping_cart=None): from erpnext.accounts.doctype.tax_rule.tax_rule import get_tax_template, get_party_details args = { @@ -332,8 +332,8 @@ def set_taxes(party, party_type, posting_date, company, customer_group=None, sup if customer_group: args['customer_group'] = customer_group - if supplier_type: - args['supplier_type'] = supplier_type + if supplier_group: + args['supplier_group'] = supplier_group if billing_address or shipping_address: args.update(get_party_details(party, party_type, {"billing_address": billing_address, \ @@ -371,10 +371,10 @@ def get_pyt_term_template(party_name, party_type, company=None): customer.customer_group, fieldname='payment_terms') else: supplier = frappe.db.get_value("Supplier", party_name, - fieldname=['payment_terms', "supplier_type"], as_dict=1) + fieldname=['payment_terms', "supplier_group"], as_dict=1) template = supplier.payment_terms - if not template and supplier.supplier_type: - template = frappe.db.get_value("Supplier Type", supplier.supplier_type, fieldname='payment_terms') + if not template and supplier.supplier_group: + template = frappe.db.get_value("Supplier Group", supplier.supplier_group, fieldname='payment_terms') if not template and company: template = frappe.db.get_value("Company", company, fieldname='payment_terms') diff --git a/erpnext/accounts/report/accounts_receivable/accounts_receivable.py b/erpnext/accounts/report/accounts_receivable/accounts_receivable.py index fc76be406e..ca806bfc4a 100644 --- a/erpnext/accounts/report/accounts_receivable/accounts_receivable.py +++ b/erpnext/accounts/report/accounts_receivable/accounts_receivable.py @@ -112,7 +112,7 @@ class ReceivablePayableReport(object): _("Customer Group") + ":Link/Customer Group:120" ] if args.get("party_type") == "Supplier": - columns += [_("Supplier Type") + ":Link/Supplier Type:80"] + columns += [_("Supplier Group") + ":Link/Supplier Group:80"] columns.append(_("Remarks") + "::200") @@ -194,11 +194,11 @@ class ReceivablePayableReport(object): # Delivery Note row += [voucher_details.get(gle.voucher_no, {}).get("delivery_note")] - # customer territory / supplier type + # customer territory / supplier group if args.get("party_type") == "Customer": row += [self.get_territory(gle.party), self.get_customer_group(gle.party)] if args.get("party_type") == "Supplier": - row += [self.get_supplier_type(gle.party)] + row += [self.get_supplier_group(gle.party)] row.append(gle.remarks) data.append(row) @@ -260,15 +260,15 @@ class ReceivablePayableReport(object): def get_customer_group(self, party_name): return self.get_party_map("Customer").get(party_name, {}).get("customer_group") or "" - def get_supplier_type(self, party_name): - return self.get_party_map("Supplier").get(party_name, {}).get("supplier_type") or "" + def get_supplier_group(self, party_name): + return self.get_party_map("Supplier").get(party_name, {}).get("supplier_group") or "" def get_party_map(self, party_type): if not hasattr(self, "party_map"): if party_type == "Customer": select_fields = "name, customer_name, territory, customer_group" elif party_type == "Supplier": - select_fields = "name, supplier_name, supplier_type" + select_fields = "name, supplier_name, supplier_group" self.party_map = dict(((r.name, r) for r in frappe.db.sql("select {0} from `tab{1}`" .format(select_fields, party_type), as_dict=True))) diff --git a/erpnext/accounts/report/accounts_receivable_summary/accounts_receivable_summary.py b/erpnext/accounts/report/accounts_receivable_summary/accounts_receivable_summary.py index 08b24fb147..9b50960f4b 100644 --- a/erpnext/accounts/report/accounts_receivable_summary/accounts_receivable_summary.py +++ b/erpnext/accounts/report/accounts_receivable_summary/accounts_receivable_summary.py @@ -35,7 +35,7 @@ class AccountsReceivableSummary(ReceivablePayableReport): _("Customer Group") + ":Link/Customer Group:120" ] if args.get("party_type") == "Supplier": - columns += [_("Supplier Type") + ":Link/Supplier Type:80"] + columns += [_("Supplier Group") + ":Link/Supplier Group:80"] columns.append({ "fieldname": "currency", @@ -66,7 +66,7 @@ class AccountsReceivableSummary(ReceivablePayableReport): if args.get("party_type") == "Customer": row += [self.get_territory(party), self.get_customer_group(party)] if args.get("party_type") == "Supplier": - row += [self.get_supplier_type(party)] + row += [self.get_supplier_group(party)] row.append(party_dict.currency) data.append(row) @@ -113,7 +113,7 @@ class AccountsReceivableSummary(ReceivablePayableReport): "outstanding_amt", "age", "range1", "range2", "range3", "range4", "currency"] if args.get("party_type") == "Supplier": - cols += ["supplier_type", "remarks"] + cols += ["supplier_group", "remarks"] if args.get("party_type") == "Customer": cols += ["territory", "customer_group", "remarks"] diff --git a/erpnext/accounts/report/purchase_register/purchase_register.py b/erpnext/accounts/report/purchase_register/purchase_register.py index cf599a0ccc..7a298b322f 100644 --- a/erpnext/accounts/report/purchase_register/purchase_register.py +++ b/erpnext/accounts/report/purchase_register/purchase_register.py @@ -42,7 +42,7 @@ def _execute(filters=None, additional_table_columns=None, additional_query_colum row.append(inv.get(col)) row += [ - supplier_details.get(inv.supplier), # supplier_type + supplier_details.get(inv.supplier), # supplier_group inv.tax_id, inv.credit_to, inv.mode_of_payment, ", ".join(project), inv.bill_no, inv.bill_date, inv.remarks, ", ".join(purchase_order), ", ".join(purchase_receipt), company_currency @@ -83,7 +83,7 @@ def get_columns(invoice_list, additional_table_columns): columns += additional_table_columns columns += [ - _("Supplier Type") + ":Link/Supplier Type:120", _("Tax Id") + "::80", _("Payable Account") + ":Link/Account:120", + _("Supplier Group") + ":Link/Supplier Group:120", _("Tax Id") + "::80", _("Payable Account") + ":Link/Account:120", _("Mode of Payment") + ":Link/Mode of Payment:80", _("Project") + ":Link/Project:80", _("Bill No") + "::120", _("Bill Date") + ":Date:80", _("Remarks") + "::150", _("Purchase Order") + ":Link/Purchase Order:100", @@ -229,8 +229,8 @@ def get_account_details(invoice_list): def get_supplier_details(suppliers): supplier_details = {} - for supp in frappe.db.sql("""select name, supplier_type from `tabSupplier` + for supp in frappe.db.sql("""select name, supplier_group from `tabSupplier` where name in (%s)""" % ", ".join(["%s"]*len(suppliers)), tuple(suppliers), as_dict=1): - supplier_details.setdefault(supp.name, supp.supplier_type) + supplier_details.setdefault(supp.name, supp.supplier_group) return supplier_details diff --git a/erpnext/buying/page/purchase_analytics/purchase_analytics.js b/erpnext/buying/page/purchase_analytics/purchase_analytics.js index 442a8bbd3e..df5790e826 100644 --- a/erpnext/buying/page/purchase_analytics/purchase_analytics.js +++ b/erpnext/buying/page/purchase_analytics/purchase_analytics.js @@ -19,7 +19,7 @@ erpnext.PurchaseAnalytics = frappe.views.TreeGridReport.extend({ title: __("Purchase Analytics"), parent: $(wrapper).find('.layout-main'), page: wrapper.page, - doctypes: ["Item", "Item Group", "Supplier", "Supplier Type", "Company", "Fiscal Year", + doctypes: ["Item", "Item Group", "Supplier", "Supplier Group", "Company", "Fiscal Year", "Purchase Invoice", "Purchase Invoice Item", "Purchase Order", "Purchase Order Item[Purchase Analytics]", "Purchase Receipt", "Purchase Receipt Item[Purchase Analytics]"], @@ -27,11 +27,11 @@ erpnext.PurchaseAnalytics = frappe.views.TreeGridReport.extend({ }); this.tree_grids = { - "Supplier Type": { - label: __("Supplier Type / Supplier"), + "Supplier Group": { + label: __("Supplier Group / Supplier"), show: true, item_key: "supplier", - parent_field: "parent_supplier_type", + parent_field: "parent_supplier_group", formatter: function(item) { return item.supplier_name ? item.supplier_name + " (" + item.name + ")" : item.name; } @@ -77,7 +77,7 @@ erpnext.PurchaseAnalytics = frappe.views.TreeGridReport.extend({ }, filters: [ {fieldtype:"Select", label: __("Tree Type"), fieldname: "tree_type", - options:["Supplier Type", "Supplier", "Item Group", "Item"], + options:["Supplier Group", "Supplier", "Item Group", "Item"], filter: function(val, item, opts, me) { return me.apply_zero_filter(val, item, opts, me); }}, @@ -110,22 +110,22 @@ erpnext.PurchaseAnalytics = frappe.views.TreeGridReport.extend({ var me = this; if (!this.tl) { // add 'Not Set' Supplier & Item - // Add 'All Supplier Types' Supplier Type + // Add 'All Supplier Groups' Supplier Group // (Supplier / Item are not mandatory!!) - // Set parent supplier type for tree view + // Set parent supplier group for tree view - $.each(frappe.report_dump.data["Supplier Type"], function(i, v) { - v['parent_supplier_type'] = __("All Supplier Types") + $.each(frappe.report_dump.data["Supplier Group"], function(i, v) { + v['parent_supplier_group'] = __("All Supplier Groups") }) - frappe.report_dump.data["Supplier Type"] = [{ - name: __("All Supplier Types"), - id: "All Supplier Types", - }].concat(frappe.report_dump.data["Supplier Type"]); + frappe.report_dump.data["Supplier Group"] = [{ + name: __("All Supplier Groups"), + id: "All Supplier Groups", + }].concat(frappe.report_dump.data["Supplier Group"]); frappe.report_dump.data["Supplier"].push({ name: __("Not Set"), - parent_supplier_type: __("All Supplier Types"), + parent_supplier_group: __("All Supplier Groups"), id: "Not Set", }); @@ -144,8 +144,8 @@ erpnext.PurchaseAnalytics = frappe.views.TreeGridReport.extend({ if(!this.data || me.item_type != me.tree_type) { if(me.tree_type=='Supplier') { var items = frappe.report_dump.data["Supplier"]; - } if(me.tree_type=='Supplier Type') { - var items = this.prepare_tree("Supplier", "Supplier Type"); + } if(me.tree_type=='Supplier Group') { + var items = this.prepare_tree("Supplier", "Supplier Group"); } else if(me.tree_type=="Item Group") { var items = this.prepare_tree("Item", "Item Group"); } else if(me.tree_type=="Item") { diff --git a/erpnext/config/buying.py b/erpnext/config/buying.py index ba29125ca0..e20d514a23 100644 --- a/erpnext/config/buying.py +++ b/erpnext/config/buying.py @@ -39,8 +39,8 @@ def get_data(): }, { "type": "doctype", - "name": "Supplier Type", - "description": _("Supplier Type master.") + "name": "Supplier Group", + "description": _("Supplier Group master.") }, { "type": "doctype", diff --git a/erpnext/demo/setup/setup_data.py b/erpnext/demo/setup/setup_data.py index 4ed4df9176..42d079db34 100644 --- a/erpnext/demo/setup/setup_data.py +++ b/erpnext/demo/setup/setup_data.py @@ -275,7 +275,7 @@ def setup_supplier(): frappe.get_doc({ "doctype": "Supplier", "supplier_name": s, - "supplier_type": random.choice(["Services", "Raw Material"]), + "supplier_group": random.choice(["Services", "Raw Material"]), }).insert() def setup_warehouse(): diff --git a/erpnext/setup/setup_wizard/operations/install_fixtures.py b/erpnext/setup/setup_wizard/operations/install_fixtures.py index 8f761e5946..2c294af2a1 100644 --- a/erpnext/setup/setup_wizard/operations/install_fixtures.py +++ b/erpnext/setup/setup_wizard/operations/install_fixtures.py @@ -147,14 +147,14 @@ def install(country=None): {'doctype': 'Customer Group', 'customer_group_name': _('Non Profit'), 'is_group': 0, 'parent_customer_group': _('All Customer Groups')}, {'doctype': 'Customer Group', 'customer_group_name': _('Government'), 'is_group': 0, 'parent_customer_group': _('All Customer Groups')}, - # supplier type - {'doctype': 'Supplier Type', 'supplier_type': _('Services')}, - {'doctype': 'Supplier Type', 'supplier_type': _('Local')}, - {'doctype': 'Supplier Type', 'supplier_type': _('Raw Material')}, - {'doctype': 'Supplier Type', 'supplier_type': _('Electrical')}, - {'doctype': 'Supplier Type', 'supplier_type': _('Hardware')}, - {'doctype': 'Supplier Type', 'supplier_type': _('Pharmaceutical')}, - {'doctype': 'Supplier Type', 'supplier_type': _('Distributor')}, + # supplier group + {'doctype': 'Supplier Group', 'supplier_group_name': _('Services')}, + {'doctype': 'Supplier Group', 'supplier_group_name': _('Local')}, + {'doctype': 'Supplier Group', 'supplier_group_name': _('Raw Material')}, + {'doctype': 'Supplier Group', 'supplier_group_name': _('Electrical')}, + {'doctype': 'Supplier Group', 'supplier_group_name': _('Hardware')}, + {'doctype': 'Supplier Group', 'supplier_group_name': _('Pharmaceutical')}, + {'doctype': 'Supplier Group', 'supplier_group_name': _('Distributor')}, # Sales Person {'doctype': 'Sales Person', 'sales_person_name': _('Sales Team'), 'is_group': 1, "parent_sales_person": ""}, diff --git a/erpnext/startup/report_data_map.py b/erpnext/startup/report_data_map.py index daf6fdd3bd..3720017804 100644 --- a/erpnext/startup/report_data_map.py +++ b/erpnext/startup/report_data_map.py @@ -208,14 +208,14 @@ data_map = { }, "Supplier": { "columns": ["name", "if(supplier_name=name, '', supplier_name) as supplier_name", - "supplier_type as parent_supplier_type"], + "supplier_group as parent_supplier_group"], "conditions": ["docstatus < 2"], "order_by": "name", "links": { - "parent_supplier_type": ["Supplier Type", "name"], + "parent_supplier_group": ["Supplier Group", "name"], } }, - "Supplier Type": { + "Supplier Group": { "columns": ["name"], "conditions": ["docstatus < 2"], "order_by": "name" diff --git a/erpnext/utilities/user_progress_utils.py b/erpnext/utilities/user_progress_utils.py index 5bd855f719..20e533e91a 100644 --- a/erpnext/utilities/user_progress_utils.py +++ b/erpnext/utilities/user_progress_utils.py @@ -63,7 +63,7 @@ def create_suppliers(args_data): doc = frappe.get_doc({ "doctype":"Supplier", "supplier_name": supplier, - "supplier_type": _("Local"), + "supplier_group": _("Local"), "company": defaults.get("company") }).insert()