Merge pull request #1446 from nabinhait/field_currency
[fix] Get field currency for child doc
This commit is contained in:
commit
9cd321ec65
1 changed files with 19 additions and 10 deletions
|
|
@ -259,16 +259,25 @@ def get_field_currency(df, doc=None):
|
|||
|
||||
if not doc:
|
||||
return None
|
||||
|
||||
if ":" in cstr(df.get("options")):
|
||||
split_opts = df.get("options").split(":")
|
||||
if len(split_opts)==3:
|
||||
currency = frappe.db.get_value(split_opts[0], doc.get(split_opts[1]),
|
||||
split_opts[2])
|
||||
else:
|
||||
currency = doc.get(df.get("options"))
|
||||
|
||||
return currency
|
||||
|
||||
if not getattr(frappe.local, "field_currency", None):
|
||||
frappe.local.field_currency = frappe._dict()
|
||||
|
||||
if not frappe.local.field_currency.get((doc.doctype, doc.parent or doc.name), {}).get(df.fieldname):
|
||||
if ":" in cstr(df.get("options")):
|
||||
split_opts = df.get("options").split(":")
|
||||
if len(split_opts)==3:
|
||||
currency = frappe.db.get_value(split_opts[0], doc.get(split_opts[1]), split_opts[2])
|
||||
else:
|
||||
currency = doc.get(df.get("options"))
|
||||
if not currency and doc.parent:
|
||||
currency = frappe.db.get_value(doc.parenttype, doc.parent, df.get("options"))
|
||||
|
||||
if currency:
|
||||
frappe.local.field_currency.setdefault((doc.doctype, doc.parent or doc.name), frappe._dict())\
|
||||
.setdefault(df.fieldname, currency)
|
||||
|
||||
return frappe.local.field_currency.get((doc.doctype, doc.parent or doc.name), {}).get(df.fieldname)
|
||||
|
||||
def get_field_precision(df, doc=None, currency=None):
|
||||
"""get precision based on DocField options and fieldvalue in doc"""
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue