mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-27 00:44:45 +00:00
style: bulk format code with black
v13 port because otherwise backports will result in conflicts always
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
|
||||
# ERPNext - web based ERP (http://erpnext.com)
|
||||
# Copyright (C) 2012 Frappe Technologies Pvt Ltd
|
||||
#
|
||||
@@ -18,7 +17,4 @@
|
||||
# default settings that can be made for a user.
|
||||
|
||||
product_name = "ERPNext"
|
||||
user_defaults = {
|
||||
"Company": "company",
|
||||
"Territory": "territory"
|
||||
}
|
||||
user_defaults = {"Company": "company", "Territory": "territory"}
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
# License: GNU General Public License v3. See license.txt"
|
||||
|
||||
|
||||
|
||||
import frappe
|
||||
from frappe.utils import cint
|
||||
|
||||
@@ -10,69 +9,72 @@ from frappe.utils import cint
|
||||
def boot_session(bootinfo):
|
||||
"""boot session - send website info if guest"""
|
||||
|
||||
bootinfo.custom_css = frappe.db.get_value('Style Settings', None, 'custom_css') or ''
|
||||
bootinfo.custom_css = frappe.db.get_value("Style Settings", None, "custom_css") or ""
|
||||
|
||||
if frappe.session['user']!='Guest':
|
||||
if frappe.session["user"] != "Guest":
|
||||
update_page_info(bootinfo)
|
||||
|
||||
load_country_and_currency(bootinfo)
|
||||
bootinfo.sysdefaults.territory = frappe.db.get_single_value('Selling Settings',
|
||||
'territory')
|
||||
bootinfo.sysdefaults.customer_group = frappe.db.get_single_value('Selling Settings',
|
||||
'customer_group')
|
||||
bootinfo.sysdefaults.allow_stale = cint(frappe.db.get_single_value('Accounts Settings',
|
||||
'allow_stale'))
|
||||
bootinfo.sysdefaults.quotation_valid_till = cint(frappe.db.get_single_value('Selling Settings',
|
||||
'default_valid_till'))
|
||||
bootinfo.sysdefaults.territory = frappe.db.get_single_value("Selling Settings", "territory")
|
||||
bootinfo.sysdefaults.customer_group = frappe.db.get_single_value(
|
||||
"Selling Settings", "customer_group"
|
||||
)
|
||||
bootinfo.sysdefaults.allow_stale = cint(
|
||||
frappe.db.get_single_value("Accounts Settings", "allow_stale")
|
||||
)
|
||||
bootinfo.sysdefaults.quotation_valid_till = cint(
|
||||
frappe.db.get_single_value("Selling Settings", "default_valid_till")
|
||||
)
|
||||
|
||||
# if no company, show a dialog box to create a new company
|
||||
bootinfo.customer_count = frappe.db.sql("""SELECT count(*) FROM `tabCustomer`""")[0][0]
|
||||
|
||||
if not bootinfo.customer_count:
|
||||
bootinfo.setup_complete = frappe.db.sql("""SELECT `name`
|
||||
bootinfo.setup_complete = (
|
||||
frappe.db.sql(
|
||||
"""SELECT `name`
|
||||
FROM `tabCompany`
|
||||
LIMIT 1""") and 'Yes' or 'No'
|
||||
LIMIT 1"""
|
||||
)
|
||||
and "Yes"
|
||||
or "No"
|
||||
)
|
||||
|
||||
bootinfo.docs += frappe.db.sql("""select name, default_currency, cost_center, default_selling_terms, default_buying_terms,
|
||||
bootinfo.docs += frappe.db.sql(
|
||||
"""select name, default_currency, cost_center, default_selling_terms, default_buying_terms,
|
||||
default_letter_head, default_bank_account, enable_perpetual_inventory, country from `tabCompany`""",
|
||||
as_dict=1, update={"doctype":":Company"})
|
||||
as_dict=1,
|
||||
update={"doctype": ":Company"},
|
||||
)
|
||||
|
||||
party_account_types = frappe.db.sql(""" select name, ifnull(account_type, '') from `tabParty Type`""")
|
||||
party_account_types = frappe.db.sql(
|
||||
""" select name, ifnull(account_type, '') from `tabParty Type`"""
|
||||
)
|
||||
bootinfo.party_account_types = frappe._dict(party_account_types)
|
||||
|
||||
|
||||
def load_country_and_currency(bootinfo):
|
||||
country = frappe.db.get_default("country")
|
||||
if country and frappe.db.exists("Country", country):
|
||||
bootinfo.docs += [frappe.get_doc("Country", country)]
|
||||
|
||||
bootinfo.docs += frappe.db.sql("""select name, fraction, fraction_units,
|
||||
bootinfo.docs += frappe.db.sql(
|
||||
"""select name, fraction, fraction_units,
|
||||
number_format, smallest_currency_fraction_value, symbol from tabCurrency
|
||||
where enabled=1""", as_dict=1, update={"doctype":":Currency"})
|
||||
where enabled=1""",
|
||||
as_dict=1,
|
||||
update={"doctype": ":Currency"},
|
||||
)
|
||||
|
||||
|
||||
def update_page_info(bootinfo):
|
||||
bootinfo.page_info.update({
|
||||
"Chart of Accounts": {
|
||||
"title": "Chart of Accounts",
|
||||
"route": "Tree/Account"
|
||||
},
|
||||
"Chart of Cost Centers": {
|
||||
"title": "Chart of Cost Centers",
|
||||
"route": "Tree/Cost Center"
|
||||
},
|
||||
"Item Group Tree": {
|
||||
"title": "Item Group Tree",
|
||||
"route": "Tree/Item Group"
|
||||
},
|
||||
"Customer Group Tree": {
|
||||
"title": "Customer Group Tree",
|
||||
"route": "Tree/Customer Group"
|
||||
},
|
||||
"Territory Tree": {
|
||||
"title": "Territory Tree",
|
||||
"route": "Tree/Territory"
|
||||
},
|
||||
"Sales Person Tree": {
|
||||
"title": "Sales Person Tree",
|
||||
"route": "Tree/Sales Person"
|
||||
bootinfo.page_info.update(
|
||||
{
|
||||
"Chart of Accounts": {"title": "Chart of Accounts", "route": "Tree/Account"},
|
||||
"Chart of Cost Centers": {"title": "Chart of Cost Centers", "route": "Tree/Cost Center"},
|
||||
"Item Group Tree": {"title": "Item Group Tree", "route": "Tree/Item Group"},
|
||||
"Customer Group Tree": {"title": "Customer Group Tree", "route": "Tree/Customer Group"},
|
||||
"Territory Tree": {"title": "Territory Tree", "route": "Tree/Territory"},
|
||||
"Sales Person Tree": {"title": "Sales Person Tree", "route": "Tree/Sales Person"},
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
|
||||
|
||||
|
||||
def get_filters_config():
|
||||
filters_config = {
|
||||
"fiscal year": {
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
|
||||
|
||||
import frappe
|
||||
from frappe.utils import cint
|
||||
|
||||
@@ -8,66 +6,66 @@ def get_leaderboards():
|
||||
leaderboards = {
|
||||
"Customer": {
|
||||
"fields": [
|
||||
{'fieldname': 'total_sales_amount', 'fieldtype': 'Currency'},
|
||||
'total_qty_sold',
|
||||
{'fieldname': 'outstanding_amount', 'fieldtype': 'Currency'}
|
||||
{"fieldname": "total_sales_amount", "fieldtype": "Currency"},
|
||||
"total_qty_sold",
|
||||
{"fieldname": "outstanding_amount", "fieldtype": "Currency"},
|
||||
],
|
||||
"method": "erpnext.startup.leaderboard.get_all_customers",
|
||||
"icon": "customer"
|
||||
"icon": "customer",
|
||||
},
|
||||
"Item": {
|
||||
"fields": [
|
||||
{'fieldname': 'total_sales_amount', 'fieldtype': 'Currency'},
|
||||
'total_qty_sold',
|
||||
{'fieldname': 'total_purchase_amount', 'fieldtype': 'Currency'},
|
||||
'total_qty_purchased',
|
||||
'available_stock_qty',
|
||||
{'fieldname': 'available_stock_value', 'fieldtype': 'Currency'}
|
||||
{"fieldname": "total_sales_amount", "fieldtype": "Currency"},
|
||||
"total_qty_sold",
|
||||
{"fieldname": "total_purchase_amount", "fieldtype": "Currency"},
|
||||
"total_qty_purchased",
|
||||
"available_stock_qty",
|
||||
{"fieldname": "available_stock_value", "fieldtype": "Currency"},
|
||||
],
|
||||
"method": "erpnext.startup.leaderboard.get_all_items",
|
||||
"icon": "stock"
|
||||
"icon": "stock",
|
||||
},
|
||||
"Supplier": {
|
||||
"fields": [
|
||||
{'fieldname': 'total_purchase_amount', 'fieldtype': 'Currency'},
|
||||
'total_qty_purchased',
|
||||
{'fieldname': 'outstanding_amount', 'fieldtype': 'Currency'}
|
||||
{"fieldname": "total_purchase_amount", "fieldtype": "Currency"},
|
||||
"total_qty_purchased",
|
||||
{"fieldname": "outstanding_amount", "fieldtype": "Currency"},
|
||||
],
|
||||
"method": "erpnext.startup.leaderboard.get_all_suppliers",
|
||||
"icon": "buying"
|
||||
"icon": "buying",
|
||||
},
|
||||
"Sales Partner": {
|
||||
"fields": [
|
||||
{'fieldname': 'total_sales_amount', 'fieldtype': 'Currency'},
|
||||
{'fieldname': 'total_commission', 'fieldtype': 'Currency'}
|
||||
{"fieldname": "total_sales_amount", "fieldtype": "Currency"},
|
||||
{"fieldname": "total_commission", "fieldtype": "Currency"},
|
||||
],
|
||||
"method": "erpnext.startup.leaderboard.get_all_sales_partner",
|
||||
"icon": "hr"
|
||||
"icon": "hr",
|
||||
},
|
||||
"Sales Person": {
|
||||
"fields": [
|
||||
{'fieldname': 'total_sales_amount', 'fieldtype': 'Currency'}
|
||||
],
|
||||
"fields": [{"fieldname": "total_sales_amount", "fieldtype": "Currency"}],
|
||||
"method": "erpnext.startup.leaderboard.get_all_sales_person",
|
||||
"icon": "customer"
|
||||
}
|
||||
"icon": "customer",
|
||||
},
|
||||
}
|
||||
|
||||
return leaderboards
|
||||
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_all_customers(date_range, company, field, limit = None):
|
||||
def get_all_customers(date_range, company, field, limit=None):
|
||||
if field == "outstanding_amount":
|
||||
filters = [['docstatus', '=', '1'], ['company', '=', company]]
|
||||
filters = [["docstatus", "=", "1"], ["company", "=", company]]
|
||||
if date_range:
|
||||
date_range = frappe.parse_json(date_range)
|
||||
filters.append(['posting_date', '>=', 'between', [date_range[0], date_range[1]]])
|
||||
return frappe.db.get_all('Sales Invoice',
|
||||
fields = ['customer as name', 'sum(outstanding_amount) as value'],
|
||||
filters = filters,
|
||||
group_by = 'customer',
|
||||
order_by = 'value desc',
|
||||
limit = limit
|
||||
filters.append(["posting_date", ">=", "between", [date_range[0], date_range[1]]])
|
||||
return frappe.db.get_all(
|
||||
"Sales Invoice",
|
||||
fields=["customer as name", "sum(outstanding_amount) as value"],
|
||||
filters=filters,
|
||||
group_by="customer",
|
||||
order_by="value desc",
|
||||
limit=limit,
|
||||
)
|
||||
else:
|
||||
if field == "total_sales_amount":
|
||||
@@ -75,9 +73,10 @@ def get_all_customers(date_range, company, field, limit = None):
|
||||
elif field == "total_qty_sold":
|
||||
select_field = "sum(so_item.stock_qty)"
|
||||
|
||||
date_condition = get_date_condition(date_range, 'so.transaction_date')
|
||||
date_condition = get_date_condition(date_range, "so.transaction_date")
|
||||
|
||||
return frappe.db.sql("""
|
||||
return frappe.db.sql(
|
||||
"""
|
||||
select so.customer as name, {0} as value
|
||||
FROM `tabSales Order` as so JOIN `tabSales Order Item` as so_item
|
||||
ON so.name = so_item.parent
|
||||
@@ -85,17 +84,24 @@ def get_all_customers(date_range, company, field, limit = None):
|
||||
group by so.customer
|
||||
order by value DESC
|
||||
limit %s
|
||||
""".format(select_field, date_condition), (company, cint(limit)), as_dict=1)
|
||||
""".format(
|
||||
select_field, date_condition
|
||||
),
|
||||
(company, cint(limit)),
|
||||
as_dict=1,
|
||||
)
|
||||
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_all_items(date_range, company, field, limit = None):
|
||||
def get_all_items(date_range, company, field, limit=None):
|
||||
if field in ("available_stock_qty", "available_stock_value"):
|
||||
select_field = "sum(actual_qty)" if field=="available_stock_qty" else "sum(stock_value)"
|
||||
return frappe.db.get_all('Bin',
|
||||
fields = ['item_code as name', '{0} as value'.format(select_field)],
|
||||
group_by = 'item_code',
|
||||
order_by = 'value desc',
|
||||
limit = limit
|
||||
select_field = "sum(actual_qty)" if field == "available_stock_qty" else "sum(stock_value)"
|
||||
return frappe.db.get_all(
|
||||
"Bin",
|
||||
fields=["item_code as name", "{0} as value".format(select_field)],
|
||||
group_by="item_code",
|
||||
order_by="value desc",
|
||||
limit=limit,
|
||||
)
|
||||
else:
|
||||
if field == "total_sales_amount":
|
||||
@@ -111,9 +117,10 @@ def get_all_items(date_range, company, field, limit = None):
|
||||
select_field = "sum(order_item.stock_qty)"
|
||||
select_doctype = "Purchase Order"
|
||||
|
||||
date_condition = get_date_condition(date_range, 'sales_order.transaction_date')
|
||||
date_condition = get_date_condition(date_range, "sales_order.transaction_date")
|
||||
|
||||
return frappe.db.sql("""
|
||||
return frappe.db.sql(
|
||||
"""
|
||||
select order_item.item_code as name, {0} as value
|
||||
from `tab{1}` sales_order join `tab{1} Item` as order_item
|
||||
on sales_order.name = order_item.parent
|
||||
@@ -122,21 +129,28 @@ def get_all_items(date_range, company, field, limit = None):
|
||||
group by order_item.item_code
|
||||
order by value desc
|
||||
limit %s
|
||||
""".format(select_field, select_doctype, date_condition), (company, cint(limit)), as_dict=1) #nosec
|
||||
""".format(
|
||||
select_field, select_doctype, date_condition
|
||||
),
|
||||
(company, cint(limit)),
|
||||
as_dict=1,
|
||||
) # nosec
|
||||
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_all_suppliers(date_range, company, field, limit = None):
|
||||
def get_all_suppliers(date_range, company, field, limit=None):
|
||||
if field == "outstanding_amount":
|
||||
filters = [['docstatus', '=', '1'], ['company', '=', company]]
|
||||
filters = [["docstatus", "=", "1"], ["company", "=", company]]
|
||||
if date_range:
|
||||
date_range = frappe.parse_json(date_range)
|
||||
filters.append(['posting_date', 'between', [date_range[0], date_range[1]]])
|
||||
return frappe.db.get_all('Purchase Invoice',
|
||||
fields = ['supplier as name', 'sum(outstanding_amount) as value'],
|
||||
filters = filters,
|
||||
group_by = 'supplier',
|
||||
order_by = 'value desc',
|
||||
limit = limit
|
||||
filters.append(["posting_date", "between", [date_range[0], date_range[1]]])
|
||||
return frappe.db.get_all(
|
||||
"Purchase Invoice",
|
||||
fields=["supplier as name", "sum(outstanding_amount) as value"],
|
||||
filters=filters,
|
||||
group_by="supplier",
|
||||
order_by="value desc",
|
||||
limit=limit,
|
||||
)
|
||||
else:
|
||||
if field == "total_purchase_amount":
|
||||
@@ -144,9 +158,10 @@ def get_all_suppliers(date_range, company, field, limit = None):
|
||||
elif field == "total_qty_purchased":
|
||||
select_field = "sum(purchase_order_item.stock_qty)"
|
||||
|
||||
date_condition = get_date_condition(date_range, 'purchase_order.modified')
|
||||
date_condition = get_date_condition(date_range, "purchase_order.modified")
|
||||
|
||||
return frappe.db.sql("""
|
||||
return frappe.db.sql(
|
||||
"""
|
||||
select purchase_order.supplier as name, {0} as value
|
||||
FROM `tabPurchase Order` as purchase_order LEFT JOIN `tabPurchase Order Item`
|
||||
as purchase_order_item ON purchase_order.name = purchase_order_item.parent
|
||||
@@ -156,34 +171,45 @@ def get_all_suppliers(date_range, company, field, limit = None):
|
||||
and purchase_order.company = %s
|
||||
group by purchase_order.supplier
|
||||
order by value DESC
|
||||
limit %s""".format(select_field, date_condition), (company, cint(limit)), as_dict=1) #nosec
|
||||
limit %s""".format(
|
||||
select_field, date_condition
|
||||
),
|
||||
(company, cint(limit)),
|
||||
as_dict=1,
|
||||
) # nosec
|
||||
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_all_sales_partner(date_range, company, field, limit = None):
|
||||
def get_all_sales_partner(date_range, company, field, limit=None):
|
||||
if field == "total_sales_amount":
|
||||
select_field = "sum(`base_net_total`)"
|
||||
elif field == "total_commission":
|
||||
select_field = "sum(`total_commission`)"
|
||||
|
||||
filters = {
|
||||
'sales_partner': ['!=', ''],
|
||||
'docstatus': 1,
|
||||
'company': company
|
||||
}
|
||||
filters = {"sales_partner": ["!=", ""], "docstatus": 1, "company": company}
|
||||
if date_range:
|
||||
date_range = frappe.parse_json(date_range)
|
||||
filters['transaction_date'] = ['between', [date_range[0], date_range[1]]]
|
||||
filters["transaction_date"] = ["between", [date_range[0], date_range[1]]]
|
||||
|
||||
return frappe.get_list(
|
||||
"Sales Order",
|
||||
fields=[
|
||||
"`sales_partner` as name",
|
||||
"{} as value".format(select_field),
|
||||
],
|
||||
filters=filters,
|
||||
group_by="sales_partner",
|
||||
order_by="value DESC",
|
||||
limit=limit,
|
||||
)
|
||||
|
||||
return frappe.get_list('Sales Order', fields=[
|
||||
'`sales_partner` as name',
|
||||
'{} as value'.format(select_field),
|
||||
], filters=filters, group_by='sales_partner', order_by='value DESC', limit=limit)
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_all_sales_person(date_range, company, field = None, limit = 0):
|
||||
date_condition = get_date_condition(date_range, 'sales_order.transaction_date')
|
||||
def get_all_sales_person(date_range, company, field=None, limit=0):
|
||||
date_condition = get_date_condition(date_range, "sales_order.transaction_date")
|
||||
|
||||
return frappe.db.sql("""
|
||||
return frappe.db.sql(
|
||||
"""
|
||||
select sales_team.sales_person as name, sum(sales_order.base_net_total) as value
|
||||
from `tabSales Order` as sales_order join `tabSales Team` as sales_team
|
||||
on sales_order.name = sales_team.parent and sales_team.parenttype = 'Sales Order'
|
||||
@@ -193,10 +219,16 @@ def get_all_sales_person(date_range, company, field = None, limit = 0):
|
||||
group by sales_team.sales_person
|
||||
order by value DESC
|
||||
limit %s
|
||||
""".format(date_condition=date_condition), (company, cint(limit)), as_dict=1)
|
||||
""".format(
|
||||
date_condition=date_condition
|
||||
),
|
||||
(company, cint(limit)),
|
||||
as_dict=1,
|
||||
)
|
||||
|
||||
|
||||
def get_date_condition(date_range, field):
|
||||
date_condition = ''
|
||||
date_condition = ""
|
||||
if date_range:
|
||||
date_range = frappe.parse_json(date_range)
|
||||
from_date, to_date = date_range
|
||||
|
||||
@@ -6,8 +6,8 @@ import frappe
|
||||
|
||||
|
||||
def get_notification_config():
|
||||
notifications = { "for_doctype":
|
||||
{
|
||||
notifications = {
|
||||
"for_doctype": {
|
||||
"Issue": {"status": "Open"},
|
||||
"Warranty Claim": {"status": "Open"},
|
||||
"Task": {"status": ("in", ("Open", "Overdue"))},
|
||||
@@ -16,66 +16,46 @@ def get_notification_config():
|
||||
"Contact": {"status": "Open"},
|
||||
"Opportunity": {"status": "Open"},
|
||||
"Quotation": {"docstatus": 0},
|
||||
"Sales Order": {
|
||||
"status": ("not in", ("Completed", "Closed")),
|
||||
"docstatus": ("<", 2)
|
||||
},
|
||||
"Sales Order": {"status": ("not in", ("Completed", "Closed")), "docstatus": ("<", 2)},
|
||||
"Journal Entry": {"docstatus": 0},
|
||||
"Sales Invoice": {
|
||||
"outstanding_amount": (">", 0),
|
||||
"docstatus": ("<", 2)
|
||||
},
|
||||
"Purchase Invoice": {
|
||||
"outstanding_amount": (">", 0),
|
||||
"docstatus": ("<", 2)
|
||||
},
|
||||
"Sales Invoice": {"outstanding_amount": (">", 0), "docstatus": ("<", 2)},
|
||||
"Purchase Invoice": {"outstanding_amount": (">", 0), "docstatus": ("<", 2)},
|
||||
"Payment Entry": {"docstatus": 0},
|
||||
"Leave Application": {"docstatus": 0},
|
||||
"Expense Claim": {"docstatus": 0},
|
||||
"Job Applicant": {"status": "Open"},
|
||||
"Delivery Note": {
|
||||
"status": ("not in", ("Completed", "Closed")),
|
||||
"docstatus": ("<", 2)
|
||||
},
|
||||
"Delivery Note": {"status": ("not in", ("Completed", "Closed")), "docstatus": ("<", 2)},
|
||||
"Stock Entry": {"docstatus": 0},
|
||||
"Material Request": {
|
||||
"docstatus": ("<", 2),
|
||||
"status": ("not in", ("Stopped",)),
|
||||
"per_ordered": ("<", 100)
|
||||
"per_ordered": ("<", 100),
|
||||
},
|
||||
"Request for Quotation": { "docstatus": 0 },
|
||||
"Request for Quotation": {"docstatus": 0},
|
||||
"Supplier Quotation": {"docstatus": 0},
|
||||
"Purchase Order": {
|
||||
"status": ("not in", ("Completed", "Closed")),
|
||||
"docstatus": ("<", 2)
|
||||
},
|
||||
"Purchase Receipt": {
|
||||
"status": ("not in", ("Completed", "Closed")),
|
||||
"docstatus": ("<", 2)
|
||||
},
|
||||
"Work Order": { "status": ("in", ("Draft", "Not Started", "In Process")) },
|
||||
"Purchase Order": {"status": ("not in", ("Completed", "Closed")), "docstatus": ("<", 2)},
|
||||
"Purchase Receipt": {"status": ("not in", ("Completed", "Closed")), "docstatus": ("<", 2)},
|
||||
"Work Order": {"status": ("in", ("Draft", "Not Started", "In Process"))},
|
||||
"BOM": {"docstatus": 0},
|
||||
|
||||
"Timesheet": {"status": "Draft"},
|
||||
|
||||
"Lab Test": {"docstatus": 0},
|
||||
"Sample Collection": {"docstatus": 0},
|
||||
"Patient Appointment": {"status": "Open"},
|
||||
"Patient Encounter": {"docstatus": 0}
|
||||
"Patient Encounter": {"docstatus": 0},
|
||||
},
|
||||
|
||||
"targets": {
|
||||
"Company": {
|
||||
"filters" : { "monthly_sales_target": ( ">", 0 ) },
|
||||
"target_field" : "monthly_sales_target",
|
||||
"value_field" : "total_monthly_sales"
|
||||
"filters": {"monthly_sales_target": (">", 0)},
|
||||
"target_field": "monthly_sales_target",
|
||||
"value_field": "total_monthly_sales",
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
doctype = [d for d in notifications.get('for_doctype')]
|
||||
for doc in frappe.get_all('DocType',
|
||||
fields= ["name"], filters = {"name": ("not in", doctype), 'is_submittable': 1}):
|
||||
doctype = [d for d in notifications.get("for_doctype")]
|
||||
for doc in frappe.get_all(
|
||||
"DocType", fields=["name"], filters={"name": ("not in", doctype), "is_submittable": 1}
|
||||
):
|
||||
notifications["for_doctype"][doc.name] = {"docstatus": 0}
|
||||
|
||||
return notifications
|
||||
|
||||
@@ -6,90 +6,98 @@
|
||||
# "remember to add indexes!"
|
||||
|
||||
data_map = {
|
||||
"Company": {
|
||||
"columns": ["name"],
|
||||
"conditions": ["docstatus < 2"]
|
||||
},
|
||||
"Company": {"columns": ["name"], "conditions": ["docstatus < 2"]},
|
||||
"Fiscal Year": {
|
||||
"columns": ["name", "year_start_date", "year_end_date"],
|
||||
"conditions": ["docstatus < 2"],
|
||||
},
|
||||
|
||||
# Accounts
|
||||
"Account": {
|
||||
"columns": ["name", "parent_account", "lft", "rgt", "report_type",
|
||||
"company", "is_group"],
|
||||
"columns": ["name", "parent_account", "lft", "rgt", "report_type", "company", "is_group"],
|
||||
"conditions": ["docstatus < 2"],
|
||||
"order_by": "lft",
|
||||
"links": {
|
||||
"company": ["Company", "name"],
|
||||
}
|
||||
|
||||
},
|
||||
},
|
||||
"Cost Center": {
|
||||
"columns": ["name", "lft", "rgt"],
|
||||
"conditions": ["docstatus < 2"],
|
||||
"order_by": "lft"
|
||||
"order_by": "lft",
|
||||
},
|
||||
"GL Entry": {
|
||||
"columns": ["name", "account", "posting_date", "cost_center", "debit", "credit",
|
||||
"is_opening", "company", "voucher_type", "voucher_no", "remarks"],
|
||||
"columns": [
|
||||
"name",
|
||||
"account",
|
||||
"posting_date",
|
||||
"cost_center",
|
||||
"debit",
|
||||
"credit",
|
||||
"is_opening",
|
||||
"company",
|
||||
"voucher_type",
|
||||
"voucher_no",
|
||||
"remarks",
|
||||
],
|
||||
"order_by": "posting_date, account",
|
||||
"links": {
|
||||
"account": ["Account", "name"],
|
||||
"company": ["Company", "name"],
|
||||
"cost_center": ["Cost Center", "name"]
|
||||
}
|
||||
"cost_center": ["Cost Center", "name"],
|
||||
},
|
||||
},
|
||||
|
||||
# Stock
|
||||
"Item": {
|
||||
"columns": ["name", "if(item_name=name, '', item_name) as item_name", "description",
|
||||
"item_group as parent_item_group", "stock_uom", "brand", "valuation_method"],
|
||||
"columns": [
|
||||
"name",
|
||||
"if(item_name=name, '', item_name) as item_name",
|
||||
"description",
|
||||
"item_group as parent_item_group",
|
||||
"stock_uom",
|
||||
"brand",
|
||||
"valuation_method",
|
||||
],
|
||||
# "conditions": ["docstatus < 2"],
|
||||
"order_by": "name",
|
||||
"links": {
|
||||
"parent_item_group": ["Item Group", "name"],
|
||||
"brand": ["Brand", "name"]
|
||||
}
|
||||
"links": {"parent_item_group": ["Item Group", "name"], "brand": ["Brand", "name"]},
|
||||
},
|
||||
"Item Group": {
|
||||
"columns": ["name", "parent_item_group"],
|
||||
# "conditions": ["docstatus < 2"],
|
||||
"order_by": "lft"
|
||||
},
|
||||
"Brand": {
|
||||
"columns": ["name"],
|
||||
"conditions": ["docstatus < 2"],
|
||||
"order_by": "name"
|
||||
},
|
||||
"Project": {
|
||||
"columns": ["name"],
|
||||
"conditions": ["docstatus < 2"],
|
||||
"order_by": "name"
|
||||
},
|
||||
"Warehouse": {
|
||||
"columns": ["name"],
|
||||
"conditions": ["docstatus < 2"],
|
||||
"order_by": "name"
|
||||
"order_by": "lft",
|
||||
},
|
||||
"Brand": {"columns": ["name"], "conditions": ["docstatus < 2"], "order_by": "name"},
|
||||
"Project": {"columns": ["name"], "conditions": ["docstatus < 2"], "order_by": "name"},
|
||||
"Warehouse": {"columns": ["name"], "conditions": ["docstatus < 2"], "order_by": "name"},
|
||||
"Stock Ledger Entry": {
|
||||
"columns": ["name", "posting_date", "posting_time", "item_code", "warehouse",
|
||||
"actual_qty as qty", "voucher_type", "voucher_no", "project",
|
||||
"incoming_rate as incoming_rate", "stock_uom", "serial_no",
|
||||
"qty_after_transaction", "valuation_rate"],
|
||||
"columns": [
|
||||
"name",
|
||||
"posting_date",
|
||||
"posting_time",
|
||||
"item_code",
|
||||
"warehouse",
|
||||
"actual_qty as qty",
|
||||
"voucher_type",
|
||||
"voucher_no",
|
||||
"project",
|
||||
"incoming_rate as incoming_rate",
|
||||
"stock_uom",
|
||||
"serial_no",
|
||||
"qty_after_transaction",
|
||||
"valuation_rate",
|
||||
],
|
||||
"order_by": "posting_date, posting_time, creation",
|
||||
"links": {
|
||||
"item_code": ["Item", "name"],
|
||||
"warehouse": ["Warehouse", "name"],
|
||||
"project": ["Project", "name"]
|
||||
"project": ["Project", "name"],
|
||||
},
|
||||
"force_index": "posting_sort_index"
|
||||
"force_index": "posting_sort_index",
|
||||
},
|
||||
"Serial No": {
|
||||
"columns": ["name", "purchase_rate as incoming_rate"],
|
||||
"conditions": ["docstatus < 2"],
|
||||
"order_by": "name"
|
||||
"order_by": "name",
|
||||
},
|
||||
"Stock Entry": {
|
||||
"columns": ["name", "purpose"],
|
||||
@@ -97,227 +105,223 @@ data_map = {
|
||||
"order_by": "posting_date, posting_time, name",
|
||||
},
|
||||
"Material Request Item": {
|
||||
"columns": ["item.name as name", "item_code", "warehouse",
|
||||
"(qty - ordered_qty) as qty"],
|
||||
"columns": ["item.name as name", "item_code", "warehouse", "(qty - ordered_qty) as qty"],
|
||||
"from": "`tabMaterial Request Item` item, `tabMaterial Request` main",
|
||||
"conditions": ["item.parent = main.name", "main.docstatus=1", "main.status != 'Stopped'",
|
||||
"ifnull(warehouse, '')!=''", "qty > ordered_qty"],
|
||||
"links": {
|
||||
"item_code": ["Item", "name"],
|
||||
"warehouse": ["Warehouse", "name"]
|
||||
},
|
||||
"conditions": [
|
||||
"item.parent = main.name",
|
||||
"main.docstatus=1",
|
||||
"main.status != 'Stopped'",
|
||||
"ifnull(warehouse, '')!=''",
|
||||
"qty > ordered_qty",
|
||||
],
|
||||
"links": {"item_code": ["Item", "name"], "warehouse": ["Warehouse", "name"]},
|
||||
},
|
||||
"Purchase Order Item": {
|
||||
"columns": ["item.name as name", "item_code", "warehouse",
|
||||
"(qty - received_qty)*conversion_factor as qty"],
|
||||
"columns": [
|
||||
"item.name as name",
|
||||
"item_code",
|
||||
"warehouse",
|
||||
"(qty - received_qty)*conversion_factor as qty",
|
||||
],
|
||||
"from": "`tabPurchase Order Item` item, `tabPurchase Order` main",
|
||||
"conditions": ["item.parent = main.name", "main.docstatus=1", "main.status != 'Stopped'",
|
||||
"ifnull(warehouse, '')!=''", "qty > received_qty"],
|
||||
"links": {
|
||||
"item_code": ["Item", "name"],
|
||||
"warehouse": ["Warehouse", "name"]
|
||||
},
|
||||
"conditions": [
|
||||
"item.parent = main.name",
|
||||
"main.docstatus=1",
|
||||
"main.status != 'Stopped'",
|
||||
"ifnull(warehouse, '')!=''",
|
||||
"qty > received_qty",
|
||||
],
|
||||
"links": {"item_code": ["Item", "name"], "warehouse": ["Warehouse", "name"]},
|
||||
},
|
||||
|
||||
"Sales Order Item": {
|
||||
"columns": ["item.name as name", "item_code", "(qty - delivered_qty)*conversion_factor as qty", "warehouse"],
|
||||
"columns": [
|
||||
"item.name as name",
|
||||
"item_code",
|
||||
"(qty - delivered_qty)*conversion_factor as qty",
|
||||
"warehouse",
|
||||
],
|
||||
"from": "`tabSales Order Item` item, `tabSales Order` main",
|
||||
"conditions": ["item.parent = main.name", "main.docstatus=1", "main.status != 'Stopped'",
|
||||
"ifnull(warehouse, '')!=''", "qty > delivered_qty"],
|
||||
"links": {
|
||||
"item_code": ["Item", "name"],
|
||||
"warehouse": ["Warehouse", "name"]
|
||||
},
|
||||
"conditions": [
|
||||
"item.parent = main.name",
|
||||
"main.docstatus=1",
|
||||
"main.status != 'Stopped'",
|
||||
"ifnull(warehouse, '')!=''",
|
||||
"qty > delivered_qty",
|
||||
],
|
||||
"links": {"item_code": ["Item", "name"], "warehouse": ["Warehouse", "name"]},
|
||||
},
|
||||
|
||||
# Sales
|
||||
"Customer": {
|
||||
"columns": ["name", "if(customer_name=name, '', customer_name) as customer_name",
|
||||
"customer_group as parent_customer_group", "territory as parent_territory"],
|
||||
"columns": [
|
||||
"name",
|
||||
"if(customer_name=name, '', customer_name) as customer_name",
|
||||
"customer_group as parent_customer_group",
|
||||
"territory as parent_territory",
|
||||
],
|
||||
"conditions": ["docstatus < 2"],
|
||||
"order_by": "name",
|
||||
"links": {
|
||||
"parent_customer_group": ["Customer Group", "name"],
|
||||
"parent_territory": ["Territory", "name"],
|
||||
}
|
||||
},
|
||||
},
|
||||
"Customer Group": {
|
||||
"columns": ["name", "parent_customer_group"],
|
||||
"conditions": ["docstatus < 2"],
|
||||
"order_by": "lft"
|
||||
"order_by": "lft",
|
||||
},
|
||||
"Territory": {
|
||||
"columns": ["name", "parent_territory"],
|
||||
"conditions": ["docstatus < 2"],
|
||||
"order_by": "lft"
|
||||
"order_by": "lft",
|
||||
},
|
||||
"Sales Invoice": {
|
||||
"columns": ["name", "customer", "posting_date", "company"],
|
||||
"conditions": ["docstatus=1"],
|
||||
"order_by": "posting_date",
|
||||
"links": {
|
||||
"customer": ["Customer", "name"],
|
||||
"company":["Company", "name"]
|
||||
}
|
||||
"links": {"customer": ["Customer", "name"], "company": ["Company", "name"]},
|
||||
},
|
||||
"Sales Invoice Item": {
|
||||
"columns": ["name", "parent", "item_code", "stock_qty as qty", "base_net_amount"],
|
||||
"conditions": ["docstatus=1", "ifnull(parent, '')!=''"],
|
||||
"order_by": "parent",
|
||||
"links": {
|
||||
"parent": ["Sales Invoice", "name"],
|
||||
"item_code": ["Item", "name"]
|
||||
}
|
||||
"links": {"parent": ["Sales Invoice", "name"], "item_code": ["Item", "name"]},
|
||||
},
|
||||
"Sales Order": {
|
||||
"columns": ["name", "customer", "transaction_date as posting_date", "company"],
|
||||
"conditions": ["docstatus=1"],
|
||||
"order_by": "transaction_date",
|
||||
"links": {
|
||||
"customer": ["Customer", "name"],
|
||||
"company":["Company", "name"]
|
||||
}
|
||||
"links": {"customer": ["Customer", "name"], "company": ["Company", "name"]},
|
||||
},
|
||||
"Sales Order Item[Sales Analytics]": {
|
||||
"columns": ["name", "parent", "item_code", "stock_qty as qty", "base_net_amount"],
|
||||
"conditions": ["docstatus=1", "ifnull(parent, '')!=''"],
|
||||
"order_by": "parent",
|
||||
"links": {
|
||||
"parent": ["Sales Order", "name"],
|
||||
"item_code": ["Item", "name"]
|
||||
}
|
||||
"links": {"parent": ["Sales Order", "name"], "item_code": ["Item", "name"]},
|
||||
},
|
||||
"Delivery Note": {
|
||||
"columns": ["name", "customer", "posting_date", "company"],
|
||||
"conditions": ["docstatus=1"],
|
||||
"order_by": "posting_date",
|
||||
"links": {
|
||||
"customer": ["Customer", "name"],
|
||||
"company":["Company", "name"]
|
||||
}
|
||||
"links": {"customer": ["Customer", "name"], "company": ["Company", "name"]},
|
||||
},
|
||||
"Delivery Note Item[Sales Analytics]": {
|
||||
"columns": ["name", "parent", "item_code", "stock_qty as qty", "base_net_amount"],
|
||||
"conditions": ["docstatus=1", "ifnull(parent, '')!=''"],
|
||||
"order_by": "parent",
|
||||
"links": {
|
||||
"parent": ["Delivery Note", "name"],
|
||||
"item_code": ["Item", "name"]
|
||||
}
|
||||
"links": {"parent": ["Delivery Note", "name"], "item_code": ["Item", "name"]},
|
||||
},
|
||||
"Supplier": {
|
||||
"columns": ["name", "if(supplier_name=name, '', supplier_name) as supplier_name",
|
||||
"supplier_group as parent_supplier_group"],
|
||||
"columns": [
|
||||
"name",
|
||||
"if(supplier_name=name, '', supplier_name) as supplier_name",
|
||||
"supplier_group as parent_supplier_group",
|
||||
],
|
||||
"conditions": ["docstatus < 2"],
|
||||
"order_by": "name",
|
||||
"links": {
|
||||
"parent_supplier_group": ["Supplier Group", "name"],
|
||||
}
|
||||
},
|
||||
},
|
||||
"Supplier Group": {
|
||||
"columns": ["name", "parent_supplier_group"],
|
||||
"conditions": ["docstatus < 2"],
|
||||
"order_by": "name"
|
||||
"order_by": "name",
|
||||
},
|
||||
"Purchase Invoice": {
|
||||
"columns": ["name", "supplier", "posting_date", "company"],
|
||||
"conditions": ["docstatus=1"],
|
||||
"order_by": "posting_date",
|
||||
"links": {
|
||||
"supplier": ["Supplier", "name"],
|
||||
"company":["Company", "name"]
|
||||
}
|
||||
"links": {"supplier": ["Supplier", "name"], "company": ["Company", "name"]},
|
||||
},
|
||||
"Purchase Invoice Item": {
|
||||
"columns": ["name", "parent", "item_code", "stock_qty as qty", "base_net_amount"],
|
||||
"conditions": ["docstatus=1", "ifnull(parent, '')!=''"],
|
||||
"order_by": "parent",
|
||||
"links": {
|
||||
"parent": ["Purchase Invoice", "name"],
|
||||
"item_code": ["Item", "name"]
|
||||
}
|
||||
"links": {"parent": ["Purchase Invoice", "name"], "item_code": ["Item", "name"]},
|
||||
},
|
||||
"Purchase Order": {
|
||||
"columns": ["name", "supplier", "transaction_date as posting_date", "company"],
|
||||
"conditions": ["docstatus=1"],
|
||||
"order_by": "posting_date",
|
||||
"links": {
|
||||
"supplier": ["Supplier", "name"],
|
||||
"company":["Company", "name"]
|
||||
}
|
||||
"links": {"supplier": ["Supplier", "name"], "company": ["Company", "name"]},
|
||||
},
|
||||
"Purchase Order Item[Purchase Analytics]": {
|
||||
"columns": ["name", "parent", "item_code", "stock_qty as qty", "base_net_amount"],
|
||||
"conditions": ["docstatus=1", "ifnull(parent, '')!=''"],
|
||||
"order_by": "parent",
|
||||
"links": {
|
||||
"parent": ["Purchase Order", "name"],
|
||||
"item_code": ["Item", "name"]
|
||||
}
|
||||
"links": {"parent": ["Purchase Order", "name"], "item_code": ["Item", "name"]},
|
||||
},
|
||||
"Purchase Receipt": {
|
||||
"columns": ["name", "supplier", "posting_date", "company"],
|
||||
"conditions": ["docstatus=1"],
|
||||
"order_by": "posting_date",
|
||||
"links": {
|
||||
"supplier": ["Supplier", "name"],
|
||||
"company":["Company", "name"]
|
||||
}
|
||||
"links": {"supplier": ["Supplier", "name"], "company": ["Company", "name"]},
|
||||
},
|
||||
"Purchase Receipt Item[Purchase Analytics]": {
|
||||
"columns": ["name", "parent", "item_code", "stock_qty as qty", "base_net_amount"],
|
||||
"conditions": ["docstatus=1", "ifnull(parent, '')!=''"],
|
||||
"order_by": "parent",
|
||||
"links": {
|
||||
"parent": ["Purchase Receipt", "name"],
|
||||
"item_code": ["Item", "name"]
|
||||
}
|
||||
"links": {"parent": ["Purchase Receipt", "name"], "item_code": ["Item", "name"]},
|
||||
},
|
||||
# Support
|
||||
"Issue": {
|
||||
"columns": ["name","status","creation","resolution_date","first_responded_on"],
|
||||
"columns": ["name", "status", "creation", "resolution_date", "first_responded_on"],
|
||||
"conditions": ["docstatus < 2"],
|
||||
"order_by": "creation"
|
||||
"order_by": "creation",
|
||||
},
|
||||
|
||||
# Manufacturing
|
||||
"Work Order": {
|
||||
"columns": ["name","status","creation","planned_start_date","planned_end_date","status","actual_start_date","actual_end_date", "modified"],
|
||||
"columns": [
|
||||
"name",
|
||||
"status",
|
||||
"creation",
|
||||
"planned_start_date",
|
||||
"planned_end_date",
|
||||
"status",
|
||||
"actual_start_date",
|
||||
"actual_end_date",
|
||||
"modified",
|
||||
],
|
||||
"conditions": ["docstatus = 1"],
|
||||
"order_by": "creation"
|
||||
"order_by": "creation",
|
||||
},
|
||||
|
||||
#Medical
|
||||
# Medical
|
||||
"Patient": {
|
||||
"columns": ["name", "creation", "owner", "if(patient_name=name, '', patient_name) as patient_name"],
|
||||
"columns": [
|
||||
"name",
|
||||
"creation",
|
||||
"owner",
|
||||
"if(patient_name=name, '', patient_name) as patient_name",
|
||||
],
|
||||
"conditions": ["docstatus < 2"],
|
||||
"order_by": "name",
|
||||
"links": {
|
||||
"owner" : ["User", "name"]
|
||||
}
|
||||
"links": {"owner": ["User", "name"]},
|
||||
},
|
||||
"Patient Appointment": {
|
||||
"columns": ["name", "appointment_type", "patient", "practitioner", "appointment_date", "department", "status", "company"],
|
||||
"columns": [
|
||||
"name",
|
||||
"appointment_type",
|
||||
"patient",
|
||||
"practitioner",
|
||||
"appointment_date",
|
||||
"department",
|
||||
"status",
|
||||
"company",
|
||||
],
|
||||
"order_by": "name",
|
||||
"links": {
|
||||
"practitioner": ["Healthcare Practitioner", "name"],
|
||||
"appointment_type": ["Appointment Type", "name"]
|
||||
}
|
||||
"appointment_type": ["Appointment Type", "name"],
|
||||
},
|
||||
},
|
||||
"Healthcare Practitioner": {
|
||||
"columns": ["name", "department"],
|
||||
"order_by": "name",
|
||||
"links": {
|
||||
"department": ["Department", "name"],
|
||||
}
|
||||
|
||||
},
|
||||
},
|
||||
"Appointment Type": {
|
||||
"columns": ["name"],
|
||||
"order_by": "name"
|
||||
},
|
||||
"Medical Department": {
|
||||
"columns": ["name"],
|
||||
"order_by": "name"
|
||||
}
|
||||
"Appointment Type": {"columns": ["name"], "order_by": "name"},
|
||||
"Medical Department": {"columns": ["name"], "order_by": "name"},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user