From bfb8ccb628895657fa982d059e2f107157080cf8 Mon Sep 17 00:00:00 2001 From: git-avc Date: Tue, 13 Jan 2026 23:01:16 +0100 Subject: [PATCH 1/6] feat: let's control alignment --- frappe/core/doctype/docfield/docfield.json | 8 ++++++++ frappe/public/js/frappe/form/controls/base_input.js | 8 +++++++- frappe/public/js/frappe/form/controls/data.js | 4 ++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/frappe/core/doctype/docfield/docfield.json b/frappe/core/doctype/docfield/docfield.json index b2c1b0d262..b089fce2c2 100644 --- a/frappe/core/doctype/docfield/docfield.json +++ b/frappe/core/doctype/docfield/docfield.json @@ -72,6 +72,7 @@ "mandatory_depends_on", "read_only_depends_on", "display", + "alignment", "print_width", "width", "max_height", @@ -475,6 +476,13 @@ "max_height": "3rem", "options": "JS" }, + { + "depends_on": "eval:in_list([\"Data\", \"Int\", \"Float\"], doc.fieldtype)", + "fieldname": "alignment", + "fieldtype": "Select", + "label": "Alignment", + "options": "\nLeft\nCenter\nRight" + }, { "fieldname": "column_break_38", "fieldtype": "Column Break" diff --git a/frappe/public/js/frappe/form/controls/base_input.js b/frappe/public/js/frappe/form/controls/base_input.js index beab7e96bd..bf8d2b0e32 100644 --- a/frappe/public/js/frappe/form/controls/base_input.js +++ b/frappe/public/js/frappe/form/controls/base_input.js @@ -165,7 +165,13 @@ frappe.ui.form.ControlInput = class ControlInput extends frappe.ui.form.Control let doc = this.doc || (this.frm && this.frm.doc); let display_value = frappe.format(value, this.df, { no_icon: true, inline: true }, doc); // This is used to display formatted output AND showing values in read only fields - this.disp_area && $(this.disp_area).html(display_value); + if (this.disp_area) { + $(this.disp_area).html(display_value); + // Apply alignment for Data, Int, Float fields + if (this.df.alignment && ["Data", "Int", "Float"].includes(this.df.fieldtype)) { + $(this.disp_area).css("text-align", this.df.alignment.toLowerCase()); + } + } } set_label(label) { if (label) this.df.label = label; diff --git a/frappe/public/js/frappe/form/controls/data.js b/frappe/public/js/frappe/form/controls/data.js index 6b3a501eb8..78b22777cc 100644 --- a/frappe/public/js/frappe/form/controls/data.js +++ b/frappe/public/js/frappe/form/controls/data.js @@ -251,6 +251,10 @@ frappe.ui.form.ControlData = class ControlData extends frappe.ui.form.ControlInp if (this.df.input_class) { this.$input.addClass(this.df.input_class); } + // Apply alignment if specified + if (this.df.alignment) { + this.$input.css("text-align", this.df.alignment.toLowerCase()); + } } set_input(value) { this.last_value = this.value; From 59c3a02f28bef1adcd2845831660040f2bccaecc Mon Sep 17 00:00:00 2001 From: git-avc Date: Tue, 13 Jan 2026 23:43:09 +0100 Subject: [PATCH 2/6] fix: add Currency fieldtype --- frappe/core/doctype/docfield/docfield.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frappe/core/doctype/docfield/docfield.json b/frappe/core/doctype/docfield/docfield.json index b089fce2c2..3acf1d5ea8 100644 --- a/frappe/core/doctype/docfield/docfield.json +++ b/frappe/core/doctype/docfield/docfield.json @@ -477,7 +477,7 @@ "options": "JS" }, { - "depends_on": "eval:in_list([\"Data\", \"Int\", \"Float\"], doc.fieldtype)", + "depends_on": "eval:in_list([\"Data\", \"Int\", \"Float\", \"Currency\", \"Percent\"], doc.fieldtype)", "fieldname": "alignment", "fieldtype": "Select", "label": "Alignment", From ab880b4c4f119c2e3d379bfaa832070ccdaa7255 Mon Sep 17 00:00:00 2001 From: git-avc Date: Sun, 18 Jan 2026 23:13:43 +0100 Subject: [PATCH 3/6] fix: consider read-only fields --- frappe/public/js/frappe/form/controls/base_input.js | 4 ++-- frappe/public/js/frappe/form/controls/data.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/frappe/public/js/frappe/form/controls/base_input.js b/frappe/public/js/frappe/form/controls/base_input.js index 4d6b641e2b..ba4b2bd0d3 100644 --- a/frappe/public/js/frappe/form/controls/base_input.js +++ b/frappe/public/js/frappe/form/controls/base_input.js @@ -179,8 +179,8 @@ frappe.ui.form.ControlInput = class ControlInput extends frappe.ui.form.Control // This is used to display formatted output AND showing values in read only fields if (this.disp_area) { $(this.disp_area).html(display_value); - // Apply alignment for Data, Int, Float fields - if (this.df.alignment && ["Data", "Int", "Float"].includes(this.df.fieldtype)) { + // Apply alignment for supported fields + if (this.df.alignment && ["Data", "Int", "Float", "Currency", "Percent"].includes(this.df.fieldtype)) { $(this.disp_area).css("text-align", this.df.alignment.toLowerCase()); } } diff --git a/frappe/public/js/frappe/form/controls/data.js b/frappe/public/js/frappe/form/controls/data.js index 78b22777cc..5bb401a92c 100644 --- a/frappe/public/js/frappe/form/controls/data.js +++ b/frappe/public/js/frappe/form/controls/data.js @@ -251,8 +251,8 @@ frappe.ui.form.ControlData = class ControlData extends frappe.ui.form.ControlInp if (this.df.input_class) { this.$input.addClass(this.df.input_class); } - // Apply alignment if specified - if (this.df.alignment) { + // Apply alignment if specified for supported field types + if (this.df.alignment && ["Data", "Int", "Float", "Currency", "Percent"].includes(this.df.fieldtype)) { this.$input.css("text-align", this.df.alignment.toLowerCase()); } } From 75b4366325b295390b2a6ede7013b75c9463fb51 Mon Sep 17 00:00:00 2001 From: git-avc Date: Mon, 19 Jan 2026 00:07:22 +0100 Subject: [PATCH 4/6] fix: let's alignment on customize form --- frappe/core/doctype/docfield/docfield.py | 1 + frappe/custom/doctype/custom_field/custom_field.json | 8 ++++++++ frappe/custom/doctype/custom_field/custom_field.py | 1 + frappe/custom/doctype/customize_form/customize_form.py | 1 + .../customize_form_field/customize_form_field.json | 8 ++++++++ .../doctype/customize_form_field/customize_form_field.py | 1 + 6 files changed, 20 insertions(+) diff --git a/frappe/core/doctype/docfield/docfield.py b/frappe/core/doctype/docfield/docfield.py index 6f90b81ce9..41aab9db6a 100644 --- a/frappe/core/doctype/docfield/docfield.py +++ b/frappe/core/doctype/docfield/docfield.py @@ -17,6 +17,7 @@ class DocField(Document): allow_bulk_edit: DF.Check allow_in_quick_entry: DF.Check allow_on_submit: DF.Check + alignment: DF.Literal["", "Left", "Center", "Right"] bold: DF.Check button_color: DF.Literal["", "Default", "Primary", "Info", "Success", "Warning", "Danger"] collapsible: DF.Check diff --git a/frappe/custom/doctype/custom_field/custom_field.json b/frappe/custom/doctype/custom_field/custom_field.json index 6777fc4b35..aba6e4be1f 100644 --- a/frappe/custom/doctype/custom_field/custom_field.json +++ b/frappe/custom/doctype/custom_field/custom_field.json @@ -46,6 +46,7 @@ "print_hide", "print_hide_if_no_value", "print_width", + "alignment", "no_copy", "allow_on_submit", "in_list_view", @@ -302,6 +303,13 @@ "no_copy": 1, "print_hide": 1 }, + { + "depends_on": "eval:['Data', 'Int', 'Float', 'Currency', 'Percent'].includes(doc.fieldtype)", + "fieldname": "alignment", + "fieldtype": "Select", + "label": "Alignment", + "options": "\nLeft\nCenter\nRight" + }, { "default": "0", "fieldname": "no_copy", diff --git a/frappe/custom/doctype/custom_field/custom_field.py b/frappe/custom/doctype/custom_field/custom_field.py index e90a6caf53..02bd0d368c 100644 --- a/frappe/custom/doctype/custom_field/custom_field.py +++ b/frappe/custom/doctype/custom_field/custom_field.py @@ -24,6 +24,7 @@ class CustomField(Document): allow_in_quick_entry: DF.Check allow_on_submit: DF.Check + alignment: DF.Literal["", "Left", "Center", "Right"] bold: DF.Check button_color: DF.Literal["", "Default", "Primary", "Info", "Success", "Warning", "Danger"] collapsible: DF.Check diff --git a/frappe/custom/doctype/customize_form/customize_form.py b/frappe/custom/doctype/customize_form/customize_form.py index 0258abd57e..dc49394630 100644 --- a/frappe/custom/doctype/customize_form/customize_form.py +++ b/frappe/custom/doctype/customize_form/customize_form.py @@ -768,6 +768,7 @@ docfield_properties = { "permlevel": "Int", "width": "Data", "print_width": "Data", + "alignment": "Select", "non_negative": "Check", "reqd": "Check", "unique": "Check", diff --git a/frappe/custom/doctype/customize_form_field/customize_form_field.json b/frappe/custom/doctype/customize_form_field/customize_form_field.json index 9d42e98d79..6976cbe0f9 100644 --- a/frappe/custom/doctype/customize_form_field/customize_form_field.json +++ b/frappe/custom/doctype/customize_form_field/customize_form_field.json @@ -65,6 +65,7 @@ "print_hide", "print_hide_if_no_value", "print_width", + "alignment", "columns", "width", "is_custom_field" @@ -356,6 +357,13 @@ "print_width": "50px", "width": "50px" }, + { + "depends_on": "eval:in_list(['Data', 'Int', 'Float', 'Currency', 'Percent'], doc.fieldtype)", + "fieldname": "alignment", + "fieldtype": "Select", + "label": "Alignment", + "options": "\nLeft\nCenter\nRight" + }, { "depends_on": "eval:parent.istable", "description": "Number of columns for a field in a Grid (Total Columns in a grid should be less than 11)", diff --git a/frappe/custom/doctype/customize_form_field/customize_form_field.py b/frappe/custom/doctype/customize_form_field/customize_form_field.py index 9a67a1d944..fcd28b9439 100644 --- a/frappe/custom/doctype/customize_form_field/customize_form_field.py +++ b/frappe/custom/doctype/customize_form_field/customize_form_field.py @@ -16,6 +16,7 @@ class CustomizeFormField(Document): allow_bulk_edit: DF.Check allow_in_quick_entry: DF.Check allow_on_submit: DF.Check + alignment: DF.Literal["", "Left", "Center", "Right"] bold: DF.Check button_color: DF.Literal["", "Default", "Primary", "Info", "Success", "Warning", "Danger"] collapsible: DF.Check From 7b012af2f404664453395c1cda92072d5b675ea1 Mon Sep 17 00:00:00 2001 From: git-avc Date: Mon, 19 Jan 2026 00:29:02 +0100 Subject: [PATCH 5/6] fix: linters --- frappe/core/doctype/docfield/docfield.py | 1 - 1 file changed, 1 deletion(-) diff --git a/frappe/core/doctype/docfield/docfield.py b/frappe/core/doctype/docfield/docfield.py index 41aab9db6a..94d99fe5e9 100644 --- a/frappe/core/doctype/docfield/docfield.py +++ b/frappe/core/doctype/docfield/docfield.py @@ -127,7 +127,6 @@ class DocField(Document): def get_link_doctype(self): """Return the Link doctype for the `docfield` (if applicable). - * If fieldtype is Link: Return "options". * If fieldtype is Table MultiSelect: Return "options" of the Link field in the Child Table. """ From 9feacbbb66bebe211cd96c9b068fd83c087a442f Mon Sep 17 00:00:00 2001 From: git-avc Date: Mon, 19 Jan 2026 00:41:01 +0100 Subject: [PATCH 6/6] fix: more linters --- frappe/public/js/frappe/form/controls/base_input.js | 7 +++++-- frappe/public/js/frappe/form/controls/data.js | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/frappe/public/js/frappe/form/controls/base_input.js b/frappe/public/js/frappe/form/controls/base_input.js index ba4b2bd0d3..3cd277a239 100644 --- a/frappe/public/js/frappe/form/controls/base_input.js +++ b/frappe/public/js/frappe/form/controls/base_input.js @@ -179,8 +179,11 @@ frappe.ui.form.ControlInput = class ControlInput extends frappe.ui.form.Control // This is used to display formatted output AND showing values in read only fields if (this.disp_area) { $(this.disp_area).html(display_value); - // Apply alignment for supported fields - if (this.df.alignment && ["Data", "Int", "Float", "Currency", "Percent"].includes(this.df.fieldtype)) { + // Apply alignment only for supported fields + if ( + this.df.alignment && + ["Data", "Int", "Float", "Currency", "Percent"].includes(this.df.fieldtype) + ) { $(this.disp_area).css("text-align", this.df.alignment.toLowerCase()); } } diff --git a/frappe/public/js/frappe/form/controls/data.js b/frappe/public/js/frappe/form/controls/data.js index 5bb401a92c..dcaf1cab44 100644 --- a/frappe/public/js/frappe/form/controls/data.js +++ b/frappe/public/js/frappe/form/controls/data.js @@ -251,8 +251,11 @@ frappe.ui.form.ControlData = class ControlData extends frappe.ui.form.ControlInp if (this.df.input_class) { this.$input.addClass(this.df.input_class); } - // Apply alignment if specified for supported field types - if (this.df.alignment && ["Data", "Int", "Float", "Currency", "Percent"].includes(this.df.fieldtype)) { + // Apply alignment for supported field types + if ( + this.df.alignment && + ["Data", "Int", "Float", "Currency", "Percent"].includes(this.df.fieldtype) + ) { this.$input.css("text-align", this.df.alignment.toLowerCase()); } }