config/utility level changes

This commit is contained in:
Zlash65 2018-04-19 18:37:29 +05:30
parent 0a50554417
commit 890707854d
10 changed files with 56 additions and 56 deletions

View File

@ -47,7 +47,7 @@ def _get_party_details(party=None, account=None, party_type="Customer", company=
set_contact_details(out, party, party_type) set_contact_details(out, party, party_type)
set_other_values(out, party, party_type) set_other_values(out, party, party_type)
set_price_list(out, party, party_type, price_list) 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) out["payment_terms_template"] = get_pyt_term_template(party.name, party_type, company)
if not out.get("currency"): if not out.get("currency"):
@ -105,7 +105,7 @@ def set_other_values(out, party, party_type):
if party_type=="Customer": if party_type=="Customer":
to_copy = ["customer_name", "customer_group", "territory", "language"] to_copy = ["customer_name", "customer_group", "territory", "language"]
else: else:
to_copy = ["supplier_name", "supplier_type", "language"] to_copy = ["supplier_name", "supplier_group", "language"]
for f in to_copy: for f in to_copy:
out[f] = party.get(f) 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): def get_party_account(party_type, party, company):
"""Returns the account for the given `party`. """Returns the account for the given `party`.
Will first search in party (Customer / Supplier) record, if not found, 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.""" finally will return default."""
if not company: if not company:
frappe.throw(_("Please select a 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") {"parenttype": party_type, "parent": party, "company": company}, "account")
if not account and party_type in ['Customer', 'Supplier']: 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)) group = frappe.db.get_value(party_type, party, scrub(party_group_doctype))
account = frappe.db.get_value("Party Account", account = frappe.db.get_value("Party Account",
{"parenttype": party_group_doctype, "parent": group, "company": company}, "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") due_date = get_due_date_from_template(template_name, posting_date, bill_date).strftime("%Y-%m-%d")
else: else:
if party_type == "Supplier": if party_type == "Supplier":
supplier_type = frappe.db.get_value(party_type, party, fieldname="supplier_type") supplier_group = frappe.db.get_value(party_type, party, fieldname="supplier_group")
template_name = frappe.db.get_value("Supplier Type", supplier_type, fieldname="payment_terms") template_name = frappe.db.get_value("Supplier Group", supplier_group, fieldname="payment_terms")
if template_name: if template_name:
due_date = get_due_date_from_template(template_name, posting_date, bill_date).strftime("%Y-%m-%d") 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 # 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))) .format(formatdate(default_due_date)))
@frappe.whitelist() @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): 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 from erpnext.accounts.doctype.tax_rule.tax_rule import get_tax_template, get_party_details
args = { args = {
@ -332,8 +332,8 @@ def set_taxes(party, party_type, posting_date, company, customer_group=None, sup
if customer_group: if customer_group:
args['customer_group'] = customer_group args['customer_group'] = customer_group
if supplier_type: if supplier_group:
args['supplier_type'] = supplier_type args['supplier_group'] = supplier_group
if billing_address or shipping_address: if billing_address or shipping_address:
args.update(get_party_details(party, party_type, {"billing_address": billing_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') customer.customer_group, fieldname='payment_terms')
else: else:
supplier = frappe.db.get_value("Supplier", party_name, 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 template = supplier.payment_terms
if not template and supplier.supplier_type: if not template and supplier.supplier_group:
template = frappe.db.get_value("Supplier Type", supplier.supplier_type, fieldname='payment_terms') template = frappe.db.get_value("Supplier Group", supplier.supplier_group, fieldname='payment_terms')
if not template and company: if not template and company:
template = frappe.db.get_value("Company", company, fieldname='payment_terms') template = frappe.db.get_value("Company", company, fieldname='payment_terms')

View File

@ -112,7 +112,7 @@ class ReceivablePayableReport(object):
_("Customer Group") + ":Link/Customer Group:120" _("Customer Group") + ":Link/Customer Group:120"
] ]
if args.get("party_type") == "Supplier": if args.get("party_type") == "Supplier":
columns += [_("Supplier Type") + ":Link/Supplier Type:80"] columns += [_("Supplier Group") + ":Link/Supplier Group:80"]
columns.append(_("Remarks") + "::200") columns.append(_("Remarks") + "::200")
@ -194,11 +194,11 @@ class ReceivablePayableReport(object):
# Delivery Note # Delivery Note
row += [voucher_details.get(gle.voucher_no, {}).get("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": if args.get("party_type") == "Customer":
row += [self.get_territory(gle.party), self.get_customer_group(gle.party)] row += [self.get_territory(gle.party), self.get_customer_group(gle.party)]
if args.get("party_type") == "Supplier": if args.get("party_type") == "Supplier":
row += [self.get_supplier_type(gle.party)] row += [self.get_supplier_group(gle.party)]
row.append(gle.remarks) row.append(gle.remarks)
data.append(row) data.append(row)
@ -260,15 +260,15 @@ class ReceivablePayableReport(object):
def get_customer_group(self, party_name): def get_customer_group(self, party_name):
return self.get_party_map("Customer").get(party_name, {}).get("customer_group") or "" return self.get_party_map("Customer").get(party_name, {}).get("customer_group") or ""
def get_supplier_type(self, party_name): def get_supplier_group(self, party_name):
return self.get_party_map("Supplier").get(party_name, {}).get("supplier_type") or "" return self.get_party_map("Supplier").get(party_name, {}).get("supplier_group") or ""
def get_party_map(self, party_type): def get_party_map(self, party_type):
if not hasattr(self, "party_map"): if not hasattr(self, "party_map"):
if party_type == "Customer": if party_type == "Customer":
select_fields = "name, customer_name, territory, customer_group" select_fields = "name, customer_name, territory, customer_group"
elif party_type == "Supplier": 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}`" 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))) .format(select_fields, party_type), as_dict=True)))

View File

@ -35,7 +35,7 @@ class AccountsReceivableSummary(ReceivablePayableReport):
_("Customer Group") + ":Link/Customer Group:120" _("Customer Group") + ":Link/Customer Group:120"
] ]
if args.get("party_type") == "Supplier": if args.get("party_type") == "Supplier":
columns += [_("Supplier Type") + ":Link/Supplier Type:80"] columns += [_("Supplier Group") + ":Link/Supplier Group:80"]
columns.append({ columns.append({
"fieldname": "currency", "fieldname": "currency",
@ -66,7 +66,7 @@ class AccountsReceivableSummary(ReceivablePayableReport):
if args.get("party_type") == "Customer": if args.get("party_type") == "Customer":
row += [self.get_territory(party), self.get_customer_group(party)] row += [self.get_territory(party), self.get_customer_group(party)]
if args.get("party_type") == "Supplier": if args.get("party_type") == "Supplier":
row += [self.get_supplier_type(party)] row += [self.get_supplier_group(party)]
row.append(party_dict.currency) row.append(party_dict.currency)
data.append(row) data.append(row)
@ -113,7 +113,7 @@ class AccountsReceivableSummary(ReceivablePayableReport):
"outstanding_amt", "age", "range1", "range2", "range3", "range4", "currency"] "outstanding_amt", "age", "range1", "range2", "range3", "range4", "currency"]
if args.get("party_type") == "Supplier": if args.get("party_type") == "Supplier":
cols += ["supplier_type", "remarks"] cols += ["supplier_group", "remarks"]
if args.get("party_type") == "Customer": if args.get("party_type") == "Customer":
cols += ["territory", "customer_group", "remarks"] cols += ["territory", "customer_group", "remarks"]

View File

@ -42,7 +42,7 @@ def _execute(filters=None, additional_table_columns=None, additional_query_colum
row.append(inv.get(col)) row.append(inv.get(col))
row += [ 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.tax_id, inv.credit_to, inv.mode_of_payment, ", ".join(project),
inv.bill_no, inv.bill_date, inv.remarks, inv.bill_no, inv.bill_date, inv.remarks,
", ".join(purchase_order), ", ".join(purchase_receipt), company_currency ", ".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 += additional_table_columns
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", _("Mode of Payment") + ":Link/Mode of Payment:80", _("Project") + ":Link/Project:80",
_("Bill No") + "::120", _("Bill Date") + ":Date:80", _("Remarks") + "::150", _("Bill No") + "::120", _("Bill Date") + ":Date:80", _("Remarks") + "::150",
_("Purchase Order") + ":Link/Purchase Order:100", _("Purchase Order") + ":Link/Purchase Order:100",
@ -229,8 +229,8 @@ def get_account_details(invoice_list):
def get_supplier_details(suppliers): def get_supplier_details(suppliers):
supplier_details = {} 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): 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 return supplier_details

View File

@ -19,7 +19,7 @@ erpnext.PurchaseAnalytics = frappe.views.TreeGridReport.extend({
title: __("Purchase Analytics"), title: __("Purchase Analytics"),
parent: $(wrapper).find('.layout-main'), parent: $(wrapper).find('.layout-main'),
page: wrapper.page, 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 Invoice", "Purchase Invoice Item",
"Purchase Order", "Purchase Order Item[Purchase Analytics]", "Purchase Order", "Purchase Order Item[Purchase Analytics]",
"Purchase Receipt", "Purchase Receipt Item[Purchase Analytics]"], "Purchase Receipt", "Purchase Receipt Item[Purchase Analytics]"],
@ -27,11 +27,11 @@ erpnext.PurchaseAnalytics = frappe.views.TreeGridReport.extend({
}); });
this.tree_grids = { this.tree_grids = {
"Supplier Type": { "Supplier Group": {
label: __("Supplier Type / Supplier"), label: __("Supplier Group / Supplier"),
show: true, show: true,
item_key: "supplier", item_key: "supplier",
parent_field: "parent_supplier_type", parent_field: "parent_supplier_group",
formatter: function(item) { formatter: function(item) {
return item.supplier_name ? item.supplier_name + " (" + item.name + ")" : item.name; return item.supplier_name ? item.supplier_name + " (" + item.name + ")" : item.name;
} }
@ -77,7 +77,7 @@ erpnext.PurchaseAnalytics = frappe.views.TreeGridReport.extend({
}, },
filters: [ filters: [
{fieldtype:"Select", label: __("Tree Type"), fieldname: "tree_type", {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) { filter: function(val, item, opts, me) {
return me.apply_zero_filter(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; var me = this;
if (!this.tl) { if (!this.tl) {
// add 'Not Set' Supplier & Item // add 'Not Set' Supplier & Item
// Add 'All Supplier Types' Supplier Type // Add 'All Supplier Groups' Supplier Group
// (Supplier / Item are not mandatory!!) // (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) { $.each(frappe.report_dump.data["Supplier Group"], function(i, v) {
v['parent_supplier_type'] = __("All Supplier Types") v['parent_supplier_group'] = __("All Supplier Groups")
}) })
frappe.report_dump.data["Supplier Type"] = [{ frappe.report_dump.data["Supplier Group"] = [{
name: __("All Supplier Types"), name: __("All Supplier Groups"),
id: "All Supplier Types", id: "All Supplier Groups",
}].concat(frappe.report_dump.data["Supplier Type"]); }].concat(frappe.report_dump.data["Supplier Group"]);
frappe.report_dump.data["Supplier"].push({ frappe.report_dump.data["Supplier"].push({
name: __("Not Set"), name: __("Not Set"),
parent_supplier_type: __("All Supplier Types"), parent_supplier_group: __("All Supplier Groups"),
id: "Not Set", id: "Not Set",
}); });
@ -144,8 +144,8 @@ erpnext.PurchaseAnalytics = frappe.views.TreeGridReport.extend({
if(!this.data || me.item_type != me.tree_type) { if(!this.data || me.item_type != me.tree_type) {
if(me.tree_type=='Supplier') { if(me.tree_type=='Supplier') {
var items = frappe.report_dump.data["Supplier"]; var items = frappe.report_dump.data["Supplier"];
} if(me.tree_type=='Supplier Type') { } if(me.tree_type=='Supplier Group') {
var items = this.prepare_tree("Supplier", "Supplier Type"); var items = this.prepare_tree("Supplier", "Supplier Group");
} else if(me.tree_type=="Item Group") { } else if(me.tree_type=="Item Group") {
var items = this.prepare_tree("Item", "Item Group"); var items = this.prepare_tree("Item", "Item Group");
} else if(me.tree_type=="Item") { } else if(me.tree_type=="Item") {

View File

@ -39,8 +39,8 @@ def get_data():
}, },
{ {
"type": "doctype", "type": "doctype",
"name": "Supplier Type", "name": "Supplier Group",
"description": _("Supplier Type master.") "description": _("Supplier Group master.")
}, },
{ {
"type": "doctype", "type": "doctype",

View File

@ -275,7 +275,7 @@ def setup_supplier():
frappe.get_doc({ frappe.get_doc({
"doctype": "Supplier", "doctype": "Supplier",
"supplier_name": s, "supplier_name": s,
"supplier_type": random.choice(["Services", "Raw Material"]), "supplier_group": random.choice(["Services", "Raw Material"]),
}).insert() }).insert()
def setup_warehouse(): def setup_warehouse():

View File

@ -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': _('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')}, {'doctype': 'Customer Group', 'customer_group_name': _('Government'), 'is_group': 0, 'parent_customer_group': _('All Customer Groups')},
# supplier type # supplier group
{'doctype': 'Supplier Type', 'supplier_type': _('Services')}, {'doctype': 'Supplier Group', 'supplier_group_name': _('Services')},
{'doctype': 'Supplier Type', 'supplier_type': _('Local')}, {'doctype': 'Supplier Group', 'supplier_group_name': _('Local')},
{'doctype': 'Supplier Type', 'supplier_type': _('Raw Material')}, {'doctype': 'Supplier Group', 'supplier_group_name': _('Raw Material')},
{'doctype': 'Supplier Type', 'supplier_type': _('Electrical')}, {'doctype': 'Supplier Group', 'supplier_group_name': _('Electrical')},
{'doctype': 'Supplier Type', 'supplier_type': _('Hardware')}, {'doctype': 'Supplier Group', 'supplier_group_name': _('Hardware')},
{'doctype': 'Supplier Type', 'supplier_type': _('Pharmaceutical')}, {'doctype': 'Supplier Group', 'supplier_group_name': _('Pharmaceutical')},
{'doctype': 'Supplier Type', 'supplier_type': _('Distributor')}, {'doctype': 'Supplier Group', 'supplier_group_name': _('Distributor')},
# Sales Person # Sales Person
{'doctype': 'Sales Person', 'sales_person_name': _('Sales Team'), 'is_group': 1, "parent_sales_person": ""}, {'doctype': 'Sales Person', 'sales_person_name': _('Sales Team'), 'is_group': 1, "parent_sales_person": ""},

View File

@ -208,14 +208,14 @@ data_map = {
}, },
"Supplier": { "Supplier": {
"columns": ["name", "if(supplier_name=name, '', supplier_name) as supplier_name", "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"], "conditions": ["docstatus < 2"],
"order_by": "name", "order_by": "name",
"links": { "links": {
"parent_supplier_type": ["Supplier Type", "name"], "parent_supplier_group": ["Supplier Group", "name"],
} }
}, },
"Supplier Type": { "Supplier Group": {
"columns": ["name"], "columns": ["name"],
"conditions": ["docstatus < 2"], "conditions": ["docstatus < 2"],
"order_by": "name" "order_by": "name"

View File

@ -63,7 +63,7 @@ def create_suppliers(args_data):
doc = frappe.get_doc({ doc = frappe.get_doc({
"doctype":"Supplier", "doctype":"Supplier",
"supplier_name": supplier, "supplier_name": supplier,
"supplier_type": _("Local"), "supplier_group": _("Local"),
"company": defaults.get("company") "company": defaults.get("company")
}).insert() }).insert()