feat: creating stock entry against purchase receipt
diff --git a/erpnext/controllers/queries.py b/erpnext/controllers/queries.py
index 0dcf077..ccd334f 100644
--- a/erpnext/controllers/queries.py
+++ b/erpnext/controllers/queries.py
@@ -152,9 +152,6 @@
def item_query(doctype, txt, searchfield, start, page_len, filters, as_dict=False):
conditions = []
- if not filters["item_group"]:
- filters.pop("item_group", None)
-
description_cond = ''
if frappe.db.count('Item', cache=True) < 50000:
# scan description only if items are less than 50000
diff --git a/erpnext/manufacturing/doctype/work_order/work_order.js b/erpnext/manufacturing/doctype/work_order/work_order.js
index 580243f..22613cc 100644
--- a/erpnext/manufacturing/doctype/work_order/work_order.js
+++ b/erpnext/manufacturing/doctype/work_order/work_order.js
@@ -72,9 +72,10 @@
frm.set_query("production_item", function() {
return {
query: "erpnext.controllers.queries.item_query",
- filters:{
- 'is_stock_item': 1,
- }
+ filters:[
+ ['is_stock_item', '=',1],
+ ['default_bom', '!=', '']
+ ]
}
});
diff --git a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js
index 2151364..e82aa2c 100644
--- a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js
+++ b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js
@@ -107,6 +107,8 @@
cur_frm.add_custom_button(__('Return'), this.make_purchase_return, __('Create'));
+ cur_frm.add_custom_button(__('Make Stock Entry'), cur_frm.cscript['Make Stock Entry'], __('Create'));
+
if(flt(this.frm.doc.per_billed) < 100) {
cur_frm.add_custom_button(__('Invoice'), this.make_purchase_invoice, __('Create'));
}
@@ -249,6 +251,13 @@
},
});
+cur_frm.cscript['Make Stock Entry'] = function() {
+ frappe.model.open_mapped_doc({
+ method: "erpnext.stock.doctype.purchase_receipt.purchase_receipt.make_stock_entry",
+ frm: cur_frm,
+ })
+}
+
var validate_sample_quantity = function(frm, cdt, cdn) {
var d = locals[cdt][cdn];
if (d.sample_quantity) {
diff --git a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py
index 1a469c5..cdca44d 100644
--- a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py
+++ b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py
@@ -12,6 +12,7 @@
from erpnext.controllers.buying_controller import BuyingController
from erpnext.accounts.utils import get_account_currency
from frappe.desk.notifications import clear_doctype_notifications
+from frappe.model.mapper import get_mapped_doc
from erpnext.buying.utils import check_on_hold_or_closed_status
from erpnext.assets.doctype.asset.asset import get_asset_account, is_cwip_accounting_disabled
from six import iteritems
@@ -530,3 +531,24 @@
def update_purchase_receipt_status(docname, status):
pr = frappe.get_doc("Purchase Receipt", docname)
pr.update_status(status)
+
+@frappe.whitelist()
+def make_stock_entry(source_name,target_doc=None):
+ def set_missing_values(source, target):
+ target.stock_entry_type = "Material Transfer"
+ target.purpose = "Material Transfer"
+
+ doclist = get_mapped_doc("Purchase Receipt", source_name,{
+ "Purchase Receipt": {
+ "doctype": "Stock Entry",
+ },
+ "Purchase Receipt Item": {
+ "doctype": "Stock Entry Detail",
+ "field_map": {
+ "warehouse": "s_warehouse",
+ "parent": "reference_purchase_receipt"
+ },
+ },
+ }, target_doc, set_missing_values)
+
+ return doclist
diff --git a/erpnext/stock/doctype/stock_entry_detail/stock_entry_detail.json b/erpnext/stock/doctype/stock_entry_detail/stock_entry_detail.json
index 8834035..5933700 100644
--- a/erpnext/stock/doctype/stock_entry_detail/stock_entry_detail.json
+++ b/erpnext/stock/doctype/stock_entry_detail/stock_entry_detail.json
@@ -13,6 +13,7 @@
"t_warehouse",
"sec_break1",
"item_code",
+ "item_group",
"col_break2",
"item_name",
"section_break_8",
@@ -59,7 +60,8 @@
"against_stock_entry",
"ste_detail",
"column_break_51",
- "transferred_qty"
+ "transferred_qty",
+ "reference_purchase_receipt"
],
"fields": [
{
@@ -72,7 +74,6 @@
"fieldtype": "Section Break"
},
{
- "columns": 2,
"fieldname": "s_warehouse",
"fieldtype": "Link",
"in_list_view": 1,
@@ -86,7 +87,6 @@
"fieldtype": "Column Break"
},
{
- "columns": 2,
"fieldname": "t_warehouse",
"fieldtype": "Link",
"in_list_view": 1,
@@ -101,7 +101,6 @@
},
{
"bold": 1,
- "columns": 3,
"fieldname": "item_code",
"fieldtype": "Link",
"in_global_search": 1,
@@ -164,7 +163,6 @@
},
{
"bold": 1,
- "columns": 3,
"fieldname": "qty",
"fieldtype": "Float",
"in_list_view": 1,
@@ -460,15 +458,30 @@
{
"fieldname": "dimension_col_break",
"fieldtype": "Column Break"
+ },
+ {
+ "fetch_from": "item_code.item_group",
+ "fieldname": "item_group",
+ "fieldtype": "Data",
+ "in_list_view": 1,
+ "label": "Item Group"
+ },
+ {
+ "fieldname": "reference_purchase_receipt",
+ "fieldtype": "Link",
+ "label": "Reference Purchase Receipt",
+ "options": "Purchase Receipt",
+ "read_only": 1
}
],
"idx": 1,
"istable": 1,
- "modified": "2019-05-25 22:51:00.802226",
+ "modified": "2019-06-14 11:58:41.958144",
"modified_by": "Administrator",
"module": "Stock",
"name": "Stock Entry Detail",
"owner": "Administrator",
"permissions": [],
+ "sort_field": "modified",
"sort_order": "ASC"
}
\ No newline at end of file
diff --git a/erpnext/stock/report/stock_balance/stock_balance.js b/erpnext/stock/report/stock_balance/stock_balance.js
index 120f879..3829d6a 100644
--- a/erpnext/stock/report/stock_balance/stock_balance.js
+++ b/erpnext/stock/report/stock_balance/stock_balance.js
@@ -41,9 +41,6 @@
"get_query": function() {
return {
query: "erpnext.controllers.queries.item_query",
- filters: {
- "item_group": frappe.query_report.get_filter_value("item_group")
- }
}
}
},