feat: creating stock entry against purchase receipt

This commit is contained in:
Anurag Mishra 2019-06-14 12:11:23 +05:30
parent 0d50523723
commit 4c1639305f
6 changed files with 54 additions and 15 deletions

View File

@ -152,9 +152,6 @@ def tax_account_query(doctype, txt, searchfield, start, page_len, filters):
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

View File

@ -72,9 +72,10 @@ frappe.ui.form.on("Work Order", {
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', '!=', '']
]
}
});

View File

@ -107,6 +107,8 @@ erpnext.stock.PurchaseReceiptController = erpnext.buying.BuyingController.extend
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 @@ frappe.ui.form.on('Purchase Receipt Item', {
},
});
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) {

View File

@ -12,6 +12,7 @@ from frappe.utils import getdate
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 make_purchase_return(source_name, target_doc=None):
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

View File

@ -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"
}

View File

@ -41,9 +41,6 @@ frappe.query_reports["Stock Balance"] = {
"get_query": function() {
return {
query: "erpnext.controllers.queries.item_query",
filters: {
"item_group": frappe.query_report.get_filter_value("item_group")
}
}
}
},