Skip to content

Commit

Permalink
fix(ux): item description should fall back to name
Browse files Browse the repository at this point in the history
Don't set item description = item code from front end. This is already
being set to item_name in before_insert and item_name is better
fallback than item code for description.

Also fixed wrong condition for erasing description while duplicating
item.
  • Loading branch information
ankush committed Jul 19, 2021
1 parent 0a79cfa commit ae8368e
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions erpnext/stock/doctype/item/item.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,17 +93,18 @@ frappe.ui.form.on("Item", {

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

if (!frm.doc.is_fixed_asset) {
erpnext.item.make_dashboard(frm);
}

frm.add_custom_button(__('Duplicate'), function() {
var new_item = frappe.model.copy_doc(frm.doc);
if(new_item.item_name===new_item.item_code) {
// Duplicate item could have different name, causing "copy paste" error.
if (new_item.item_name===new_item.item_code) {
new_item.item_name = null;
}
if(new_item.description===new_item.description) {
if (new_item.item_code===new_item.description || new_item.item_code===new_item.description) {
new_item.description = null;
}
frappe.set_route('Form', 'Item', new_item.name);
Expand Down Expand Up @@ -186,8 +187,6 @@ frappe.ui.form.on("Item", {
item_code: function(frm) {
if(!frm.doc.item_name)
frm.set_value("item_name", frm.doc.item_code);
if(!frm.doc.description)
frm.set_value("description", frm.doc.item_code);
},

is_stock_item: function(frm) {
Expand Down

0 comments on commit ae8368e

Please sign in to comment.