Merge pull request #1755 from nabinhait/v4-hotfix
Fixes in trends report
diff --git a/erpnext/config/selling.py b/erpnext/config/selling.py
index bb70ac9..a332bc4 100644
--- a/erpnext/config/selling.py
+++ b/erpnext/config/selling.py
@@ -245,7 +245,7 @@
{
"type": "report",
"is_query_report": True,
- "name": "Quotation Trend",
+ "name": "Quotation Trends",
"doctype": "Quotation"
},
{
diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py
index 4567dd7..3af8290 100644
--- a/erpnext/controllers/accounts_controller.py
+++ b/erpnext/controllers/accounts_controller.py
@@ -12,7 +12,8 @@
class AccountsController(TransactionBase):
def validate(self):
- self.set_missing_values(for_validate=True)
+ if self._action != "update_after_submit":
+ self.set_missing_values(for_validate=True)
self.validate_date_with_fiscal_year()
if self.meta.get_field("currency"):
self.calculate_taxes_and_totals()
diff --git a/erpnext/controllers/trends.py b/erpnext/controllers/trends.py
index 2c3483c..7ef9100 100644
--- a/erpnext/controllers/trends.py
+++ b/erpnext/controllers/trends.py
@@ -10,9 +10,9 @@
validate_filters(filters)
# get conditions for based_on filter cond
- based_on_details = based_wise_colums_query(filters.get("based_on"), trans)
+ based_on_details = based_wise_columns_query(filters.get("based_on"), trans)
# get conditions for periodic filter cond
- period_cols, period_select = period_wise_colums_query(filters, trans)
+ period_cols, period_select = period_wise_columns_query(filters, trans)
# get conditions for grouping filter cond
group_by_cols = group_wise_column(filters.get("group_by"))
@@ -115,7 +115,7 @@
def get_mon(dt):
return getdate(dt).strftime("%b")
-def period_wise_colums_query(filters, trans):
+def period_wise_columns_query(filters, trans):
query_details = ''
pwc = []
bet_dates = get_period_date_ranges(filters.get("period"), filters.get("fiscal_year"))
@@ -132,9 +132,9 @@
else:
pwc = [filters.get("fiscal_year") + " (Qty):Float:120",
filters.get("fiscal_year") + " (Amt):Currency:120"]
- query_details = " SUM(t2.qty), SUM(t1.grand_total),"
+ query_details = " SUM(t2.qty), SUM(t2.base_amount),"
- query_details += 'SUM(t2.qty), SUM(t1.grand_total)'
+ query_details += 'SUM(t2.qty), SUM(t2.base_amount)'
return pwc, query_details
def get_period_wise_columns(bet_dates, period, pwc):
@@ -147,7 +147,7 @@
def get_period_wise_query(bet_dates, trans_date, query_details):
query_details += """SUM(IF(t1.%(trans_date)s BETWEEN '%(sd)s' AND '%(ed)s', t2.qty, NULL)),
- SUM(IF(t1.%(trans_date)s BETWEEN '%(sd)s' AND '%(ed)s', t1.grand_total, NULL)),
+ SUM(IF(t1.%(trans_date)s BETWEEN '%(sd)s' AND '%(ed)s', t2.base_amount, NULL)),
""" % {"trans_date": trans_date, "sd": bet_dates[0],"ed": bet_dates[1]}
return query_details
@@ -191,7 +191,7 @@
return period_month_ranges
-def based_wise_colums_query(based_on, trans):
+def based_wise_columns_query(based_on, trans):
based_on_details = {}
# based_on_cols, based_on_select, based_on_group_by, addl_tables
diff --git a/erpnext/public/js/purchase_trends_filters.js b/erpnext/public/js/purchase_trends_filters.js
index 168b9ad..d60b915 100644
--- a/erpnext/public/js/purchase_trends_filters.js
+++ b/erpnext/public/js/purchase_trends_filters.js
@@ -21,7 +21,7 @@
"fieldname":"group_by",
"label": __("Group By"),
"fieldtype": "Select",
- "options": ["Item", "Supplier"].join("\n"),
+ "options": ["", "Item", "Supplier"].join("\n"),
"default": ""
},
{
@@ -39,4 +39,4 @@
"default": frappe.defaults.get_user_default("company")
},
];
-}
\ No newline at end of file
+}
diff --git a/erpnext/public/js/sales_trends_filters.js b/erpnext/public/js/sales_trends_filters.js
index a1254c1..89c269e 100644
--- a/erpnext/public/js/sales_trends_filters.js
+++ b/erpnext/public/js/sales_trends_filters.js
@@ -21,7 +21,7 @@
"fieldname":"group_by",
"label": __("Group By"),
"fieldtype": "Select",
- "options": ["Item", "Customer"].join("\n"),
+ "options": ["", "Item", "Customer"].join("\n"),
"default": ""
},
{
@@ -37,6 +37,6 @@
"fieldtype": "Link",
"options": "Company",
"default": frappe.defaults.get_user_default("company")
- },
+ },
];
-}
\ No newline at end of file
+}