fix(ux): item description should fall back to name (#26339)

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.
This commit is contained in:
Ankush 2021-07-19 20:42:44 +05:30 committed by GitHub
parent 354e2984c2
commit 80e269887d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

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