Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: when create doc from item dashboard default uom (buying or selling) is not correctly selected (backport #36892) #36928

Merged
merged 1 commit into from
Sep 3, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion erpnext/stock/doctype/item/item.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@

frappe.provide("erpnext.item");

const SALES_DOCTYPES = ['Quotation', 'Sales Order', 'Delivery Note', 'Sales Invoice'];
const PURCHASE_DOCTYPES = ['Purchase Order', 'Purchase Receipt', 'Purchase Invoice'];

frappe.ui.form.on("Item", {
setup: function(frm) {
frm.add_fetch('attribute', 'numeric_values', 'numeric_values');
Expand Down Expand Up @@ -894,7 +897,13 @@ function open_form(frm, doctype, child_doctype, parentfield) {
let new_child_doc = frappe.model.add_child(new_doc, child_doctype, parentfield);
new_child_doc.item_code = frm.doc.name;
new_child_doc.item_name = frm.doc.item_name;
new_child_doc.uom = frm.doc.stock_uom;
if (in_list(SALES_DOCTYPES, doctype) && frm.doc.sales_uom) {
new_child_doc.uom = frm.doc.sales_uom;
} else if (in_list(PURCHASE_DOCTYPES, doctype) && frm.doc.purchase_uom) {
new_child_doc.uom = frm.doc.purchase_uom;
} else {
new_child_doc.uom = frm.doc.stock_uom;
}
new_child_doc.description = frm.doc.description;
if (!new_child_doc.qty) {
new_child_doc.qty = 1.0;
Expand Down
Loading