Skip to content
Open
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ def create_items():
"is_stock_item": 1,
"standard_rate": 100,
"opening_stock": 100,
"valuation_rate": 100,
"last_purchase_rate": 100,
"item_defaults": [{"company": "_Test Company", "default_warehouse": "Stores - _TC"}],
}
Expand All @@ -103,6 +104,7 @@ def create_items():
"is_stock_item": 1,
"standard_rate": 200,
"opening_stock": 200,
"valuation_rate": 200,
"last_purchase_rate": 200,
"item_defaults": [{"company": "_Test Company", "default_warehouse": "Stores - _TC"}],
}
Expand Down
30 changes: 18 additions & 12 deletions erpnext/stock/doctype/item/item.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ frappe.ui.form.on("Item", {
},
};
},

onload: function (frm) {
erpnext.item.setup_queries(frm);
if (frm.doc.variant_of) {
Expand Down Expand Up @@ -127,6 +128,21 @@ frappe.ui.form.on("Item", {
refresh: function (frm) {
frm.trigger("toggle_has_serial_batch_fields");

if (frappe.defaults.get_default("item_naming_by") != "Naming Series" || frm.doc.variant_of) {
frm.toggle_display("naming_series", false);
} else {
erpnext.toggle_naming_series();
}

frm.toggle_display(["standard_rate"], frappe.model.can_create("Item Price"));

if (frm.is_new()) {
frm.toggle_display("disabled", false);
return;
}

frm.toggle_display("disabled", true);

if (frm.doc.is_stock_item) {
frm.add_custom_button(
__("Stock Balance"),
Expand Down Expand Up @@ -229,8 +245,6 @@ frappe.ui.form.on("Item", {
__("Create")
);
}

// frm.page.set_inner_btn_group_as_primary(__('Create'));
}
if (frm.doc.variant_of) {
frm.set_intro(
Expand All @@ -241,12 +255,6 @@ frappe.ui.form.on("Item", {
);
}

if (frappe.defaults.get_default("item_naming_by") != "Naming Series" || frm.doc.variant_of) {
frm.toggle_display("naming_series", false);
} else {
erpnext.toggle_naming_series();
}

erpnext.item.edit_prices_button(frm);
erpnext.item.toggle_attributes(frm);

Expand Down Expand Up @@ -286,8 +294,6 @@ frappe.ui.form.on("Item", {
},
};
});

frm.toggle_display(["standard_rate"], frappe.model.can_create("Item Price"));
},

validate: function (frm) {
Expand Down Expand Up @@ -661,10 +667,10 @@ $.extend(erpnext.item, {
make_dashboard: function (frm) {
if (frm.doc.__islocal) return;

// Show Stock Levels only if is_stock_item
if (frm.doc.is_stock_item) {
frappe.require("item-dashboard.bundle.js", function () {
const section = frm.dashboard.add_section("", __("Stock Levels"));
const section = frm.fields_dict["stock_levels_html"].$wrapper;

erpnext.item.item_dashboard = new erpnext.stock.ItemDashboard({
parent: section,
item_code: frm.doc.name,
Expand Down
Loading
Loading