From 66e08e39f7229f666ceba23852d7120e17ad20b6 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Mon, 29 Sep 2014 12:17:03 +0530 Subject: [PATCH] [fix] currency moved to frappe --- erpnext/controllers/accounts_controller.py | 10 +++++++++- erpnext/stock/get_item_details.py | 4 ++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py index 7fa81c9926..0d189c741d 100644 --- a/erpnext/controllers/accounts_controller.py +++ b/erpnext/controllers/accounts_controller.py @@ -146,7 +146,6 @@ class AccountsController(TransactionBase): self.currency = company_currency self.conversion_rate = 1.0 else: - from erpnext.setup.doctype.currency.currency import validate_conversion_rate validate_conversion_rate(self.currency, self.conversion_rate, self.meta.get_label("conversion_rate"), self.company) @@ -500,3 +499,12 @@ def get_taxes_and_charges(master_doctype, master_name, tax_parentfield): taxes_and_charges.append(tax) return taxes_and_charges + +def validate_conversion_rate(currency, conversion_rate, conversion_rate_label, company): + """common validation for currency and price list currency""" + + company_currency = frappe.db.get_value("Company", company, "default_currency") + + if not conversion_rate: + throw(_("{0} is mandatory. Maybe Currency Exchange record is not created for {1} to {2}.").format( + conversion_rate_label, currency, company_currency)) diff --git a/erpnext/stock/get_item_details.py b/erpnext/stock/get_item_details.py index fffb52e835..19f97247ad 100644 --- a/erpnext/stock/get_item_details.py +++ b/erpnext/stock/get_item_details.py @@ -8,6 +8,7 @@ from frappe.utils import flt, cint, add_days import json from erpnext.accounts.doctype.pricing_rule.pricing_rule import get_pricing_rule_for_item from erpnext.setup.utils import get_exchange_rate +from frappe.model.meta import get_field_precision @frappe.whitelist() def get_item_details(args): @@ -206,8 +207,7 @@ def validate_price_list(args): throw(_("Price List not selected")) def validate_conversion_rate(args, meta): - from erpnext.setup.doctype.currency.currency import validate_conversion_rate - from frappe.model.meta import get_field_precision + from erpnext.controllers.accounts_controller import validate_conversion_rate # validate currency conversion rate validate_conversion_rate(args.currency, args.conversion_rate,