refactor: clean up long conditional

This commit is contained in:
Hussain Nagaria 2025-01-01 07:15:12 +05:30
parent 88b854c859
commit ed64dd728e

View file

@ -290,13 +290,12 @@ $.extend(frappe.model, {
// don't copy name and blank fields
let df = frappe.meta.get_docfield(doc.doctype, key);
if (
df &&
key.substring(0, 2) != "__" &&
!no_copy_list.includes(key) &&
!(df && !from_amend && cint(df.no_copy) == 1) &&
df.fieldtype !== "Password"
) {
const is_internal_field = key.substring(0, 2) === "__";
const is_blocked_field = no_copy_list.includes(key);
const is_no_copy = !from_amend && df && cint(df.no_copy) == 1;
const is_password = df && df.fieldtype === "Password";
if (df && !is_internal_field && !is_blocked_field && !is_no_copy && !is_password) {
let value = doc[key] || [];
if (frappe.model.table_fields.includes(df.fieldtype)) {
for (let i = 0, j = value.length; i < j; i++) {