Преглед изворни кода

Merge pull request #1446 from nabinhait/field_currency

[fix] Get field currency for child doc
version-14
Nabin Hait пре 9 година
родитељ
комит
9cd321ec65
1 измењених фајлова са 19 додато и 10 уклоњено
  1. +19
    -10
      frappe/model/meta.py

+ 19
- 10
frappe/model/meta.py Прегледај датотеку

@@ -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…
Откажи
Сачувај