fix: resolve currency precision for child table rows in unsaved documents

This commit is contained in:
Luis Mendoza 2026-02-06 16:01:22 +00:00
parent 39b0cea12f
commit 8e97332029
2 changed files with 8 additions and 1 deletions

View file

@ -884,6 +884,12 @@ def get_field_currency(df, doc=None):
if frappe.get_meta(doc.parenttype).has_field(df.get("options")):
# only get_value if parent has currency field
currency = frappe.db.get_value(doc.parenttype, doc.parent, df.get("options"))
if not currency:
# Parent may not be in DB yet (new document being saved).
# Use the in-memory parent document reference if available.
parent = getattr(doc, "parent_doc", None)
if parent:
currency = parent.get(df.get("options"))
if currency:
frappe.local.field_currency.setdefault((doc.doctype, ref_docname), frappe._dict()).setdefault(

View file

@ -332,7 +332,8 @@ $.extend(frappe.meta, {
} else if (df && df.fieldtype === "Currency") {
precision = cint(frappe.defaults.get_default("currency_precision"));
if (!precision) {
var number_format = get_number_format();
var currency = frappe.meta.get_field_currency(df, doc);
var number_format = get_number_format(currency);
var number_format_info = get_number_format_info(number_format);
precision = number_format_info.precision;
}