Merge pull request #21513 from deepeshgarg007/get_period_api_v13
fix: get_period_list API change fixes
diff --git a/erpnext/accounts/report/consolidated_financial_statement/consolidated_financial_statement.py b/erpnext/accounts/report/consolidated_financial_statement/consolidated_financial_statement.py
index b62238b..c2c7207 100644
--- a/erpnext/accounts/report/consolidated_financial_statement/consolidated_financial_statement.py
+++ b/erpnext/accounts/report/consolidated_financial_statement/consolidated_financial_statement.py
@@ -84,6 +84,7 @@
def get_profit_loss_data(fiscal_year, companies, columns, filters):
income, expense, net_profit_loss = get_income_expense_data(companies, fiscal_year, filters)
+ company_currency = get_company_currency(filters)
data = []
data.extend(income or [])
@@ -93,7 +94,7 @@
chart = get_pl_chart_data(filters, columns, income, expense, net_profit_loss)
- report_summary = get_pl_summary(companies, '', income, expense, net_profit_loss, True)
+ report_summary = get_pl_summary(companies, '', income, expense, net_profit_loss, company_currency, True)
return data, None, chart, report_summary
diff --git a/erpnext/accounts/report/gross_profit/gross_profit.py b/erpnext/accounts/report/gross_profit/gross_profit.py
index 6ef6d6e..4e22b05 100644
--- a/erpnext/accounts/report/gross_profit/gross_profit.py
+++ b/erpnext/accounts/report/gross_profit/gross_profit.py
@@ -55,27 +55,27 @@
columns = []
column_map = frappe._dict({
"parent": _("Sales Invoice") + ":Link/Sales Invoice:120",
- "posting_date": _("Posting Date") + ":Date",
- "posting_time": _("Posting Time"),
- "item_code": _("Item Code") + ":Link/Item",
- "item_name": _("Item Name"),
- "item_group": _("Item Group") + ":Link/Item Group",
- "brand": _("Brand"),
- "description": _("Description"),
- "warehouse": _("Warehouse") + ":Link/Warehouse",
- "qty": _("Qty") + ":Float",
- "base_rate": _("Avg. Selling Rate") + ":Currency/currency",
- "buying_rate": _("Valuation Rate") + ":Currency/currency",
- "base_amount": _("Selling Amount") + ":Currency/currency",
- "buying_amount": _("Buying Amount") + ":Currency/currency",
- "gross_profit": _("Gross Profit") + ":Currency/currency",
- "gross_profit_percent": _("Gross Profit %") + ":Percent",
- "project": _("Project") + ":Link/Project",
+ "posting_date": _("Posting Date") + ":Date:100",
+ "posting_time": _("Posting Time") + ":Data:100",
+ "item_code": _("Item Code") + ":Link/Item:100",
+ "item_name": _("Item Name") + ":Data:100",
+ "item_group": _("Item Group") + ":Link/Item Group:100",
+ "brand": _("Brand") + ":Link/Brand:100",
+ "description": _("Description") +":Data:100",
+ "warehouse": _("Warehouse") + ":Link/Warehouse:100",
+ "qty": _("Qty") + ":Float:80",
+ "base_rate": _("Avg. Selling Rate") + ":Currency/currency:100",
+ "buying_rate": _("Valuation Rate") + ":Currency/currency:100",
+ "base_amount": _("Selling Amount") + ":Currency/currency:100",
+ "buying_amount": _("Buying Amount") + ":Currency/currency:100",
+ "gross_profit": _("Gross Profit") + ":Currency/currency:100",
+ "gross_profit_percent": _("Gross Profit %") + ":Percent:100",
+ "project": _("Project") + ":Link/Project:100",
"sales_person": _("Sales person"),
- "allocated_amount": _("Allocated Amount") + ":Currency/currency",
- "customer": _("Customer") + ":Link/Customer",
- "customer_group": _("Customer Group") + ":Link/Customer Group",
- "territory": _("Territory") + ":Link/Territory"
+ "allocated_amount": _("Allocated Amount") + ":Currency/currency:100",
+ "customer": _("Customer") + ":Link/Customer:100",
+ "customer_group": _("Customer Group") + ":Link/Customer Group:100",
+ "territory": _("Territory") + ":Link/Territory:100"
})
for col in group_wise_columns.get(scrub(filters.group_by)):
@@ -85,7 +85,8 @@
"fieldname": "currency",
"label" : _("Currency"),
"fieldtype": "Link",
- "options": "Currency"
+ "options": "Currency",
+ "hidden": 1
})
return columns
@@ -277,7 +278,7 @@
from `tabPurchase Invoice Item` a
where a.item_code = %s and a.docstatus=1
and modified <= %s
- order by a.modified desc limit 1""", (item_code,self.filters.to_date))
+ order by a.modified desc limit 1""", (item_code, self.filters.to_date))
else:
last_purchase_rate = frappe.db.sql("""
select (a.base_rate / a.conversion_factor)
diff --git a/erpnext/accounts/report/item_wise_purchase_register/item_wise_purchase_register.py b/erpnext/accounts/report/item_wise_purchase_register/item_wise_purchase_register.py
index 127f313..1f78c7a 100644
--- a/erpnext/accounts/report/item_wise_purchase_register/item_wise_purchase_register.py
+++ b/erpnext/accounts/report/item_wise_purchase_register/item_wise_purchase_register.py
@@ -102,7 +102,7 @@
data.append(row)
- if filters.get('group_by'):
+ if filters.get('group_by') and item_list:
total_row = total_row_map.get(prev_group_by_value or d.get('item_name'))
total_row['percent_gt'] = flt(total_row['total']/grand_total * 100)
data.append(total_row)
diff --git a/erpnext/accounts/report/item_wise_sales_register/item_wise_sales_register.py b/erpnext/accounts/report/item_wise_sales_register/item_wise_sales_register.py
index 0c8957a..92a22e6 100644
--- a/erpnext/accounts/report/item_wise_sales_register/item_wise_sales_register.py
+++ b/erpnext/accounts/report/item_wise_sales_register/item_wise_sales_register.py
@@ -111,7 +111,7 @@
data.append(row)
- if filters.get('group_by'):
+ if filters.get('group_by') and item_list:
total_row = total_row_map.get(prev_group_by_value or d.get('item_name'))
total_row['percent_gt'] = flt(total_row['total']/grand_total * 100)
data.append(total_row)
diff --git a/erpnext/buying/doctype/purchase_order/purchase_order.js b/erpnext/buying/doctype/purchase_order/purchase_order.js
index ed054ae..4a8146a 100644
--- a/erpnext/buying/doctype/purchase_order/purchase_order.js
+++ b/erpnext/buying/doctype/purchase_order/purchase_order.js
@@ -27,15 +27,6 @@
frm.set_indicator_formatter('item_code',
function(doc) { return (doc.qty<=doc.received_qty) ? "green" : "orange" })
- frm.set_query("blanket_order", "items", function() {
- return {
- filters: {
- "company": frm.doc.company,
- "docstatus": 1
- }
- }
- });
-
frm.set_query("expense_account", "items", function() {
return {
query: "erpnext.controllers.queries.get_expense_account",
diff --git a/erpnext/controllers/queries.py b/erpnext/controllers/queries.py
index c14bb66..5febfd6 100644
--- a/erpnext/controllers/queries.py
+++ b/erpnext/controllers/queries.py
@@ -371,6 +371,19 @@
fields = ["name", "parent_account"],
limit_start=start, limit_page_length=page_len, as_list=True)
+def get_blanket_orders(doctype, txt, searchfield, start, page_len, filters):
+ return frappe.db.sql("""select distinct bo.name, bo.blanket_order_type, bo.to_date
+ from `tabBlanket Order` bo, `tabBlanket Order Item` boi
+ where
+ boi.parent = bo.name
+ and boi.item_code = {item_code}
+ and bo.blanket_order_type = '{blanket_order_type}'
+ and bo.company = {company}
+ and bo.docstatus = 1"""
+ .format(item_code = frappe.db.escape(filters.get("item")),
+ blanket_order_type = filters.get("blanket_order_type"),
+ company = frappe.db.escape(filters.get("company"))
+ ))
@frappe.whitelist()
def get_income_account(doctype, txt, searchfield, start, page_len, filters):
diff --git a/erpnext/public/js/controllers/transaction.js b/erpnext/public/js/controllers/transaction.js
index 5843034..c9d7728 100644
--- a/erpnext/public/js/controllers/transaction.js
+++ b/erpnext/public/js/controllers/transaction.js
@@ -175,6 +175,20 @@
};
}
+ if (this.frm.fields_dict["items"].grid.get_field('blanket_order')) {
+ this.frm.set_query("blanket_order", "items", function(doc, cdt, cdn) {
+ var item = locals[cdt][cdn];
+ return {
+ query: "erpnext.controllers.queries.get_blanket_orders",
+ filters: {
+ "company": doc.company,
+ "blanket_order_type": doc.doctype === "Sales Order" ? "Selling" : "Purchasing",
+ "item": item.item_code
+ }
+ }
+ });
+ }
+
},
onload: function() {
var me = this;
diff --git a/erpnext/public/js/utils/dimension_tree_filter.js b/erpnext/public/js/utils/dimension_tree_filter.js
index 75c5a82..b223fc5 100644
--- a/erpnext/public/js/utils/dimension_tree_filter.js
+++ b/erpnext/public/js/utils/dimension_tree_filter.js
@@ -24,7 +24,7 @@
onload: function(frm) {
erpnext.dimension_filters.forEach((dimension) => {
frappe.model.with_doctype(dimension['document_type'], () => {
- if (frappe.meta.has_field(dimension['document_type'], 'is_group')) {
+ if(frappe.meta.has_field(dimension['document_type'], 'is_group')) {
frm.set_query(dimension['fieldname'], {
"is_group": 0
});
@@ -42,19 +42,21 @@
update_dimension: function(frm) {
erpnext.dimension_filters.forEach((dimension) => {
- if (frm.is_new()) {
- if (frm.doc.company && Object.keys(default_dimensions || {}).length > 0
+ if(frm.is_new()) {
+ if(frm.doc.company && Object.keys(default_dimensions || {}).length > 0
&& default_dimensions[frm.doc.company]) {
- if (frappe.meta.has_field(doctype, dimension['fieldname'])) {
- frm.set_value(dimension['fieldname'],
- default_dimensions[frm.doc.company][dimension['document_type']]);
- }
+ let default_dimension = default_dimensions[frm.doc.company][dimension['document_type']];
- $.each(frm.doc.items || frm.doc.accounts || [], function(i, row) {
- frappe.model.set_value(row.doctype, row.name, dimension['fieldname'],
- default_dimensions[frm.doc.company][dimension['document_type']])
- });
+ if(default_dimension) {
+ if (frappe.meta.has_field(doctype, dimension['fieldname'])) {
+ frm.set_value(dimension['fieldname'], default_dimension);
+ }
+
+ $.each(frm.doc.items || frm.doc.accounts || [], function(i, row) {
+ frappe.model.set_value(row.doctype, row.name, dimension['fieldname'], default_dimension);
+ });
+ }
}
}
});
@@ -76,20 +78,6 @@
var row = frappe.get_doc(cdt, cdn);
frm.script_manager.copy_from_first_row("accounts", row, [dimension['fieldname']]);
});
- },
-
- items_add: function(frm, cdt, cdn) {
- erpnext.dimension_filters.forEach((dimension) => {
- var row = frappe.get_doc(cdt, cdn);
- frm.script_manager.copy_from_first_row("items", row, [dimension['fieldname']]);
- });
- },
-
- accounts_add: function(frm, cdt, cdn) {
- erpnext.dimension_filters.forEach((dimension) => {
- var row = frappe.get_doc(cdt, cdn);
- frm.script_manager.copy_from_first_row("accounts", row, [dimension['fieldname']]);
- });
}
});
});
\ No newline at end of file
diff --git a/erpnext/selling/doctype/sales_order/sales_order.js b/erpnext/selling/doctype/sales_order/sales_order.js
index 3c1ffe9..45a43c5 100644
--- a/erpnext/selling/doctype/sales_order/sales_order.js
+++ b/erpnext/selling/doctype/sales_order/sales_order.js
@@ -65,15 +65,6 @@
}
});
- frm.set_query("blanket_order", "items", function() {
- return {
- filters: {
- "company": frm.doc.company,
- "docstatus": 1
- }
- }
- });
-
erpnext.queries.setup_warehouse_query(frm);
},
@@ -148,7 +139,7 @@
}
this.frm.add_custom_button(__('Pick List'), () => this.create_pick_list(), __('Create'));
-
+
const order_is_a_sale = ["Sales", "Shopping Cart"].indexOf(doc.order_type) !== -1;
const order_is_maintenance = ["Maintenance"].indexOf(doc.order_type) !== -1;
// order type has been customised then show all the action buttons
diff --git a/erpnext/stock/report/stock_ledger/stock_ledger.py b/erpnext/stock/report/stock_ledger/stock_ledger.py
index 28d7208..0190f09 100644
--- a/erpnext/stock/report/stock_ledger/stock_ledger.py
+++ b/erpnext/stock/report/stock_ledger/stock_ledger.py
@@ -46,19 +46,6 @@
"out_qty": min(sle.actual_qty, 0)
})
- # get the name of the item that was produced using this item
- if sle.voucher_type == "Stock Entry":
- purpose, work_order, fg_completed_qty = frappe.db.get_value(sle.voucher_type, sle.voucher_no, ["purpose", "work_order", "fg_completed_qty"])
-
- if purpose == "Manufacture" and work_order:
- finished_product = frappe.db.get_value("Work Order", work_order, "item_name")
- finished_qty = fg_completed_qty
-
- sle.update({
- "finished_product": finished_product,
- "finished_qty": finished_qty,
- })
-
data.append(sle)
if include_uom:
@@ -77,8 +64,6 @@
{"label": _("In Qty"), "fieldname": "in_qty", "fieldtype": "Float", "width": 80, "convertible": "qty"},
{"label": _("Out Qty"), "fieldname": "out_qty", "fieldtype": "Float", "width": 80, "convertible": "qty"},
{"label": _("Balance Qty"), "fieldname": "qty_after_transaction", "fieldtype": "Float", "width": 100, "convertible": "qty"},
- {"label": _("Finished Product"), "fieldname": "finished_product", "width": 100},
- {"label": _("Finished Qty"), "fieldname": "finished_qty", "fieldtype": "Float", "width": 100, "convertible": "qty"},
{"label": _("Voucher #"), "fieldname": "voucher_no", "fieldtype": "Dynamic Link", "options": "voucher_type", "width": 150},
{"label": _("Warehouse"), "fieldname": "warehouse", "fieldtype": "Link", "options": "Warehouse", "width": 150},
{"label": _("Item Group"), "fieldname": "item_group", "fieldtype": "Link", "options": "Item Group", "width": 100},