Pull items in Stock Entry from Purchase Invoice (#11839)
This commit is contained in:
parent
3bac586ee2
commit
a11dcb6e59
@ -16,6 +16,7 @@ from erpnext.accounts.general_ledger import make_gl_entries, merge_similar_entri
|
||||
from erpnext.accounts.doctype.gl_entry.gl_entry import update_outstanding_amt
|
||||
from erpnext.buying.utils import check_for_closed_status
|
||||
from erpnext.accounts.general_ledger import get_round_off_account_and_cost_center
|
||||
from frappe.model.mapper import get_mapped_doc
|
||||
|
||||
form_grid_templates = {
|
||||
"items": "templates/form_grid/item_grid.html"
|
||||
@ -728,3 +729,22 @@ def get_fixed_asset_account(asset, account=None):
|
||||
filters={"parent": asset_category, "company_name": company}, fieldname="fixed_asset_account")
|
||||
|
||||
return account
|
||||
|
||||
@frappe.whitelist()
|
||||
def make_stock_entry(source_name, target_doc=None):
|
||||
doc = get_mapped_doc("Purchase Invoice", source_name, {
|
||||
"Purchase Invoice": {
|
||||
"doctype": "Stock Entry",
|
||||
"validation": {
|
||||
"docstatus": ["=", 1]
|
||||
}
|
||||
},
|
||||
"Purchase Invoice Item": {
|
||||
"doctype": "Stock Entry Detail",
|
||||
"field_map": {
|
||||
"stock_qty": "transfer_qty"
|
||||
},
|
||||
}
|
||||
}, target_doc)
|
||||
|
||||
return doc
|
@ -260,7 +260,7 @@ erpnext.utils.map_current_doc = function(opts) {
|
||||
action: function(selections, args) {
|
||||
let values = selections;
|
||||
if(values.length === 0){
|
||||
frappe.msgprint(__("Please select Quotations"))
|
||||
frappe.msgprint(__("Please select {0}", [opts.source_doctype]))
|
||||
return;
|
||||
}
|
||||
opts.source_name = values;
|
||||
|
@ -66,6 +66,23 @@ frappe.ui.form.on('Stock Entry', {
|
||||
});
|
||||
}
|
||||
|
||||
if (frm.doc.docstatus===0) {
|
||||
frm.add_custom_button(__('Purchase Invoice'), function() {
|
||||
erpnext.utils.map_current_doc({
|
||||
method: "erpnext.accounts.doctype.purchase_invoice.purchase_invoice.make_stock_entry",
|
||||
source_doctype: "Purchase Invoice",
|
||||
target: frm,
|
||||
date_field: "posting_date",
|
||||
setters: {
|
||||
supplier: frm.doc.supplier || undefined,
|
||||
},
|
||||
get_query_filters: {
|
||||
docstatus: 1
|
||||
}
|
||||
})
|
||||
}, __("Get items from"));
|
||||
}
|
||||
|
||||
if(frm.doc.company) {
|
||||
frm.trigger("toggle_display_account_head");
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user