Skip to content

Commit

Permalink
fix(ux): item description should fall back to name (#26339)
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 354e298 commit 80e2698
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions erpnext/stock/doctype/item/item.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,11 @@ frappe.ui.form.on("Item", {

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 80e2698

Please sign in to comment.