optimize(various)
This commit is contained in:
		
							parent
							
								
									4d0b8da0e5
								
							
						
					
					
						commit
						708e47aadf
					
				| @ -27,7 +27,7 @@ def get_default_currency(): | ||||
| 	'''Returns the currency of the default company''' | ||||
| 	company = get_default_company() | ||||
| 	if company: | ||||
| 		return frappe.db.get_value('Company', company, 'default_currency') | ||||
| 		return frappe.get_cached_value('Company',  company,  'default_currency') | ||||
| 
 | ||||
| def get_default_cost_center(company): | ||||
| 	'''Returns the default cost center of the company''' | ||||
| @ -37,7 +37,7 @@ def get_default_cost_center(company): | ||||
| 	if not frappe.flags.company_cost_center: | ||||
| 		frappe.flags.company_cost_center = {} | ||||
| 	if not company in frappe.flags.company_cost_center: | ||||
| 		frappe.flags.company_cost_center[company] = frappe.db.get_value('Company', company, 'cost_center') | ||||
| 		frappe.flags.company_cost_center[company] = frappe.get_cached_value('Company',  company,  'cost_center') | ||||
| 	return frappe.flags.company_cost_center[company] | ||||
| 
 | ||||
| def get_company_currency(company): | ||||
| @ -45,7 +45,7 @@ def get_company_currency(company): | ||||
| 	if not frappe.flags.company_currency: | ||||
| 		frappe.flags.company_currency = {} | ||||
| 	if not company in frappe.flags.company_currency: | ||||
| 		frappe.flags.company_currency[company] = frappe.db.get_value('Company', company, 'default_currency') | ||||
| 		frappe.flags.company_currency[company] = frappe.get_cached_value('Company',  company,  'default_currency') | ||||
| 	return frappe.flags.company_currency[company] | ||||
| 
 | ||||
| def set_perpetual_inventory(enable=1, company=None): | ||||
| @ -58,7 +58,7 @@ def set_perpetual_inventory(enable=1, company=None): | ||||
| 
 | ||||
| def encode_company_abbr(name, company): | ||||
| 	'''Returns name encoded with company abbreviation''' | ||||
| 	company_abbr = frappe.db.get_value("Company", company, "abbr") | ||||
| 	company_abbr = frappe.get_cached_value('Company',  company,  "abbr") | ||||
| 	parts = name.rsplit(" - ", 1) | ||||
| 
 | ||||
| 	if parts[-1].lower() != company_abbr.lower(): | ||||
| @ -74,7 +74,7 @@ def is_perpetual_inventory_enabled(company): | ||||
| 		frappe.local.enable_perpetual_inventory = {} | ||||
| 
 | ||||
| 	if not company in frappe.local.enable_perpetual_inventory: | ||||
| 		frappe.local.enable_perpetual_inventory[company] = frappe.db.get_value("Company", | ||||
| 		frappe.local.enable_perpetual_inventory[company] = frappe.get_cached_value('Company',  | ||||
| 			company,  "enable_perpetual_inventory") or 0 | ||||
| 
 | ||||
| 	return frappe.local.enable_perpetual_inventory[company] | ||||
| @ -87,7 +87,7 @@ def get_default_finance_book(company=None): | ||||
| 		frappe.local.default_finance_book = {} | ||||
| 
 | ||||
| 	if not company in frappe.local.default_finance_book: | ||||
| 		frappe.local.default_finance_book[company] = frappe.db.get_value("Company", | ||||
| 		frappe.local.default_finance_book[company] = frappe.get_cached_value('Company',  | ||||
| 			company,  "default_finance_book") | ||||
| 
 | ||||
| 	return frappe.local.default_finance_book[company] | ||||
| @ -108,7 +108,7 @@ def get_region(company=None): | ||||
| 	You can also set global company flag in `frappe.flags.company` | ||||
| 	''' | ||||
| 	if company or frappe.flags.company: | ||||
| 		return frappe.db.get_value('Company', | ||||
| 		return frappe.get_cached_value('Company',  | ||||
| 			company or frappe.flags.company,  'country') | ||||
| 	elif frappe.flags.country: | ||||
| 		return frappe.flags.country | ||||
|  | ||||
| @ -119,7 +119,7 @@ class Account(NestedSet): | ||||
| 
 | ||||
| 	def validate_account_currency(self): | ||||
| 		if not self.account_currency: | ||||
| 			self.account_currency = frappe.db.get_value("Company", self.company, "default_currency") | ||||
| 			self.account_currency = frappe.get_cached_value('Company',  self.company,  "default_currency") | ||||
| 
 | ||||
| 		elif self.account_currency != frappe.db.get_value("Account", self.name, "account_currency"): | ||||
| 			if frappe.db.get_value("GL Entry", {"account": self.name}): | ||||
| @ -181,7 +181,7 @@ def get_account_currency(account): | ||||
| 	def generator(): | ||||
| 		account_currency, company = frappe.db.get_value("Account", account, ["account_currency", "company"]) | ||||
| 		if not account_currency: | ||||
| 			account_currency = frappe.db.get_value("Company", company, "default_currency") | ||||
| 			account_currency = frappe.get_cached_value('Company',  company,  "default_currency") | ||||
| 
 | ||||
| 		return account_currency | ||||
| 
 | ||||
| @ -192,7 +192,7 @@ def on_doctype_update(): | ||||
| 
 | ||||
| def get_account_autoname(account_number, account_name, company): | ||||
| 	# first validate if company exists | ||||
| 	company = frappe.db.get_value("Company", company, ["abbr", "name"], as_dict=True) | ||||
| 	company = frappe.get_cached_value('Company',  company,  ["abbr", "name"], as_dict=True) | ||||
| 	if not company: | ||||
| 		frappe.throw(_('Company {0} does not exist').format(company)) | ||||
| 
 | ||||
|  | ||||
| @ -38,7 +38,7 @@ def create_charts(company, chart_template=None, existing_company=None): | ||||
| 						"report_type": report_type, | ||||
| 						"account_number": account_number, | ||||
| 						"account_type": child.get("account_type"), | ||||
| 						"account_currency": frappe.db.get_value("Company", company, "default_currency"), | ||||
| 						"account_currency": frappe.get_cached_value('Company',  company,  "default_currency"), | ||||
| 						"tax_rate": child.get("tax_rate") | ||||
| 					}) | ||||
| 
 | ||||
|  | ||||
| @ -14,7 +14,7 @@ class AccountingPeriod(Document): | ||||
| 		self.bootstrap_doctypes_for_closing() | ||||
| 
 | ||||
| 	def autoname(self): | ||||
| 		company_abbr = frappe.db.get_value("Company", self.company, "abbr") | ||||
| 		company_abbr = frappe.get_cached_value('Company',  self.company,  "abbr") | ||||
| 		self.name = " - ".join([self.period_name, company_abbr]) | ||||
| 	 | ||||
| 	def validate_overlap(self): | ||||
|  | ||||
| @ -81,7 +81,7 @@ def validate_expense_against_budget(args): | ||||
| 
 | ||||
| 	if args.get('company') and not args.fiscal_year: | ||||
| 		args.fiscal_year = get_fiscal_year(args.get('posting_date'), company=args.get('company'))[0] | ||||
| 		frappe.flags.exception_approver_role = frappe.db.get_value('Company', | ||||
| 		frappe.flags.exception_approver_role = frappe.get_cached_value('Company',  | ||||
| 			args.get('company'),  'exception_budget_approver_role') | ||||
| 
 | ||||
| 	if not args.account: | ||||
| @ -155,7 +155,7 @@ def compare_expense_with_budget(args, budget_amount, action_for, action, budget_ | ||||
| 	actual_expense = amount or get_actual_expense(args) | ||||
| 	if actual_expense > budget_amount: | ||||
| 		diff = actual_expense - budget_amount | ||||
| 		currency = frappe.db.get_value('Company', args.company, 'default_currency') | ||||
| 		currency = frappe.get_cached_value('Company',  args.company,  'default_currency') | ||||
| 
 | ||||
| 		msg = _("{0} Budget for Account {1} against {2} {3} is {4}. It will exceed by {5}").format( | ||||
| 				_(action_for), frappe.bold(args.account), args.budget_against_field,  | ||||
|  | ||||
| @ -85,7 +85,7 @@ class ExchangeRateRevaluation(Document): | ||||
| 		if self.total_gain_loss == 0: | ||||
| 			return | ||||
| 
 | ||||
| 		unrealized_exchange_gain_loss_account = frappe.db.get_value("Company", self.company, | ||||
| 		unrealized_exchange_gain_loss_account = frappe.get_cached_value('Company',  self.company,  | ||||
| 			"unrealized_exchange_gain_loss_account") | ||||
| 		if not unrealized_exchange_gain_loss_account: | ||||
| 			frappe.throw(_("Please set Unrealized Exchange Gain/Loss Account in Company {0}") | ||||
|  | ||||
| @ -69,8 +69,8 @@ class JournalEntry(AccountsController): | ||||
| 	def validate_inter_company_accounts(self): | ||||
| 		if self.voucher_type == "Inter Company Journal Entry" and self.inter_company_journal_entry_reference: | ||||
| 			doc = frappe.get_doc("Journal Entry", self.inter_company_journal_entry_reference) | ||||
| 			account_currency = frappe.db.get_value("Company", self.company, "default_currency") | ||||
| 			previous_account_currency = frappe.db.get_value("Company", doc.company, "default_currency") | ||||
| 			account_currency = frappe.get_cached_value('Company',  self.company,  "default_currency") | ||||
| 			previous_account_currency = frappe.get_cached_value('Company',  doc.company,  "default_currency") | ||||
| 			if account_currency == previous_account_currency: | ||||
| 				if self.total_credit != doc.total_debit or self.total_debit != doc.total_credit: | ||||
| 					frappe.throw(_("Total Credit/ Debit Amount should be same as linked Journal Entry")) | ||||
| @ -611,7 +611,7 @@ def get_default_bank_cash_account(company, account_type=None, mode_of_payment=No | ||||
| 			account (of that type), otherwise return empty dict. | ||||
| 		''' | ||||
| 		if account_type=="Bank": | ||||
| 			account = frappe.db.get_value("Company", company, "default_bank_account") | ||||
| 			account = frappe.get_cached_value('Company',  company,  "default_bank_account") | ||||
| 			if not account: | ||||
| 				account_list = frappe.get_all("Account", filters = {"company": company, | ||||
| 					"account_type": "Bank", "is_group": 0}) | ||||
| @ -619,7 +619,7 @@ def get_default_bank_cash_account(company, account_type=None, mode_of_payment=No | ||||
| 					account = account_list[0].name | ||||
| 
 | ||||
| 		elif account_type=="Cash": | ||||
| 			account = frappe.db.get_value("Company", company, "default_cash_account") | ||||
| 			account = frappe.get_cached_value('Company',  company,  "default_cash_account") | ||||
| 			if not account: | ||||
| 				account_list = frappe.get_all("Account", filters = {"company": company, | ||||
| 					"account_type": "Cash", "is_group": 0}) | ||||
| @ -711,7 +711,7 @@ def get_payment_entry_against_invoice(dt, dn, amount=None,  debit_in_account_cur | ||||
| 
 | ||||
| 
 | ||||
| def get_payment_entry(ref_doc, args): | ||||
| 	cost_center = frappe.db.get_value("Company", ref_doc.company, "cost_center") | ||||
| 	cost_center = frappe.get_cached_value('Company',  ref_doc.company,  "cost_center") | ||||
| 	exchange_rate = 1 | ||||
| 	if args.get("party_account"): | ||||
| 		# Modified to include the posting date for which the exchange rate is required. | ||||
|  | ||||
| @ -133,7 +133,7 @@ class OpeningInvoiceCreationTool(Document): | ||||
| 	def get_invoice_dict(self, row=None): | ||||
| 		def get_item_dict(): | ||||
| 			default_uom = frappe.db.get_single_value("Stock Settings", "stock_uom") or _("Nos") | ||||
| 			cost_center = frappe.db.get_value("Company", self.company, "cost_center") | ||||
| 			cost_center = frappe.get_cached_value('Company',  self.company,  "cost_center") | ||||
| 			if not cost_center: | ||||
| 				frappe.throw( | ||||
| 					_("Please set the Default Cost Center in {0} company.").format(frappe.bold(self.company)) | ||||
| @ -171,7 +171,7 @@ class OpeningInvoiceCreationTool(Document): | ||||
| 			"posting_date": row.posting_date, | ||||
| 			frappe.scrub(party_type): row.party, | ||||
| 			"doctype": "Sales Invoice" if self.invoice_type == "Sales" else "Purchase Invoice", | ||||
| 			"currency": frappe.db.get_value("Company", self.company, "default_currency") | ||||
| 			"currency": frappe.get_cached_value('Company',  self.company,  "default_currency") | ||||
| 		}) | ||||
| 
 | ||||
| 		if self.invoice_type == "Sales": | ||||
|  | ||||
| @ -515,7 +515,7 @@ class PaymentEntry(AccountsController): | ||||
| 	def calculate_deductions(self, tax_details): | ||||
| 		return { | ||||
| 			"account": tax_details['tax']['account_head'], | ||||
| 			"cost_center": frappe.db.get_value("Company", self.company, "cost_center"), | ||||
| 			"cost_center": frappe.get_cached_value('Company',  self.company,  "cost_center"), | ||||
| 			"amount": self.total_allocated_amount * (tax_details['tax']['rate'] / 100) | ||||
| 		} | ||||
| 
 | ||||
| @ -535,7 +535,7 @@ def get_outstanding_reference_documents(args): | ||||
| 					return [] | ||||
| 
 | ||||
| 	party_account_currency = get_account_currency(args.get("party_account")) | ||||
| 	company_currency = frappe.db.get_value("Company", args.get("company"), "default_currency") | ||||
| 	company_currency = frappe.get_cached_value('Company',  args.get("company"),  "default_currency") | ||||
| 
 | ||||
| 	# Get negative outstanding sales /purchase invoices | ||||
| 	negative_outstanding_invoices = [] | ||||
| @ -686,7 +686,7 @@ def get_account_details(account, date): | ||||
| @frappe.whitelist() | ||||
| def get_company_defaults(company): | ||||
| 	fields = ["write_off_account", "exchange_gain_loss_account", "cost_center"] | ||||
| 	ret = frappe.db.get_value("Company", company, fields, as_dict=1) | ||||
| 	ret = frappe.get_cached_value('Company',  company,  fields, as_dict=1) | ||||
| 
 | ||||
| 	for fieldname in fields: | ||||
| 		if not ret[fieldname]: | ||||
|  | ||||
| @ -151,7 +151,7 @@ class TestPaymentEntry(unittest.TestCase): | ||||
| 
 | ||||
| 	def test_payment_entry_against_ec(self): | ||||
| 
 | ||||
| 		payable = frappe.db.get_value('Company', "_Test Company", 'default_payable_account') | ||||
| 		payable = frappe.get_cached_value('Company',  "_Test Company",  'default_payable_account') | ||||
| 		ec = make_expense_claim(payable, 300, 300, "_Test Company", "Travel Expenses - _TC") | ||||
| 		pe = get_payment_entry("Expense Claim", ec.name, bank_account="_Test Bank USD - _TC", bank_amount=300) | ||||
| 		pe.reference_no = "1" | ||||
|  | ||||
| @ -28,7 +28,7 @@ class PeriodClosingVoucher(AccountsController): | ||||
| 				.format(self.closing_account_head)) | ||||
| 
 | ||||
| 		account_currency = get_account_currency(self.closing_account_head) | ||||
| 		company_currency = frappe.db.get_value("Company", self.company, "default_currency") | ||||
| 		company_currency = frappe.get_cached_value('Company',  self.company,  "default_currency") | ||||
| 		if account_currency != company_currency: | ||||
| 			frappe.throw(_("Currency of the Closing Account must be {0}").format(company_currency)) | ||||
| 
 | ||||
|  | ||||
| @ -102,7 +102,7 @@ class POSProfile(Document): | ||||
| 
 | ||||
| def get_item_groups(pos_profile): | ||||
| 	item_groups = [] | ||||
| 	pos_profile = frappe.get_doc('POS Profile', pos_profile) | ||||
| 	pos_profile = frappe.get_cached_doc('POS Profile', pos_profile) | ||||
| 
 | ||||
| 	if pos_profile.get('item_groups'): | ||||
| 		# Get items based on the item groups defined in the POS profile | ||||
|  | ||||
| @ -14,5 +14,5 @@ class PurchaseTaxesandChargesTemplate(Document): | ||||
| 
 | ||||
| 	def autoname(self): | ||||
| 		if self.company and self.title: | ||||
| 			abbr = frappe.db.get_value('Company', self.company, 'abbr') | ||||
| 			abbr = frappe.get_cached_value('Company',  self.company,  'abbr') | ||||
| 			self.name = '{0} - {1}'.format(self.title, abbr) | ||||
|  | ||||
| @ -495,7 +495,7 @@ def make_address(args, customer): | ||||
| 		address = frappe.get_doc('Address', name) | ||||
| 	else: | ||||
| 		address = frappe.new_doc('Address') | ||||
| 		address.country = frappe.db.get_value('Company', args.get('company'), 'country') | ||||
| 		address.country = frappe.get_cached_value('Company',  args.get('company'),  'country') | ||||
| 		address.append('links', { | ||||
| 			'link_doctype': 'Customer', | ||||
| 			'link_name': customer | ||||
|  | ||||
| @ -345,7 +345,7 @@ class SalesInvoice(SellingController): | ||||
| 			update_multi_mode_option(self, pos) | ||||
| 
 | ||||
| 		if not self.account_for_change_amount: | ||||
| 			self.account_for_change_amount = frappe.db.get_value('Company', self.company, 'default_cash_account') | ||||
| 			self.account_for_change_amount = frappe.get_cached_value('Company',  self.company,  'default_cash_account') | ||||
| 
 | ||||
| 		if pos: | ||||
| 			self.allow_print_before_pay = pos.allow_print_before_pay | ||||
| @ -501,7 +501,7 @@ class SalesInvoice(SellingController): | ||||
| 
 | ||||
| 	def validate_write_off_account(self): | ||||
| 		if flt(self.write_off_amount) and not self.write_off_account: | ||||
| 			self.write_off_account = frappe.db.get_value('Company', self.company, 'write_off_account') | ||||
| 			self.write_off_account = frappe.get_cached_value('Company',  self.company,  'write_off_account') | ||||
| 
 | ||||
| 		if flt(self.write_off_amount) and not self.write_off_account: | ||||
| 			msgprint(_("Please enter Write Off Account"), raise_exception=1) | ||||
| @ -830,7 +830,7 @@ class SalesInvoice(SellingController): | ||||
| 		# write off entries, applicable if only pos | ||||
| 		if self.write_off_account and self.write_off_amount: | ||||
| 			write_off_account_currency = get_account_currency(self.write_off_account) | ||||
| 			default_cost_center = frappe.db.get_value('Company', self.company, 'cost_center') | ||||
| 			default_cost_center = frappe.get_cached_value('Company',  self.company,  'cost_center') | ||||
| 
 | ||||
| 			gl_entries.append( | ||||
| 				self.get_gl_dict({ | ||||
| @ -1285,7 +1285,7 @@ def validate_inter_company_invoice(doc, doctype): | ||||
| 		frappe.throw(_("No {0} found for Inter Company Transactions.").format(partytype)) | ||||
| 
 | ||||
| 	company = details.get("company") | ||||
| 	default_currency = frappe.db.get_value("Company", company, "default_currency") | ||||
| 	default_currency = frappe.get_cached_value('Company',  company,  "default_currency") | ||||
| 	if default_currency != doc.currency: | ||||
| 		frappe.throw(_("Company currencies of both the companies should match for Inter Company Transactions.")) | ||||
| 
 | ||||
|  | ||||
| @ -1324,14 +1324,14 @@ class TestSalesInvoice(unittest.TestCase): | ||||
| 		return si | ||||
| 
 | ||||
| 	def test_company_monthly_sales(self): | ||||
| 		existing_current_month_sales = frappe.db.get_value("Company", "_Test Company", "total_monthly_sales") | ||||
| 		existing_current_month_sales = frappe.get_cached_value('Company',  "_Test Company",  "total_monthly_sales") | ||||
| 
 | ||||
| 		si = create_sales_invoice() | ||||
| 		current_month_sales = frappe.db.get_value("Company", "_Test Company", "total_monthly_sales") | ||||
| 		current_month_sales = frappe.get_cached_value('Company',  "_Test Company",  "total_monthly_sales") | ||||
| 		self.assertEqual(current_month_sales, existing_current_month_sales + si.base_grand_total) | ||||
| 
 | ||||
| 		si.cancel() | ||||
| 		current_month_sales = frappe.db.get_value("Company", "_Test Company", "total_monthly_sales") | ||||
| 		current_month_sales = frappe.get_cached_value('Company',  "_Test Company",  "total_monthly_sales") | ||||
| 		self.assertEqual(current_month_sales, existing_current_month_sales) | ||||
| 
 | ||||
| 	def test_rounding_adjustment(self): | ||||
|  | ||||
| @ -14,7 +14,7 @@ class SalesTaxesandChargesTemplate(Document): | ||||
| 
 | ||||
| 	def autoname(self): | ||||
| 		if self.company and self.title: | ||||
| 			abbr = frappe.db.get_value('Company', self.company, 'abbr') | ||||
| 			abbr = frappe.get_cached_value('Company',  self.company,  'abbr') | ||||
| 			self.name = '{0} - {1}'.format(self.title, abbr) | ||||
| 
 | ||||
| 	def set_missing_values(self): | ||||
|  | ||||
| @ -115,7 +115,7 @@ def validate_account_for_perpetual_inventory(gl_map): | ||||
| 
 | ||||
| def round_off_debit_credit(gl_map): | ||||
| 	precision = get_field_precision(frappe.get_meta("GL Entry").get_field("debit"), | ||||
| 		currency=frappe.db.get_value("Company", gl_map[0].company, "default_currency", cache=True)) | ||||
| 		currency=frappe.get_cached_value('Company',  gl_map[0].company,  "default_currency")) | ||||
| 
 | ||||
| 	debit_credit_diff = 0.0 | ||||
| 	for entry in gl_map: | ||||
| @ -161,7 +161,7 @@ def make_round_off_gle(gl_map, debit_credit_diff): | ||||
| 	gl_map.append(round_off_gle) | ||||
| 
 | ||||
| def get_round_off_account_and_cost_center(company): | ||||
| 	round_off_account, round_off_cost_center = frappe.db.get_value("Company", company, | ||||
| 	round_off_account, round_off_cost_center = frappe.get_cached_value('Company',  company, | ||||
| 		["round_off_account", "round_off_cost_center"]) or [None, None] | ||||
| 	if not round_off_account: | ||||
| 		frappe.throw(_("Please mention Round Off Account in Company")) | ||||
|  | ||||
| @ -210,7 +210,7 @@ def get_party_account(party_type, party, company): | ||||
| 	if not account and party_type in ['Customer', 'Supplier']: | ||||
| 		default_account_name = "default_receivable_account" \ | ||||
| 			if party_type=="Customer" else "default_payable_account" | ||||
| 		account = frappe.db.get_value("Company", company, default_account_name) | ||||
| 		account = frappe.get_cached_value('Company',  company,  default_account_name) | ||||
| 
 | ||||
| 	existing_gle_currency = get_party_gle_currency(party_type, party, company) | ||||
| 	if existing_gle_currency: | ||||
| @ -273,8 +273,8 @@ def validate_party_accounts(doc): | ||||
| 
 | ||||
| 		party_account_currency = frappe.db.get_value("Account", account.account, "account_currency") | ||||
| 		existing_gle_currency = get_party_gle_currency(doc.doctype, doc.name, account.company) | ||||
| 		company_default_currency = frappe.db.get_value("Company", | ||||
| 			frappe.db.get_default("Company"), "default_currency", cache=True) | ||||
| 		company_default_currency = frappe.get_cached_value('Company', | ||||
| 			frappe.db.get_default("Company"),  "default_currency") | ||||
| 
 | ||||
| 		if existing_gle_currency and party_account_currency != existing_gle_currency: | ||||
| 			frappe.throw(_("Accounting entries have already been made in currency {0} for company {1}. Please select a receivable or payable account with currency {0}.").format(existing_gle_currency, account.company)) | ||||
| @ -402,7 +402,7 @@ def get_pyt_term_template(party_name, party_type, company=None): | ||||
| 			template = frappe.db.get_value("Supplier Group", supplier.supplier_group, fieldname='payment_terms') | ||||
| 
 | ||||
| 	if not template and company: | ||||
| 		template = frappe.db.get_value("Company", company, fieldname='payment_terms') | ||||
| 		template = frappe.get_cached_value('Company',  company,  fieldname='payment_terms') | ||||
| 	return template | ||||
| 
 | ||||
| def validate_party_frozen_disabled(party_type, party_name): | ||||
| @ -454,7 +454,7 @@ def get_dashboard_info(party_type, party): | ||||
| 	company = frappe.db.get_default("company") or frappe.get_all("Company")[0].name | ||||
| 	party_account_currency = get_party_account_currency(party_type, party, company) | ||||
| 	company_default_currency = get_default_currency() \ | ||||
| 		or frappe.db.get_value('Company', company, 'default_currency') | ||||
| 		or frappe.get_cached_value('Company',  company,  'default_currency') | ||||
| 
 | ||||
| 	if party_account_currency==company_default_currency: | ||||
| 		total_field = "base_grand_total" | ||||
|  | ||||
| @ -132,7 +132,7 @@ class ReceivablePayableReport(object): | ||||
| 		if not self.filters.get("company"): | ||||
| 			self.filters["company"] = frappe.db.get_single_value('Global Defaults', 'default_company') | ||||
| 
 | ||||
| 		company_currency = frappe.db.get_value("Company", self.filters.get("company"), "default_currency") | ||||
| 		company_currency = frappe.get_cached_value('Company',  self.filters.get("company"),  "default_currency") | ||||
| 
 | ||||
| 		return_entries = self.get_return_entries(args.get("party_type")) | ||||
| 
 | ||||
|  | ||||
| @ -11,7 +11,7 @@ def execute(filters=None): | ||||
| 	period_list = get_period_list(filters.from_fiscal_year, filters.to_fiscal_year, | ||||
| 		filters.periodicity, company=filters.company) | ||||
| 
 | ||||
| 	currency = filters.presentation_currency or frappe.db.get_value("Company", filters.company, "default_currency") | ||||
| 	currency = filters.presentation_currency or frappe.get_cached_value('Company',  filters.company,  "default_currency") | ||||
| 
 | ||||
| 	asset = get_data(filters.company, "Asset", "Debit", period_list, | ||||
| 		only_current_fiscal_year=False, filters=filters, | ||||
| @ -65,7 +65,7 @@ def get_provisional_profit_loss(asset, liability, equity, period_list, company, | ||||
| 	total_row = {} | ||||
| 	if asset and (liability or equity): | ||||
| 		total = total_row_total=0 | ||||
| 		currency = currency or frappe.db.get_value("Company", company, "default_currency") | ||||
| 		currency = currency or frappe.get_cached_value('Company',  company,  "default_currency") | ||||
| 		total_row = { | ||||
| 			"account_name": "'" + _("Total (Credit)") + "'", | ||||
| 			"account": "'" + _("Total (Credit)") + "'", | ||||
|  | ||||
| @ -29,7 +29,7 @@ def execute(filters=None): | ||||
| 	net_profit_loss = get_net_profit_loss(income, expense, period_list, filters.company) | ||||
| 
 | ||||
| 	data = [] | ||||
| 	company_currency = frappe.db.get_value("Company", filters.company, "default_currency") | ||||
| 	company_currency = frappe.get_cached_value('Company',  filters.company,  "default_currency") | ||||
| 	 | ||||
| 	for cash_flow_account in cash_flow_accounts: | ||||
| 		section_data = [] | ||||
|  | ||||
| @ -358,7 +358,7 @@ def execute(filters=None): | ||||
| 
 | ||||
| 	net_profit_loss = get_net_profit_loss(income, expense, period_list, filters.company) | ||||
| 
 | ||||
| 	company_currency = frappe.db.get_value("Company", filters.company, "default_currency") | ||||
| 	company_currency = frappe.get_cached_value('Company',  filters.company,  "default_currency") | ||||
| 
 | ||||
| 	data = compute_data(filters, company_currency, net_profit_loss, period_list, mappers, cash_flow_accounts) | ||||
| 
 | ||||
|  | ||||
| @ -58,7 +58,7 @@ def get_balance_sheet_data(fiscal_year, companies, columns, filters): | ||||
| 			"account_name": "'" + _("Unclosed Fiscal Years Profit / Loss (Credit)") + "'", | ||||
| 			"account": "'" + _("Unclosed Fiscal Years Profit / Loss (Credit)") + "'", | ||||
| 			"warn_if_negative": True, | ||||
| 			"currency": frappe.db.get_value("Company", filters.company, "default_currency") | ||||
| 			"currency": frappe.get_cached_value('Company',  filters.company,  "default_currency") | ||||
| 		} | ||||
| 		for company in companies: | ||||
| 			unclosed[company] = opening_balance | ||||
| @ -91,7 +91,7 @@ def get_profit_loss_data(fiscal_year, companies, columns, filters): | ||||
| 	return data, None, chart | ||||
| 
 | ||||
| def get_income_expense_data(companies, fiscal_year, filters): | ||||
| 	company_currency = frappe.db.get_value("Company", filters.company, "default_currency") | ||||
| 	company_currency = frappe.get_cached_value('Company',  filters.company,  "default_currency") | ||||
| 	income = get_data(companies, "Income", "Credit", fiscal_year, filters, True) | ||||
| 
 | ||||
| 	expense = get_data(companies, "Expense", "Debit", fiscal_year, filters, True) | ||||
| @ -106,7 +106,7 @@ def get_cash_flow_data(fiscal_year, companies, filters): | ||||
| 	income, expense, net_profit_loss = get_income_expense_data(companies, fiscal_year, filters) | ||||
| 
 | ||||
| 	data = [] | ||||
| 	company_currency = frappe.db.get_value("Company", filters.company, "default_currency") | ||||
| 	company_currency = frappe.get_cached_value('Company',  filters.company,  "default_currency") | ||||
| 
 | ||||
| 	for cash_flow_account in cash_flow_accounts: | ||||
| 		section_data = [] | ||||
| @ -215,7 +215,7 @@ def get_data(companies, root_type, balance_must_be, fiscal_year, filters=None, i | ||||
| 	return out | ||||
| 
 | ||||
| def get_company_currency(filters=None): | ||||
| 	return frappe.db.get_value("Company", filters.get('company'), "default_currency") | ||||
| 	return frappe.get_cached_value('Company',  filters.get('company'),  "default_currency") | ||||
| 
 | ||||
| def calculate_values(accounts_by_name, gl_entries_by_account, companies, fiscal_year, filters): | ||||
| 	for entries in gl_entries_by_account.values(): | ||||
| @ -267,7 +267,7 @@ def get_companies(filters): | ||||
| 	return all_companies, companies | ||||
| 
 | ||||
| def get_subsidiary_companies(company): | ||||
| 	lft, rgt = frappe.db.get_value('Company', | ||||
| 	lft, rgt = frappe.get_cached_value('Company',  | ||||
| 		company,  ["lft", "rgt"]) | ||||
| 
 | ||||
| 	return frappe.db.sql_list("""select name from `tabCompany` | ||||
| @ -321,7 +321,7 @@ def set_gl_entries_by_account(from_date, to_date, root_lft, root_rgt, filters, g | ||||
| 	accounts_by_name, ignore_closing_entries=False): | ||||
| 	"""Returns a dict like { "account": [gl entries], ... }""" | ||||
| 
 | ||||
| 	company_lft, company_rgt = frappe.db.get_value('Company', | ||||
| 	company_lft, company_rgt = frappe.get_cached_value('Company',  | ||||
| 		filters.get('company'),  ["lft", "rgt"]) | ||||
| 
 | ||||
| 	additional_conditions = get_additional_conditions(from_date, ignore_closing_entries, filters) | ||||
|  | ||||
| @ -162,7 +162,7 @@ def get_appropriate_currency(company, filters=None): | ||||
| 	if filters and filters.get("presentation_currency"): | ||||
| 		return filters["presentation_currency"] | ||||
| 	else: | ||||
| 		return frappe.db.get_value("Company", company, "default_currency") | ||||
| 		return frappe.get_cached_value('Company',  company,  "default_currency") | ||||
| 
 | ||||
| 
 | ||||
| def calculate_values( | ||||
|  | ||||
| @ -72,7 +72,7 @@ def validate_party(filters): | ||||
| 
 | ||||
| def set_account_currency(filters): | ||||
| 	if filters.get("account") or (filters.get('party') and len(filters.party) == 1): | ||||
| 		filters["company_currency"] = frappe.db.get_value("Company", filters.company, "default_currency") | ||||
| 		filters["company_currency"] = frappe.get_cached_value('Company',  filters.company,  "default_currency") | ||||
| 		account_currency = None | ||||
| 
 | ||||
| 		if filters.get("account"): | ||||
|  | ||||
| @ -11,7 +11,7 @@ from frappe.utils import flt | ||||
| 
 | ||||
| def execute(filters=None): | ||||
| 	if not filters: filters = frappe._dict() | ||||
| 	filters.currency = frappe.db.get_value("Company", filters.company, "default_currency") | ||||
| 	filters.currency = frappe.get_cached_value('Company',  filters.company,  "default_currency") | ||||
| 
 | ||||
| 	gross_profit_data = GrossProfitGenerator(filters) | ||||
| 
 | ||||
|  | ||||
| @ -39,7 +39,7 @@ def get_net_profit_loss(income, expense, period_list, company, currency=None, co | ||||
| 		"account_name": "'" + _("Profit for the year") + "'", | ||||
| 		"account": "'" + _("Profit for the year") + "'", | ||||
| 		"warn_if_negative": True, | ||||
| 		"currency": currency or frappe.db.get_value("Company", company, "default_currency") | ||||
| 		"currency": currency or frappe.get_cached_value('Company',  company,  "default_currency") | ||||
| 	} | ||||
| 
 | ||||
| 	has_value = False | ||||
|  | ||||
| @ -96,7 +96,7 @@ def accumulate_values_into_parents(accounts, accounts_by_name): | ||||
| 
 | ||||
| def prepare_data(accounts, filters, total_row, parent_children_map, based_on): | ||||
| 	data = [] | ||||
| 	company_currency = frappe.db.get_value("Company", filters.get("company"), "default_currency") | ||||
| 	company_currency = frappe.get_cached_value('Company',  filters.get("company"),  "default_currency") | ||||
| 
 | ||||
| 	for d in accounts: | ||||
| 		has_value = False | ||||
|  | ||||
| @ -26,7 +26,7 @@ def _execute(filters=None, additional_table_columns=None, additional_query_colum | ||||
| 	suppliers = list(set([d.supplier for d in invoice_list])) | ||||
| 	supplier_details = get_supplier_details(suppliers) | ||||
| 
 | ||||
| 	company_currency = frappe.db.get_value("Company", filters.company, "default_currency") | ||||
| 	company_currency = frappe.get_cached_value('Company',  filters.company,  "default_currency") | ||||
| 
 | ||||
| 	data = [] | ||||
| 	for inv in invoice_list: | ||||
|  | ||||
| @ -25,7 +25,7 @@ def _execute(filters, additional_table_columns=None, additional_query_columns=No | ||||
| 	#Cost Center & Warehouse Map | ||||
| 	invoice_cc_wh_map = get_invoice_cc_wh_map(invoice_list) | ||||
| 	invoice_so_dn_map = get_invoice_so_dn_map(invoice_list) | ||||
| 	company_currency = frappe.db.get_value("Company", filters.get("company"), "default_currency") | ||||
| 	company_currency = frappe.get_cached_value('Company',  filters.get("company"),  "default_currency") | ||||
| 	mode_of_payments = get_mode_of_payments([inv.name for inv in invoice_list]) | ||||
| 
 | ||||
| 	data = [] | ||||
|  | ||||
| @ -25,7 +25,7 @@ def get_data(filters, show_party_name): | ||||
| 	party_filters = {"name": filters.get("party")} if filters.get("party") else {} | ||||
| 	parties = frappe.get_all(filters.get("party_type"), fields = ["name", party_name_field],  | ||||
| 		filters = party_filters, order_by="name") | ||||
| 	company_currency = frappe.db.get_value("Company", filters.company, "default_currency") | ||||
| 	company_currency = frappe.get_cached_value('Company',  filters.company,  "default_currency") | ||||
| 	opening_balances = get_opening_balances(filters) | ||||
| 	balances_within_period = get_balances_within_period(filters) | ||||
| 
 | ||||
|  | ||||
| @ -133,7 +133,7 @@ def get_balance_on(account=None, date=None, party_type=None, party=None, company | ||||
| 
 | ||||
| 			# If group and currency same as company, | ||||
| 			# always return balance based on debit and credit in company currency | ||||
| 			if acc.account_currency == frappe.db.get_value("Company", acc.company, "default_currency"): | ||||
| 			if acc.account_currency == frappe.get_cached_value('Company',  acc.company,  "default_currency"): | ||||
| 				in_account_currency = False | ||||
| 		else: | ||||
| 			cond.append("""gle.account = "%s" """ % (frappe.db.escape(account, percent=False), )) | ||||
| @ -275,7 +275,7 @@ def add_cc(args=None): | ||||
| 
 | ||||
| 	if args.parent_cost_center == args.company: | ||||
| 		args.parent_cost_center = "{0} - {1}".format(args.parent_cost_center, | ||||
| 			frappe.db.get_value('Company', args.company, 'abbr')) | ||||
| 			frappe.get_cached_value('Company',  args.company,  'abbr')) | ||||
| 
 | ||||
| 	cc = frappe.new_doc("Cost Center") | ||||
| 	cc.update(args) | ||||
| @ -498,7 +498,7 @@ def remove_ref_doc_link_from_pe(ref_type, ref_no): | ||||
| 
 | ||||
| @frappe.whitelist() | ||||
| def get_company_default(company, fieldname): | ||||
| 	value = frappe.db.get_value("Company", company, fieldname) | ||||
| 	value = frappe.get_cached_value('Company',  company,  fieldname) | ||||
| 
 | ||||
| 	if not value: | ||||
| 		throw(_("Please set default {0} in Company {1}") | ||||
| @ -570,7 +570,7 @@ def get_stock_rbnb_difference(posting_date, company): | ||||
| 	stock_rbnb = flt(pr_valuation_amount, 2) - flt(pi_valuation_amount, 2) | ||||
| 
 | ||||
| 	# Balance as per system | ||||
| 	stock_rbnb_account = "Stock Received But Not Billed - " + frappe.db.get_value("Company", company, "abbr") | ||||
| 	stock_rbnb_account = "Stock Received But Not Billed - " + frappe.get_cached_value('Company',  company,  "abbr") | ||||
| 	sys_bal = get_balance_on(stock_rbnb_account, posting_date, in_account_currency=False) | ||||
| 
 | ||||
| 	# Amount should be credited | ||||
| @ -707,7 +707,7 @@ def get_children(doctype, parent, company, is_root=False): | ||||
| 
 | ||||
| 	if doctype == 'Account': | ||||
| 		sort_accounts(acc, is_root, key="value") | ||||
| 		company_currency = frappe.db.get_value("Company", company, "default_currency") | ||||
| 		company_currency = frappe.get_cached_value('Company',  company,  "default_currency") | ||||
| 		for each in acc: | ||||
| 			each["company_currency"] = company_currency | ||||
| 			each["balance"] = flt(get_balance_on(each.get("value"), in_account_currency=False)) | ||||
| @ -809,7 +809,7 @@ def get_autoname_with_number(number_value, doc_title, name, company): | ||||
| 		name_split=name.split("-") | ||||
| 		parts = [doc_title.strip(), name_split[len(name_split)-1].strip()] | ||||
| 	else: | ||||
| 		abbr = frappe.db.get_value("Company", company, ["abbr"], as_dict=True) | ||||
| 		abbr = frappe.get_cached_value('Company',  company,  ["abbr"], as_dict=True) | ||||
| 		parts = [doc_title.strip(), abbr.abbr] | ||||
| 	if cstr(number_value).strip(): | ||||
| 		parts.insert(0, cstr(number_value).strip()) | ||||
|  | ||||
| @ -410,7 +410,7 @@ def get_asset_naming_series(): | ||||
| def make_purchase_invoice(asset, item_code, gross_purchase_amount, company, posting_date): | ||||
| 	pi = frappe.new_doc("Purchase Invoice") | ||||
| 	pi.company = company | ||||
| 	pi.currency = frappe.db.get_value("Company", company, "default_currency") | ||||
| 	pi.currency = frappe.get_cached_value('Company',  company,  "default_currency") | ||||
| 	pi.set_posting_time = 1 | ||||
| 	pi.posting_date = posting_date | ||||
| 	pi.append("items", { | ||||
| @ -429,7 +429,7 @@ def make_purchase_invoice(asset, item_code, gross_purchase_amount, company, post | ||||
| def make_sales_invoice(asset, item_code, company, serial_no=None): | ||||
| 	si = frappe.new_doc("Sales Invoice") | ||||
| 	si.company = company | ||||
| 	si.currency = frappe.db.get_value("Company", company, "default_currency") | ||||
| 	si.currency = frappe.get_cached_value('Company',  company,  "default_currency") | ||||
| 	disposal_account, depreciation_cost_center = get_disposal_account_and_cost_center(company) | ||||
| 	si.append("items", { | ||||
| 		"item_code": item_code, | ||||
| @ -504,7 +504,7 @@ def get_asset_account(account_name, asset=None, asset_category=None, company=Non | ||||
| 				asset_category = asset_category, company = company) | ||||
| 
 | ||||
| 	if not account: | ||||
| 		account = frappe.db.get_value('Company', company, account_name) | ||||
| 		account = frappe.get_cached_value('Company',  company,  account_name) | ||||
| 
 | ||||
| 	if not account: | ||||
| 		frappe.throw(_("Set {0} in asset category {1} or company {2}") | ||||
|  | ||||
| @ -35,7 +35,7 @@ def make_depreciation_entry(asset_name, date=None): | ||||
| 	fixed_asset_account, accumulated_depreciation_account, depreciation_expense_account = \ | ||||
| 		get_depreciation_accounts(asset) | ||||
| 
 | ||||
| 	depreciation_cost_center, depreciation_series = frappe.db.get_value("Company", asset.company, | ||||
| 	depreciation_cost_center, depreciation_series = frappe.get_cached_value('Company',  asset.company,  | ||||
| 		["depreciation_cost_center", "series_for_depreciation_entry"]) | ||||
| 
 | ||||
| 	depreciation_cost_center = asset.cost_center or depreciation_cost_center | ||||
| @ -93,7 +93,7 @@ def get_depreciation_accounts(asset): | ||||
| 		depreciation_expense_account = accounts.depreciation_expense_account | ||||
| 		 | ||||
| 	if not accumulated_depreciation_account or not depreciation_expense_account: | ||||
| 		accounts = frappe.db.get_value("Company", asset.company, | ||||
| 		accounts = frappe.get_cached_value('Company',  asset.company,  | ||||
| 			["accumulated_depreciation_account", "depreciation_expense_account"]) | ||||
| 		 | ||||
| 		if not accumulated_depreciation_account: | ||||
| @ -116,7 +116,7 @@ def scrap_asset(asset_name): | ||||
| 	elif asset.status in ("Cancelled", "Sold", "Scrapped"): | ||||
| 		frappe.throw(_("Asset {0} cannot be scrapped, as it is already {1}").format(asset.name, asset.status)) | ||||
| 
 | ||||
| 	depreciation_series = frappe.db.get_value("Company", asset.company, "series_for_depreciation_entry") | ||||
| 	depreciation_series = frappe.get_cached_value('Company',  asset.company,  "series_for_depreciation_entry") | ||||
| 
 | ||||
| 	je = frappe.new_doc("Journal Entry") | ||||
| 	je.voucher_type = "Journal Entry" | ||||
| @ -189,7 +189,7 @@ def get_gl_entries_on_asset_disposal(asset, selling_amount=0): | ||||
| 
 | ||||
| @frappe.whitelist() | ||||
| def get_disposal_account_and_cost_center(company): | ||||
| 	disposal_account, depreciation_cost_center = frappe.db.get_value("Company", company, | ||||
| 	disposal_account, depreciation_cost_center = frappe.get_cached_value('Company',  company,  | ||||
| 		["disposal_account", "depreciation_cost_center"]) | ||||
| 
 | ||||
| 	if not disposal_account: | ||||
|  | ||||
| @ -36,7 +36,7 @@ class AssetValueAdjustment(Document): | ||||
| 		fixed_asset_account, accumulated_depreciation_account, depreciation_expense_account = \ | ||||
| 			get_depreciation_accounts(asset) | ||||
| 
 | ||||
| 		depreciation_cost_center, depreciation_series = frappe.db.get_value("Company", asset.company, | ||||
| 		depreciation_cost_center, depreciation_series = frappe.get_cached_value('Company',  asset.company,  | ||||
| 			["depreciation_cost_center", "series_for_depreciation_entry"]) | ||||
| 
 | ||||
| 		je = frappe.new_doc("Journal Entry") | ||||
|  | ||||
| @ -183,7 +183,7 @@ class TestPurchaseOrder(unittest.TestCase): | ||||
| 			"supplier" : "_Test Supplier", | ||||
| 			"is_subcontracted" : "No", | ||||
| 			"schedule_date": add_days(nowdate(), 1), | ||||
| 			"currency" : frappe.db.get_value("Company", "_Test Company", "default_currency"), | ||||
| 			"currency" : frappe.get_cached_value('Company',  "_Test Company",  "default_currency"), | ||||
| 			"conversion_factor" : 1, | ||||
| 			"items" : get_same_items(), | ||||
| 			"group_same_items": 1 | ||||
| @ -520,7 +520,7 @@ def create_purchase_order(**args): | ||||
| 	po.company = args.company or "_Test Company" | ||||
| 	po.supplier = args.customer or "_Test Supplier" | ||||
| 	po.is_subcontracted = args.is_subcontracted or "No" | ||||
| 	po.currency = args.currency or frappe.db.get_value("Company", po.company, "default_currency") | ||||
| 	po.currency = args.currency or frappe.get_cached_value('Company',  po.company,  "default_currency") | ||||
| 	po.conversion_factor = args.conversion_factor or 1 | ||||
| 	po.supplier_warehouse = args.supplier_warehouse or None | ||||
| 
 | ||||
|  | ||||
| @ -606,7 +606,7 @@ class AccountsController(TransactionBase): | ||||
| 	@property | ||||
| 	def company_abbr(self): | ||||
| 		if not hasattr(self, "_abbr"): | ||||
| 			self._abbr = frappe.db.get_value("Company", self.company, "abbr") | ||||
| 			self._abbr = frappe.get_cached_value('Company',  self.company,  "abbr") | ||||
| 
 | ||||
| 		return self._abbr | ||||
| 
 | ||||
| @ -841,7 +841,7 @@ def get_taxes_and_charges(master_doctype, master_name): | ||||
| 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", cache=True) | ||||
| 	company_currency = frappe.get_cached_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( | ||||
|  | ||||
| @ -12,7 +12,7 @@ def print_settings_for_item_table(doc): | ||||
| 	} | ||||
| 	doc.hide_in_print_layout = ["uom", "stock_uom"] | ||||
| 
 | ||||
| 	doc.flags.compact_item_print = cint(frappe.db.get_value("Print Settings", None, "compact_item_print")) | ||||
| 	doc.flags.compact_item_print = cint(frappe.db.get_single_value("Print Settings", "compact_item_print")) | ||||
| 
 | ||||
| 	if doc.flags.compact_item_print: | ||||
| 		doc.print_templates["description"] = "templates/print_formats/includes/item_table_description.html" | ||||
|  | ||||
| @ -8,6 +8,7 @@ from frappe import _, throw | ||||
| from erpnext.stock.get_item_details import get_bin_details | ||||
| from erpnext.stock.utils import get_incoming_rate | ||||
| from erpnext.stock.get_item_details import get_conversion_factor | ||||
| from erpnext.stock.doctype.item.item import get_item_defaults, set_item_default | ||||
| 
 | ||||
| from erpnext.controllers.stock_controller import StockController | ||||
| 
 | ||||
| @ -40,7 +41,7 @@ class SellingController(StockController): | ||||
| 		self.validate_selling_price() | ||||
| 		self.set_qty_as_per_stock_uom() | ||||
| 		self.set_po_nos() | ||||
| 		check_active_sales_items(self) | ||||
| 		set_default_income_account_for_item(self) | ||||
| 
 | ||||
| 	def set_missing_values(self, for_validate=False): | ||||
| 		super(SellingController, self).set_missing_values(for_validate) | ||||
| @ -349,24 +350,8 @@ class SellingController(StockController): | ||||
| 		from erpnext.controllers.buying_controller import validate_item_type | ||||
| 		validate_item_type(self, "is_sales_item", "sales") | ||||
| 
 | ||||
| def check_active_sales_items(obj): | ||||
| def set_default_income_account_for_item(obj): | ||||
| 	for d in obj.get("items"): | ||||
| 		if d.item_code: | ||||
| 			item = frappe.db.sql("""select i.docstatus, id.income_account | ||||
| 				from `tabItem` i, `tabItem Default` id | ||||
| 				where i.name=%s and id.parent=i.name and id.company=%s""", | ||||
| 				(d.item_code, obj.company), as_dict=True) | ||||
| 
 | ||||
| 			if getattr(d, "income_account", None): | ||||
| 				doc = frappe.get_doc("Item", d.item_code) | ||||
| 				if item and not item[0].income_account: | ||||
| 					for default in doc.item_defaults: | ||||
| 						if default.company == obj.company: | ||||
| 							default.income_account = d.income_account | ||||
| 							break | ||||
| 				elif not item: | ||||
| 					doc.append("item_defaults", { | ||||
| 						"company": obj.company, | ||||
| 						"income_account": d.income_account | ||||
| 					}) | ||||
| 				doc.save(ignore_permissions=True) | ||||
| 				set_item_default(d.item_code, obj.company, 'income_account', d.income_account) | ||||
|  | ||||
| @ -217,7 +217,7 @@ def make_quotation(source_name, target_doc=None): | ||||
| 		from erpnext.controllers.accounts_controller import get_default_taxes_and_charges | ||||
| 		quotation = frappe.get_doc(target) | ||||
| 
 | ||||
| 		company_currency = frappe.db.get_value("Company", quotation.company, "default_currency") | ||||
| 		company_currency = frappe.get_cached_value('Company',  quotation.company,  "default_currency") | ||||
| 		party_account_currency = get_party_account_currency("Customer", quotation.customer, | ||||
| 			quotation.company) if quotation.customer else company_currency | ||||
| 
 | ||||
|  | ||||
| @ -293,7 +293,7 @@ def setup_currency_exchange(): | ||||
| 	}).insert() | ||||
| 
 | ||||
| def setup_mode_of_payment(): | ||||
| 	company_abbr = frappe.db.get_value("Company", erpnext.get_default_company(), "abbr") | ||||
| 	company_abbr = frappe.get_cached_value('Company',  erpnext.get_default_company(),  "abbr") | ||||
| 	account_dict = {'Cash': 'Cash - '+ company_abbr , 'Bank': 'National Bank - '+ company_abbr} | ||||
| 	for payment_mode in frappe.get_all('Mode of Payment', fields = ["name", "type"]): | ||||
| 		if payment_mode.type: | ||||
| @ -317,7 +317,7 @@ def setup_account(): | ||||
| 	frappe.flags.in_import = False | ||||
| 
 | ||||
| def setup_account_to_expense_type(): | ||||
| 	company_abbr = frappe.db.get_value("Company", erpnext.get_default_company(), "abbr") | ||||
| 	company_abbr = frappe.get_cached_value('Company',  erpnext.get_default_company(),  "abbr") | ||||
| 	expense_types = [{'name': _('Calls'), "account": "Sales Expenses - "+ company_abbr}, | ||||
| 		{'name': _('Food'), "account": "Entertainment Expenses - "+ company_abbr}, | ||||
| 		{'name': _('Medical'), "account": "Utility Expenses - "+ company_abbr}, | ||||
| @ -354,7 +354,7 @@ def setup_budget(): | ||||
| 		budget.submit() | ||||
| 
 | ||||
| def setup_pos_profile(): | ||||
| 	company_abbr = frappe.db.get_value("Company", erpnext.get_default_company(), "abbr") | ||||
| 	company_abbr = frappe.get_cached_value('Company',  erpnext.get_default_company(),  "abbr") | ||||
| 	pos = frappe.new_doc('POS Profile') | ||||
| 	pos.user = frappe.db.get_global('demo_accounts_user') | ||||
| 	pos.pos_profile_name = "Demo POS Profile" | ||||
|  | ||||
| @ -28,7 +28,7 @@ def work(): | ||||
| 				si.posting_date = frappe.flags.current_date | ||||
| 				for d in si.get("items"): | ||||
| 					if not d.income_account: | ||||
| 						d.income_account = "Sales - {}".format(frappe.db.get_value('Company', si.company, 'abbr')) | ||||
| 						d.income_account = "Sales - {}".format(frappe.get_cached_value('Company',  si.company,  'abbr')) | ||||
| 				si.insert() | ||||
| 				si.submit() | ||||
| 				frappe.db.commit() | ||||
| @ -106,7 +106,7 @@ def make_pos_invoice(): | ||||
| 		si.posting_date = frappe.flags.current_date | ||||
| 		for d in si.get("items"): | ||||
| 			if not d.income_account: | ||||
| 				d.income_account = "Sales - {}".format(frappe.db.get_value('Company', si.company, 'abbr')) | ||||
| 				d.income_account = "Sales - {}".format(frappe.get_cached_value('Company',  si.company,  'abbr')) | ||||
| 		si.set_missing_values() | ||||
| 		make_payment_entries_for_pos_invoice(si) | ||||
| 		si.insert() | ||||
|  | ||||
| @ -78,7 +78,7 @@ def make_stock_entry_from_pro(pro_id, purpose): | ||||
| 		st.posting_date = frappe.flags.current_date | ||||
| 		st.fiscal_year = str(frappe.flags.current_date.year) | ||||
| 		for d in st.get("items"): | ||||
| 			d.cost_center = "Main - " + frappe.db.get_value('Company', st.company, 'abbr') | ||||
| 			d.cost_center = "Main - " + frappe.get_cached_value('Company',  st.company,  'abbr') | ||||
| 		st.insert() | ||||
| 		frappe.db.commit() | ||||
| 		st.submit() | ||||
|  | ||||
| @ -51,7 +51,7 @@ def work(): | ||||
| 	# get supplier details | ||||
| 	supplier = get_random("Supplier") | ||||
| 
 | ||||
| 	company_currency = frappe.db.get_value("Company", "Wind Power LLC", "default_currency") | ||||
| 	company_currency = frappe.get_cached_value('Company',  "Wind Power LLC",  "default_currency") | ||||
| 	party_account_currency = get_party_account_currency("Supplier", supplier, "Wind Power LLC") | ||||
| 	if company_currency == party_account_currency: | ||||
| 		exchange_rate = 1 | ||||
|  | ||||
| @ -84,7 +84,7 @@ def make_quotation(): | ||||
| 		# get customer, currency and exchange_rate | ||||
| 		customer = get_random("Customer") | ||||
| 
 | ||||
| 		company_currency = frappe.db.get_value("Company", "Wind Power LLC", "default_currency") | ||||
| 		company_currency = frappe.get_cached_value('Company',  "Wind Power LLC",  "default_currency") | ||||
| 		party_account_currency = get_party_account_currency("Customer", customer, "Wind Power LLC") | ||||
| 		if company_currency == party_account_currency: | ||||
| 			exchange_rate = 1 | ||||
|  | ||||
| @ -55,7 +55,7 @@ def make_delivery_note(): | ||||
| 			for d in dn.get("items"): | ||||
| 				if not d.expense_account: | ||||
| 					d.expense_account = ("Cost of Goods Sold - {0}".format( | ||||
| 						frappe.db.get_value('Company', dn.company, 'abbr'))) | ||||
| 						frappe.get_cached_value('Company',  dn.company,  'abbr'))) | ||||
| 			dn.insert() | ||||
| 			try: | ||||
| 				dn.submit() | ||||
|  | ||||
| @ -86,7 +86,7 @@ class ClinicalProcedure(Document): | ||||
| 				# in stock uom | ||||
| 				se_child.transfer_qty = flt(item.transfer_qty) | ||||
| 				se_child.conversion_factor = flt(item.conversion_factor) | ||||
| 				cost_center = frappe.db.get_value('Company', self.company, 'cost_center') | ||||
| 				cost_center = frappe.get_cached_value('Company',  self.company,  'cost_center') | ||||
| 				se_child.cost_center = cost_center | ||||
| 				se_child.expense_account = expense_account | ||||
| 		return stock_entry.as_dict() | ||||
| @ -146,7 +146,7 @@ def create_stock_entry(doc): | ||||
| 	expense_account = get_account(None, "expense_account", "Healthcare Settings", doc.company) | ||||
| 
 | ||||
| 	for item_line in stock_entry.items: | ||||
| 		cost_center = frappe.db.get_value('Company', doc.company, 'cost_center') | ||||
| 		cost_center = frappe.get_cached_value('Company',  doc.company,  'cost_center') | ||||
| 		#item_line.s_warehouse = warehouse #deaful source warehouse set, stock entry to copy to lines | ||||
| 		item_line.cost_center = cost_center | ||||
| 		#if not expense_account: | ||||
|  | ||||
| @ -48,7 +48,7 @@ def get_receivable_account(company): | ||||
|     receivable_account = get_account(None, "receivable_account", "Healthcare Settings", company) | ||||
|     if receivable_account: | ||||
|         return receivable_account | ||||
|     return frappe.db.get_value("Company", company, "default_receivable_account") | ||||
|     return frappe.get_cached_value('Company',  company,  "default_receivable_account") | ||||
| 
 | ||||
| def get_income_account(practitioner, company): | ||||
|     if(practitioner): | ||||
| @ -58,7 +58,7 @@ def get_income_account(practitioner, company): | ||||
|     income_account = get_account(None, "income_account", "Healthcare Settings", company) | ||||
|     if income_account: | ||||
|         return income_account | ||||
|     return frappe.db.get_value("Company", company, "default_income_account") | ||||
|     return frappe.get_cached_value('Company',  company,  "default_income_account") | ||||
| 
 | ||||
| def get_account(parent_type, parent_field, parent, company): | ||||
|     if(parent_type): | ||||
|  | ||||
| @ -25,7 +25,7 @@ class Department(NestedSet): | ||||
| 
 | ||||
| 	def before_rename(self, old, new, merge=False): | ||||
| 		# renaming consistency with abbreviation | ||||
| 		if not frappe.db.get_value('Company', self.company, 'abbr') in new: | ||||
| 		if not frappe.get_cached_value('Company',  self.company,  'abbr') in new: | ||||
| 			new = get_abbreviated_name(new, self.company) | ||||
| 
 | ||||
| 		return new | ||||
| @ -41,7 +41,7 @@ def on_doctype_update(): | ||||
| 	frappe.db.add_index("Department", ["lft", "rgt"]) | ||||
| 
 | ||||
| def get_abbreviated_name(name, company): | ||||
| 	abbr = frappe.db.get_value('Company', company, 'abbr') | ||||
| 	abbr = frappe.get_cached_value('Company',  company,  'abbr') | ||||
| 	new_name = '{0} - {1}'.format(name, abbr) | ||||
| 	return new_name | ||||
| 
 | ||||
|  | ||||
| @ -253,7 +253,7 @@ def get_holiday_list_for_employee(employee, raise_exception=True): | ||||
| 		company=frappe.db.get_value("Global Defaults", None, "default_company") | ||||
| 
 | ||||
| 	if not holiday_list: | ||||
| 		holiday_list = frappe.db.get_value("Company", company, "default_holiday_list") | ||||
| 		holiday_list = frappe.get_cached_value('Company',  company,  "default_holiday_list") | ||||
| 
 | ||||
| 	if not holiday_list and raise_exception: | ||||
| 		frappe.throw(_('Please set a default Holiday List for Employee {0} or Company {1}').format(employee, company)) | ||||
|  | ||||
| @ -53,11 +53,11 @@ class ExpenseClaim(AccountsController): | ||||
| 
 | ||||
| 	def set_payable_account(self): | ||||
| 		if not self.payable_account and not self.is_paid: | ||||
| 			self.payable_account = frappe.db.get_value("Company", self.company, "default_payable_account") | ||||
| 			self.payable_account = frappe.get_cached_value('Company',  self.company,  "default_payable_account") | ||||
| 
 | ||||
| 	def set_cost_center(self): | ||||
| 		if not self.cost_center: | ||||
| 			self.cost_center = frappe.db.get_value('Company', self.company, 'cost_center') | ||||
| 			self.cost_center = frappe.get_cached_value('Company',  self.company,  'cost_center') | ||||
| 
 | ||||
| 	def on_submit(self): | ||||
| 		if self.approval_status=="Draft": | ||||
| @ -311,8 +311,8 @@ def get_advances(employee, advance_id=None): | ||||
| @frappe.whitelist() | ||||
| def get_expense_claim( | ||||
| 	employee_name, company, employee_advance_name, posting_date, paid_amount, claimed_amount): | ||||
| 	default_payable_account = frappe.db.get_value("Company", company, "default_payable_account") | ||||
| 	default_cost_center = frappe.db.get_value('Company', company, 'cost_center') | ||||
| 	default_payable_account = frappe.get_cached_value('Company',  company,  "default_payable_account") | ||||
| 	default_cost_center = frappe.get_cached_value('Company',  company,  'cost_center') | ||||
| 
 | ||||
| 	expense_claim = frappe.new_doc('Expense Claim') | ||||
| 	expense_claim.company = company | ||||
|  | ||||
| @ -100,7 +100,7 @@ class TestExpenseClaim(unittest.TestCase): | ||||
| 		self.assertEquals(len(gl_entry), 0) | ||||
| 
 | ||||
| def get_payable_account(company): | ||||
| 	return frappe.db.get_value('Company', company, 'default_payable_account') | ||||
| 	return frappe.get_cached_value('Company',  company,  'default_payable_account') | ||||
| 
 | ||||
| def make_expense_claim(payable_account,claim_amount, sanctioned_amount, company, account, project=None, task_name=None): | ||||
| 	expense_claim = frappe.get_doc({ | ||||
|  | ||||
| @ -37,7 +37,7 @@ class JobOpening(WebsiteGenerator): | ||||
| 
 | ||||
| 		if self.staffing_plan and self.planned_vacancies: | ||||
| 			staffing_plan_company = frappe.db.get_value("Staffing Plan", self.staffing_plan, "company") | ||||
| 			lft, rgt = frappe.db.get_value("Company", staffing_plan_company, ["lft", "rgt"]) | ||||
| 			lft, rgt = frappe.get_cached_value('Company',  staffing_plan_company,  ["lft", "rgt"]) | ||||
| 
 | ||||
| 			designation_counts = get_designation_counts(self.designation, self.company) | ||||
| 			current_count = designation_counts['employee_count'] + designation_counts['job_openings'] | ||||
|  | ||||
| @ -196,7 +196,7 @@ class PayrollEntry(Document): | ||||
| 		return account_dict | ||||
| 
 | ||||
| 	def get_default_payroll_payable_account(self): | ||||
| 		payroll_payable_account = frappe.db.get_value("Company", | ||||
| 		payroll_payable_account = frappe.get_cached_value('Company',  | ||||
| 			{"company_name": self.company},  "default_payroll_payable_account") | ||||
| 
 | ||||
| 		if not payroll_payable_account: | ||||
|  | ||||
| @ -330,12 +330,12 @@ def get_salary_component_account(sal_comp): | ||||
| 	sal_comp.save() | ||||
| 
 | ||||
| def create_account(company): | ||||
| 	salary_account = frappe.db.get_value("Account", "Salary - " + frappe.db.get_value('Company', company, 'abbr')) | ||||
| 	salary_account = frappe.db.get_value("Account", "Salary - " + frappe.get_cached_value('Company',  company,  'abbr')) | ||||
| 	if not salary_account: | ||||
| 		frappe.get_doc({ | ||||
| 		"doctype": "Account", | ||||
| 		"account_name": "Salary", | ||||
| 		"parent_account": "Indirect Expenses - " + frappe.db.get_value('Company', company, 'abbr'), | ||||
| 		"parent_account": "Indirect Expenses - " + frappe.get_cached_value('Company',  company,  'abbr'), | ||||
| 		"company": company | ||||
| 		}).insert() | ||||
| 	return salary_account | ||||
|  | ||||
| @ -52,7 +52,7 @@ class StaffingPlan(Document): | ||||
| 				.format(overlap[0][0], staffing_plan_detail.designation))) | ||||
| 
 | ||||
| 	def validate_with_parent_plan(self, staffing_plan_detail): | ||||
| 		if not frappe.db.get_value("Company", self.company, "parent_company"): | ||||
| 		if not frappe.get_cached_value('Company',  self.company,  "parent_company"): | ||||
| 			return # No parent, nothing to validate | ||||
| 
 | ||||
| 		# Get staffing plan applicable for the company (Parent Company) | ||||
| @ -74,7 +74,7 @@ class StaffingPlan(Document): | ||||
| 					parent_company)), ParentCompanyError) | ||||
| 
 | ||||
| 		#Get vacanices already planned for all companies down the hierarchy of Parent Company | ||||
| 		lft, rgt = frappe.db.get_value("Company", parent_company, ["lft", "rgt"]) | ||||
| 		lft, rgt = frappe.get_cached_value('Company',  parent_company,  ["lft", "rgt"]) | ||||
| 		all_sibling_details = frappe.db.sql("""select sum(spd.vacancies) as vacancies, | ||||
| 			sum(spd.total_estimated_cost) as total_estimated_cost | ||||
| 			from `tabStaffing Plan Detail` spd join `tabStaffing Plan` sp on spd.parent=sp.name | ||||
| @ -123,7 +123,7 @@ def get_designation_counts(designation, company): | ||||
| 		return False | ||||
| 
 | ||||
| 	employee_counts_dict = {} | ||||
| 	lft, rgt = frappe.db.get_value("Company", company, ["lft", "rgt"]) | ||||
| 	lft, rgt = frappe.get_cached_value('Company',  company,  ["lft", "rgt"]) | ||||
| 	employee_counts_dict["employee_count"] = frappe.db.sql("""select count(*) from `tabEmployee` | ||||
| 		where designation = %s and status='Active' | ||||
| 			and company in (select name from tabCompany where lft>=%s and rgt<=%s) | ||||
| @ -148,7 +148,7 @@ def get_active_staffing_plan_details(company, designation, from_date=getdate(now | ||||
| 		and to_date >= %s and from_date <= %s """, (company, designation, from_date, to_date), as_dict = 1) | ||||
| 
 | ||||
| 	if not staffing_plan: | ||||
| 		parent_company = frappe.db.get_value("Company", company, "parent_company") | ||||
| 		parent_company = frappe.get_cached_value('Company',  company,  "parent_company") | ||||
| 		if parent_company: | ||||
| 			staffing_plan = get_active_staffing_plan_details(parent_company, | ||||
| 				designation, from_date, to_date) | ||||
|  | ||||
| @ -16,7 +16,7 @@ def execute(filters=None): | ||||
| 	emp_map = get_employee_details() | ||||
| 
 | ||||
| 	holiday_list = [emp_map[d]["holiday_list"] for d in emp_map if emp_map[d]["holiday_list"]] | ||||
| 	default_holiday_list = frappe.db.get_value("Company", filters.get("company"), "default_holiday_list") | ||||
| 	default_holiday_list = frappe.get_cached_value('Company',  filters.get("company"),  "default_holiday_list") | ||||
| 	holiday_list.append(default_holiday_list) | ||||
| 	holiday_list = list(set(holiday_list)) | ||||
| 	holiday_map = get_holiday(holiday_list, filters["month"]) | ||||
|  | ||||
| @ -105,7 +105,7 @@ class MaintenanceSchedule(TransactionBase): | ||||
| 		if employee: | ||||
| 			holiday_list = get_holiday_list_for_employee(employee) | ||||
| 		else: | ||||
| 			holiday_list = frappe.db.get_value("Company", self.company, "default_holiday_list") | ||||
| 			holiday_list = frappe.get_cached_value('Company',  self.company,  "default_holiday_list") | ||||
| 
 | ||||
| 		holidays = frappe.db.sql_list('''select holiday_date from `tabHoliday` where parent=%s''', holiday_list) | ||||
| 
 | ||||
|  | ||||
| @ -592,7 +592,7 @@ def get_bom_items_as_dict(bom, company, qty=1, fetch_exploded=1, fetch_scrap_ite | ||||
| 			["Cost Center", "cost_center", "cost_center"], ["Warehouse", "default_warehouse", ""]]: | ||||
| 				company_in_record = frappe.db.get_value(d[0], item_details.get(d[1]), "company") | ||||
| 				if not item_details.get(d[1]) or (company_in_record and company != company_in_record): | ||||
| 					item_dict[item][d[1]] = frappe.db.get_value("Company", company, d[2]) if d[2] else None | ||||
| 					item_dict[item][d[1]] = frappe.get_cached_value('Company',  company,  d[2]) if d[2] else None | ||||
| 
 | ||||
| 	return item_dict | ||||
| 
 | ||||
|  | ||||
| @ -45,7 +45,7 @@ class Workstation(Document): | ||||
| 
 | ||||
| @frappe.whitelist() | ||||
| def get_default_holiday_list(): | ||||
| 	return frappe.db.get_value("Company", frappe.defaults.get_user_default("Company"), "default_holiday_list") | ||||
| 	return frappe.get_cached_value('Company',  frappe.defaults.get_user_default("Company"),  "default_holiday_list") | ||||
| 
 | ||||
| def check_if_within_operating_hours(workstation, operation, from_datetime, to_datetime): | ||||
| 	if from_datetime and to_datetime: | ||||
|  | ||||
| @ -7,6 +7,6 @@ def execute(): | ||||
| 	currency = frappe.db.get_default("currency") | ||||
| 	for doc in frappe.get_all('Pricing Rule', fields = ["company", "name"]): | ||||
| 		if doc.company: | ||||
| 			currency = frappe.db.get_value("Company", doc.company, "default_currency") | ||||
| 			currency = frappe.get_cached_value('Company',  doc.company,  "default_currency") | ||||
| 
 | ||||
| 		frappe.db.sql("""update `tabPricing Rule` set currency = %s where name = %s""",(currency, doc.name)) | ||||
|  | ||||
| @ -6,7 +6,7 @@ import frappe | ||||
| from erpnext.regional.india.setup import update_address_template | ||||
| 
 | ||||
| def execute(): | ||||
| 	if frappe.db.get_value('Company', {'country': 'India'}, 'name'): | ||||
| 	if frappe.get_cached_value('Company',  {'country': 'India'},  'name'): | ||||
| 		address_template = frappe.db.get_value('Address Template', 'India', 'template') | ||||
| 		if not address_template or "gstin" not in address_template: | ||||
| 			update_address_template() | ||||
|  | ||||
| @ -56,7 +56,7 @@ def get_parent_account(company, master_type): | ||||
| 	parent_account = None | ||||
| 	 | ||||
| 	if "receivables_group" in frappe.db.get_table_columns("Company"): | ||||
| 		parent_account = frappe.db.get_value("Company", company, | ||||
| 		parent_account = frappe.get_cached_value('Company',  company,  | ||||
| 			"receivables_group" if master_type=="Customer" else "payables_group") | ||||
| 	if not parent_account: | ||||
| 		parent_account = frappe.db.get_value("Account", {"company": company, | ||||
|  | ||||
| @ -31,7 +31,7 @@ def execute(): | ||||
| 		sle_against_companies = frappe.db.sql_list("""select distinct company from `tabStock Ledger Entry`""") | ||||
| 
 | ||||
| 		if len(sle_against_companies) == 1: | ||||
| 			company = frappe.db.get_value("Company", sle_against_companies[0],  | ||||
| 			company = frappe.get_cached_value('Company',  sle_against_companies[0],   | ||||
| 				fieldname=["name", "abbr"], as_dict=1) | ||||
| 			set_company_to_warehouse(company.name) | ||||
| 			make_warehouse_nestedset(company) | ||||
|  | ||||
| @ -111,8 +111,8 @@ def get_regional_address_details(out, doctype, company): | ||||
| 	out.taxes = get_taxes_and_charges(master_doctype, default_tax) | ||||
| 
 | ||||
| def calculate_annual_eligible_hra_exemption(doc): | ||||
| 	basic_component = frappe.db.get_value("Company", doc.company, "basic_component") | ||||
| 	hra_component = frappe.db.get_value("Company", doc.company, "hra_component") | ||||
| 	basic_component = frappe.get_cached_value('Company',  doc.company,  "basic_component") | ||||
| 	hra_component = frappe.get_cached_value('Company',  doc.company,  "hra_component") | ||||
| 	annual_exemption, monthly_exemption, hra_amount = 0, 0, 0 | ||||
| 	if hra_component and basic_component: | ||||
| 		assignment = get_salary_assignment(doc.employee, getdate()) | ||||
|  | ||||
| @ -33,7 +33,7 @@ def validate_filters(filters, account_details): | ||||
| 
 | ||||
| def set_account_currency(filters): | ||||
| 
 | ||||
| 	filters["company_currency"] = frappe.db.get_value("Company", filters.company, "default_currency") | ||||
| 	filters["company_currency"] = frappe.get_cached_value('Company',  filters.company,  "default_currency") | ||||
| 
 | ||||
| 	return filters | ||||
| 
 | ||||
| @ -100,7 +100,7 @@ def get_gl_entries(filters): | ||||
| def get_result_as_list(data, filters): | ||||
| 	result = [] | ||||
| 
 | ||||
| 	company_currency = frappe.db.get_value("Company", filters.company, "default_currency") | ||||
| 	company_currency = frappe.get_cached_value('Company',  filters.company,  "default_currency") | ||||
| 	accounts = frappe.get_all("Account", filters={"Company": filters.company}, fields=["name", "account_number"]) | ||||
| 
 | ||||
| 	for d in data: | ||||
|  | ||||
| @ -322,7 +322,7 @@ def get_credit_limit(customer, company): | ||||
| 			credit_limit = frappe.db.get_value("Customer Group", customer_group, "credit_limit") | ||||
| 
 | ||||
| 	if not credit_limit: | ||||
| 		credit_limit = frappe.db.get_value("Company", company, "credit_limit") | ||||
| 		credit_limit = frappe.get_cached_value('Company',  company,  "credit_limit") | ||||
| 
 | ||||
| 	return flt(credit_limit) | ||||
| 
 | ||||
|  | ||||
| @ -33,8 +33,8 @@ class InstallationNote(TransactionBase): | ||||
| 		self.validate_installation_date() | ||||
| 		self.check_item_table() | ||||
| 
 | ||||
| 		from erpnext.controllers.selling_controller import check_active_sales_items | ||||
| 		check_active_sales_items(self) | ||||
| 		from erpnext.controllers.selling_controller import set_default_income_account_for_item | ||||
| 		set_default_income_account_for_item(self) | ||||
| 
 | ||||
| 	def is_serial_no_added(self, item_code, serial_no): | ||||
| 		has_serial_no = frappe.db.get_value("Item", item_code, "has_serial_no") | ||||
|  | ||||
| @ -157,7 +157,7 @@ def get_sales_summary(invoice_list): | ||||
| 	return {'net_total': net_total, 'grand_total': grand_total, 'total_qty': total_qty} | ||||
| 
 | ||||
| def get_company_currency(doc): | ||||
| 	currency = frappe.db.get_value("Company", doc.company, "default_currency") | ||||
| 	currency = frappe.get_cached_value('Company',  doc.company,  "default_currency") | ||||
| 	return frappe.get_doc('Currency', currency) | ||||
| 
 | ||||
| def get_invoices(filters): | ||||
|  | ||||
| @ -75,7 +75,7 @@ class Company(NestedSet): | ||||
| 							.format(self.get(field), self.name)) | ||||
| 
 | ||||
| 	def validate_currency(self): | ||||
| 		self.previous_default_currency = frappe.db.get_value("Company", self.name, "default_currency") | ||||
| 		self.previous_default_currency = frappe.get_cached_value('Company',  self.name,  "default_currency") | ||||
| 		if self.default_currency and self.previous_default_currency and \ | ||||
| 			self.default_currency != self.previous_default_currency and \ | ||||
| 			self.check_if_transactions_exist(): | ||||
| @ -161,7 +161,7 @@ class Company(NestedSet): | ||||
| 		frappe.flags.country_change = False | ||||
| 
 | ||||
| 		if not self.get('__islocal') and \ | ||||
| 			self.country != frappe.db.get_value('Company', self.name, 'country'): | ||||
| 			self.country != frappe.get_cached_value('Company',  self.name,  'country'): | ||||
| 			frappe.flags.country_change = True | ||||
| 
 | ||||
| 	def set_default_accounts(self): | ||||
| @ -361,7 +361,7 @@ def replace_abbr(company, old, new): | ||||
| 
 | ||||
| 
 | ||||
| def get_name_with_abbr(name, company): | ||||
| 	company_abbr = frappe.db.get_value("Company", company, "abbr") | ||||
| 	company_abbr = frappe.get_cached_value('Company',  company,  "abbr") | ||||
| 	parts = name.split(" - ") | ||||
| 
 | ||||
| 	if parts[-1].lower() != company_abbr.lower(): | ||||
| @ -505,7 +505,7 @@ def get_timeline_data(doctype, name): | ||||
| 	out = {} | ||||
| 	date_to_value_dict = {} | ||||
| 
 | ||||
| 	history = frappe.db.get_value("Company", name, "transactions_annual_history") | ||||
| 	history = frappe.get_cached_value('Company',  name,  "transactions_annual_history") | ||||
| 
 | ||||
| 	try: | ||||
| 		date_to_value_dict = json.loads(history) if history and '{' in history else None | ||||
| @ -514,7 +514,7 @@ def get_timeline_data(doctype, name): | ||||
| 
 | ||||
| 	if date_to_value_dict is None: | ||||
| 		update_transactions_annual_history(name, True) | ||||
| 		history = frappe.db.get_value("Company", name, "transactions_annual_history") | ||||
| 		history = frappe.get_cached_value('Company',  name,  "transactions_annual_history") | ||||
| 		return json.loads(history) if history and '{' in history else {} | ||||
| 
 | ||||
| 	return date_to_value_dict | ||||
|  | ||||
| @ -22,7 +22,7 @@ class EmailDigest(Document): | ||||
| 		self.from_date, self.to_date = self.get_from_to_date() | ||||
| 		self.set_dates() | ||||
| 		self._accounts = {} | ||||
| 		self.currency = frappe.db.get_value("Company", self.company, "default_currency") | ||||
| 		self.currency = frappe.get_cached_value('Company',  self.company,  "default_currency") | ||||
| 
 | ||||
| 	def get_users(self): | ||||
| 		"""get list of users""" | ||||
|  | ||||
| @ -178,7 +178,7 @@ def get_item_group_defaults(item, company): | ||||
| 	item = frappe.get_cached_doc("Item", item) | ||||
| 	item_group = frappe.get_cached_doc("Item Group", item.item_group) | ||||
| 
 | ||||
| 	for d in item_group.item_defaults: | ||||
| 	for d in item_group.item_group_defaults or []: | ||||
| 		if d.company == company: | ||||
| 			return d.as_dict() | ||||
| 
 | ||||
|  | ||||
| @ -51,7 +51,7 @@ def make_tax_account(company, account_name, tax_rate): | ||||
| 			}).insert(ignore_permissions=True, ignore_mandatory=True) | ||||
| 		except frappe.NameError: | ||||
| 			frappe.message_log.pop() | ||||
| 			abbr = frappe.db.get_value('Company', company, 'abbr') | ||||
| 			abbr = frappe.get_cached_value('Company',  company,  'abbr') | ||||
| 			account = '{0} - {1}'.format(account_name, abbr) | ||||
| 			return frappe.get_doc('Account', account) | ||||
| 
 | ||||
|  | ||||
| @ -22,7 +22,7 @@ class ShoppingCartSettings(Document): | ||||
| 
 | ||||
| 	def validate_exchange_rates_exist(self): | ||||
| 		"""check if exchange rates exist for all Price List currencies (to company's currency)""" | ||||
| 		company_currency = frappe.db.get_value("Company", self.company, "default_currency") | ||||
| 		company_currency = frappe.get_cached_value('Company',  self.company,  "default_currency") | ||||
| 		if not company_currency: | ||||
| 			msgprint(_("Please specify currency in Company") + ": " + self.company, | ||||
| 				raise_exception=ShoppingCartSetupError) | ||||
|  | ||||
| @ -51,4 +51,4 @@ def get_warehouse_account(warehouse, warehouse_account=None): | ||||
| 	return account | ||||
| 	 | ||||
| def get_company_default_inventory_account(company): | ||||
| 	return frappe.db.get_value('Company', company, 'default_inventory_account') | ||||
| 	return frappe.get_cached_value('Company',  company,  'default_inventory_account') | ||||
| @ -937,6 +937,20 @@ def get_item_defaults(item_code, company): | ||||
| 
 | ||||
| 	return out | ||||
| 
 | ||||
| def set_item_default(item_code, company, fieldname, value): | ||||
| 	item = frappe.get_cached_doc('Item', item_code) | ||||
| 
 | ||||
| 	for d in item.item_defaults: | ||||
| 		if d.company == company: | ||||
| 			if not d.get(fieldname): | ||||
| 				frappe.db.set_value(d.doctype, d.name, fieldname, value) | ||||
| 			return | ||||
| 
 | ||||
| 	# no row found, add a new row for the company | ||||
| 	d = item.append('item_defaults', {fieldname: value, company: company}) | ||||
| 	d.db_insert() | ||||
| 	item.clear_cache() | ||||
| 
 | ||||
| @frappe.whitelist() | ||||
| def get_uom_conv_factor(uom, stock_uom): | ||||
| 	uoms = [uom, stock_uom] | ||||
|  | ||||
| @ -81,7 +81,7 @@ class LandedCostVoucher(Document): | ||||
| 		total_applicable_charges = sum([flt(d.applicable_charges) for d in self.get("items")]) | ||||
| 
 | ||||
| 		precision = get_field_precision(frappe.get_meta("Landed Cost Item").get_field("applicable_charges"), | ||||
| 		currency=frappe.db.get_value("Company", self.company, "default_currency", cache=True)) | ||||
| 		currency=frappe.get_cached_value('Company',  self.company,  "default_currency")) | ||||
| 
 | ||||
| 		diff = flt(self.total_taxes_and_charges) - flt(total_applicable_charges) | ||||
| 		diff = flt(diff, precision) | ||||
|  | ||||
| @ -377,7 +377,7 @@ def make_purchase_receipt(**args): | ||||
| 		"serial_no": args.serial_no, | ||||
| 		"stock_uom": args.stock_uom or "_Test UOM", | ||||
| 		"uom": args.uom or "_Test UOM", | ||||
| 		"cost_center": args.cost_center or frappe.db.get_value('Company', pr.company, 'cost_center'), | ||||
| 		"cost_center": args.cost_center or frappe.get_cached_value('Company',  pr.company,  'cost_center'), | ||||
| 		"asset_location": args.location or "Test Location" | ||||
| 	}) | ||||
| 
 | ||||
|  | ||||
| @ -623,14 +623,14 @@ class StockEntry(StockController): | ||||
| 			["Cost Center", "cost_center", "cost_center"]]: | ||||
| 				company = frappe.db.get_value(d[0], ret.get(d[1]), "company") | ||||
| 				if not ret[d[1]] or (company and self.company != company): | ||||
| 					ret[d[1]] = frappe.db.get_value("Company", self.company, d[2]) if d[2] else None | ||||
| 					ret[d[1]] = frappe.get_cached_value('Company',  self.company,  d[2]) if d[2] else None | ||||
| 
 | ||||
| 		# update uom | ||||
| 		if args.get("uom") and for_update: | ||||
| 			ret.update(get_uom_details(args.get('item_code'), args.get('uom'), args.get('qty'))) | ||||
| 
 | ||||
| 		if not ret["expense_account"]: | ||||
| 			ret["expense_account"] = frappe.db.get_value("Company", self.company, "stock_adjustment_account") | ||||
| 			ret["expense_account"] = frappe.get_cached_value('Company',  self.company,  "stock_adjustment_account") | ||||
| 
 | ||||
| 		args['posting_date'] = self.posting_date | ||||
| 		args['posting_time'] = self.posting_time | ||||
|  | ||||
| @ -21,9 +21,9 @@ class StockReconciliation(StockController): | ||||
| 
 | ||||
| 	def validate(self): | ||||
| 		if not self.expense_account: | ||||
| 			self.expense_account = frappe.db.get_value("Company", self.company, "stock_adjustment_account") | ||||
| 			self.expense_account = frappe.get_cached_value('Company',  self.company,  "stock_adjustment_account") | ||||
| 		if not self.cost_center: | ||||
| 			self.cost_center = frappe.db.get_value("Company", self.company, "cost_center") | ||||
| 			self.cost_center = frappe.get_cached_value('Company',  self.company,  "cost_center") | ||||
| 		self.validate_posting_time() | ||||
| 		self.remove_items_with_no_change() | ||||
| 		self.validate_data() | ||||
|  | ||||
| @ -14,7 +14,7 @@ class Warehouse(NestedSet): | ||||
| 
 | ||||
| 	def autoname(self): | ||||
| 		if self.company: | ||||
| 			suffix = " - " + frappe.db.get_value("Company", self.company, "abbr") | ||||
| 			suffix = " - " + frappe.get_cached_value('Company',  self.company,  "abbr") | ||||
| 			if not self.warehouse_name.endswith(suffix): | ||||
| 				self.name = self.warehouse_name + suffix | ||||
| 		else: | ||||
| @ -87,7 +87,7 @@ class Warehouse(NestedSet): | ||||
| 			self.recalculate_bin_qty(new_name) | ||||
| 
 | ||||
| 	def get_new_warehouse_name_without_abbr(self, name): | ||||
| 		company_abbr = frappe.db.get_value("Company", self.company, "abbr") | ||||
| 		company_abbr = frappe.get_cached_value('Company',  self.company,  "abbr") | ||||
| 		parts = name.rsplit(" - ", 1) | ||||
| 
 | ||||
| 		if parts[-1].lower() == company_abbr.lower(): | ||||
|  | ||||
| @ -39,34 +39,18 @@ def get_item_details(args): | ||||
| 		} | ||||
| 	""" | ||||
| 	args = process_args(args) | ||||
| 	item_doc = frappe.get_doc("Item", args.item_code) | ||||
| 	item = item_doc | ||||
| 
 | ||||
| 	item = frappe.get_cached_doc("Item", args.item_code) | ||||
| 	validate_item_details(args, item) | ||||
| 
 | ||||
| 	out = get_basic_details(args, item) | ||||
| 
 | ||||
| 	get_party_item_code(args, item_doc, out) | ||||
| 	get_party_item_code(args, item, out) | ||||
| 
 | ||||
| 	if frappe.db.exists("Product Bundle", args.item_code): | ||||
| 		valuation_rate = 0.0 | ||||
| 		bundled_items = frappe.get_doc("Product Bundle", args.item_code) | ||||
| 
 | ||||
| 		for bundle_item in bundled_items.items: | ||||
| 			valuation_rate += \ | ||||
| 				flt(get_valuation_rate(bundle_item.item_code, args.company, out.get("warehouse")).get("valuation_rate") \ | ||||
| 					* bundle_item.qty) | ||||
| 
 | ||||
| 		out.update({ | ||||
| 			"valuation_rate": valuation_rate | ||||
| 		}) | ||||
| 
 | ||||
| 	else: | ||||
| 		out.update(get_valuation_rate(args.item_code, args.company, out.get("warehouse"))) | ||||
| 	set_valuation_rate(out, args) | ||||
| 
 | ||||
| 	update_party_blanket_order(args, out) | ||||
| 
 | ||||
| 	get_price_list_rate(args, item_doc, out) | ||||
| 	get_price_list_rate(args, item, out) | ||||
| 
 | ||||
| 	if args.customer and cint(args.is_pos): | ||||
| 		out.update(get_pos_profile_item_details(args.company, args)) | ||||
| @ -80,6 +64,24 @@ def get_item_details(args): | ||||
| 			args[key] = value | ||||
| 
 | ||||
| 	out.update(get_pricing_rule_for_item(args)) | ||||
| 
 | ||||
| 	update_stock(args, out) | ||||
| 
 | ||||
| 	if args.transaction_date and item.lead_time_days: | ||||
| 		out.schedule_date = out.lead_time_date = add_days(args.transaction_date, | ||||
| 			item.lead_time_days) | ||||
| 
 | ||||
| 	if args.get("is_subcontracted") == "Yes": | ||||
| 		out.bom = args.get('bom') or get_default_bom(args.item_code) | ||||
| 
 | ||||
| 	get_gross_profit(out) | ||||
| 	if args.doctype == 'Material Request': | ||||
| 		out.rate = args.rate or out.price_list_rate | ||||
| 		out.amount = flt(args.qty * out.rate) | ||||
| 
 | ||||
| 	return out | ||||
| 
 | ||||
| def update_stock(args, out): | ||||
| 	if (args.get("doctype") == "Delivery Note" or | ||||
| 		(args.get("doctype") == "Sales Invoice" and args.get('update_stock'))) \ | ||||
| 		and out.warehouse and out.stock_qty > 0: | ||||
| @ -99,19 +101,24 @@ def get_item_details(args): | ||||
| 			reserved_so = get_so_reservation_for_item(args) | ||||
| 			out.serial_no = get_serial_no(out, args.serial_no, sales_order=reserved_so) | ||||
| 
 | ||||
| 	if args.transaction_date and item.lead_time_days: | ||||
| 		out.schedule_date = out.lead_time_date = add_days(args.transaction_date, | ||||
| 			item.lead_time_days) | ||||
| 
 | ||||
| 	if args.get("is_subcontracted") == "Yes": | ||||
| 		out.bom = args.get('bom') or get_default_bom(args.item_code) | ||||
| def set_valuation_rate(out, args): | ||||
| 	if frappe.db.exists("Product Bundle", args.item_code): | ||||
| 		valuation_rate = 0.0 | ||||
| 		bundled_items = frappe.get_doc("Product Bundle", args.item_code) | ||||
| 
 | ||||
| 	get_gross_profit(out) | ||||
| 	if args.doctype == 'Material Request': | ||||
| 		out.rate = args.rate or out.price_list_rate | ||||
| 		out.amount = flt(args.qty * out.rate) | ||||
| 		for bundle_item in bundled_items.items: | ||||
| 			valuation_rate += \ | ||||
| 				flt(get_valuation_rate(bundle_item.item_code, args.company, out.get("warehouse")).get("valuation_rate") \ | ||||
| 					* bundle_item.qty) | ||||
| 
 | ||||
| 		out.update({ | ||||
| 			"valuation_rate": valuation_rate | ||||
| 		}) | ||||
| 
 | ||||
| 	else: | ||||
| 		out.update(get_valuation_rate(args.item_code, args.company, out.get("warehouse"))) | ||||
| 
 | ||||
| 	return out | ||||
| 
 | ||||
| def process_args(args): | ||||
| 	if isinstance(args, string_types): | ||||
| @ -215,10 +222,9 @@ def get_basic_details(args, item): | ||||
| 	warehouse = user_default_warehouse or item_defaults.get("default_warehouse") or\ | ||||
| 		item_group_defaults.get("default_warehouse") or args.warehouse | ||||
| 
 | ||||
| 	material_request_type = '' | ||||
| 	if args.get('doctype') == "Material Request" and not args.get('material_request_type'): | ||||
| 		args['material_request_type'] = frappe.db.get_value('Material Request', | ||||
| 			args.get('name'), 'material_request_type') | ||||
| 			args.get('name'), 'material_request_type', cache=True) | ||||
| 
 | ||||
| 	#Set the UOM to the Default Sales UOM or Default Purchase UOM if configured in the Item Master | ||||
| 	if not args.uom: | ||||
| @ -297,7 +303,7 @@ def get_basic_details(args, item): | ||||
| 		["Cost Center", "cost_center", "cost_center"], | ||||
| 		["Warehouse", "warehouse", ""]]: | ||||
| 			if not out[d[1]]: | ||||
| 				out[d[1]] = frappe.db.get_value("Company", args.company, d[2]) if d[2] else None | ||||
| 				out[d[1]] = frappe.get_cached_value('Company',  args.company,  d[2]) if d[2] else None | ||||
| 
 | ||||
| 	for fieldname in ("item_name", "item_group", "barcodes", "brand", "stock_uom"): | ||||
| 		out[fieldname] = item.get(fieldname) | ||||
| @ -319,12 +325,12 @@ def get_default_deferred_revenue_account(args, item): | ||||
| 	if item.enable_deferred_revenue: | ||||
| 		return (item.deferred_revenue_account | ||||
| 			or args.deferred_revenue_account | ||||
| 			or frappe.db.get_value("Company", args.company, "default_deferred_revenue_account")) | ||||
| 			or frappe.get_cached_value('Company',  args.company,  "default_deferred_revenue_account")) | ||||
| 	else: | ||||
| 		return None | ||||
| 
 | ||||
| def get_default_cost_center(args, item, item_group): | ||||
| 	return (frappe.db.get_value("Project", args.get("project"), "cost_center") | ||||
| 	return (frappe.db.get_value("Project", args.get("project"), "cost_center", cache=True) | ||||
| 		or (item.get("selling_cost_center") if args.get("customer") else item.get("buying_cost_center")) | ||||
| 		or (item_group.get("selling_cost_center") if args.get("customer") else item_group.get("buying_cost_center")) | ||||
| 		or args.get("cost_center")) | ||||
| @ -363,20 +369,12 @@ def get_price_list_rate(args, item_doc, out): | ||||
| 
 | ||||
| def insert_item_price(args): | ||||
| 	"""Insert Item Price if Price List and Price List Rate are specified and currency is the same""" | ||||
| 	if frappe.db.get_value("Price List", args.price_list, "currency") == args.currency \ | ||||
| 	if frappe.db.get_value("Price List", args.price_list, "currency", cache=True) == args.currency \ | ||||
| 		and cint(frappe.db.get_single_value("Stock Settings", "auto_insert_price_list_rate_if_missing")): | ||||
| 		if frappe.has_permission("Item Price", "write"): | ||||
| 			price_list_rate = (args.rate / args.get('conversion_factor') | ||||
| 				if args.get("conversion_factor") else args.rate) | ||||
| 
 | ||||
| 			item_price = frappe.get_doc({ | ||||
| 				"doctype": "Item Price", | ||||
| 				"price_list": args.price_list, | ||||
| 				"item_code": args.item_code, | ||||
| 				"currency": args.currency, | ||||
| 				"price_list_rate": price_list_rate | ||||
| 			}) | ||||
| 
 | ||||
| 			name = frappe.db.get_value('Item Price', | ||||
| 				{'item_code': args.item_code, 'price_list': args.price_list, 'currency': args.currency}, 'name') | ||||
| 
 | ||||
| @ -387,6 +385,13 @@ def insert_item_price(args): | ||||
| 				frappe.msgprint(_("Item Price updated for {0} in Price List {1}").format(args.item_code, | ||||
| 					args.price_list)) | ||||
| 			else: | ||||
| 				item_price = frappe.get_doc({ | ||||
| 					"doctype": "Item Price", | ||||
| 					"price_list": args.price_list, | ||||
| 					"item_code": args.item_code, | ||||
| 					"currency": args.currency, | ||||
| 					"price_list_rate": price_list_rate | ||||
| 				}) | ||||
| 				item_price.insert() | ||||
| 				frappe.msgprint(_("Item Price added for {0} in Price List {1}").format(args.item_code, | ||||
| 					args.price_list)) | ||||
| @ -501,7 +506,7 @@ def validate_conversion_rate(args, meta): | ||||
| 	from erpnext.controllers.accounts_controller import validate_conversion_rate | ||||
| 
 | ||||
| 	if (not args.conversion_rate | ||||
| 		and args.currency==frappe.db.get_value("Company", args.company, "default_currency")): | ||||
| 		and args.currency==frappe.get_cached_value('Company',  args.company,  "default_currency")): | ||||
| 		args.conversion_rate = 1.0 | ||||
| 
 | ||||
| 	# validate currency conversion rate | ||||
| @ -513,7 +518,7 @@ def validate_conversion_rate(args, meta): | ||||
| 			frappe._dict({"fields": args}))) | ||||
| 
 | ||||
| 	if (not args.plc_conversion_rate | ||||
| 		and args.price_list_currency==frappe.db.get_value("Price List", args.price_list, "currency")): | ||||
| 		and args.price_list_currency==frappe.db.get_value("Price List", args.price_list, "currency", cache=True)): | ||||
| 		args.plc_conversion_rate = 1.0 | ||||
| 
 | ||||
| 	# validate price list currency conversion rate | ||||
| @ -535,7 +540,7 @@ def get_party_item_code(args, item_doc, out): | ||||
| 		if customer_item_code: | ||||
| 			out.customer_item_code = customer_item_code[0].ref_code | ||||
| 		else: | ||||
| 			customer_group = frappe.db.get_value("Customer", args.customer, "customer_group") | ||||
| 			customer_group = frappe.db.get_value("Customer", args.customer, "customer_group", cache=True) | ||||
| 			customer_group_item_code = item_doc.get("customer_items", {"customer_group": customer_group}) | ||||
| 			if customer_group_item_code and not customer_group_item_code[0].customer_name: | ||||
| 				out.customer_item_code = customer_group_item_code[0].ref_code | ||||
| @ -547,8 +552,8 @@ def get_party_item_code(args, item_doc, out): | ||||
| def get_pos_profile_item_details(company, args, pos_profile=None, update_data=False): | ||||
| 	res = frappe._dict() | ||||
| 
 | ||||
| 	if not pos_profile: | ||||
| 		pos_profile = get_pos_profile(company, args.get('pos_profile')) | ||||
| 	if not frappe.flags.pos_profile and not pos_profile: | ||||
| 		pos_profile = frappe.flags.pos_profile = get_pos_profile(company, args.get('pos_profile')) | ||||
| 
 | ||||
| 	if pos_profile: | ||||
| 		for fieldname in ("income_account", "cost_center", "warehouse", "expense_account"): | ||||
| @ -564,7 +569,7 @@ def get_pos_profile_item_details(company, args, pos_profile=None, update_data=Fa | ||||
| @frappe.whitelist() | ||||
| def get_pos_profile(company, pos_profile=None, user=None): | ||||
| 	if pos_profile: | ||||
| 		return frappe.get_doc('POS Profile', pos_profile) | ||||
| 		return frappe.get_cached_doc('POS Profile', pos_profile) | ||||
| 
 | ||||
| 	if not user: | ||||
| 		user = frappe.session['user'] | ||||
| @ -618,7 +623,7 @@ def get_serial_no_batchwise(args, sales_order=None): | ||||
| 
 | ||||
| @frappe.whitelist() | ||||
| def get_conversion_factor(item_code, uom): | ||||
| 	variant_of = frappe.db.get_value("Item", item_code, "variant_of") | ||||
| 	variant_of = frappe.db.get_value("Item", item_code, "variant_of", cache=True) | ||||
| 	filters = {"parent": item_code, "uom": uom} | ||||
| 	if variant_of: | ||||
| 		filters["parent"] = ("in", (item_code, variant_of)) | ||||
| @ -633,7 +638,7 @@ def get_projected_qty(item_code, warehouse): | ||||
| @frappe.whitelist() | ||||
| def get_bin_details(item_code, warehouse): | ||||
| 	return frappe.db.get_value("Bin", {"item_code": item_code, "warehouse": warehouse}, | ||||
| 			["projected_qty", "actual_qty"], as_dict=True) \ | ||||
| 			["projected_qty", "actual_qty"], as_dict=True, cache=True) \ | ||||
| 			or {"projected_qty": 0, "actual_qty": 0} | ||||
| 
 | ||||
| @frappe.whitelist() | ||||
|  | ||||
| @ -100,7 +100,7 @@ class update_entries_after(object): | ||||
| 
 | ||||
| 		self.company = frappe.db.get_value("Warehouse", self.warehouse, "company") | ||||
| 		self.precision = get_field_precision(frappe.get_meta("Stock Ledger Entry").get_field("stock_value"), | ||||
| 			currency=frappe.db.get_value("Company", self.company, "default_currency", cache=True)) | ||||
| 			currency=frappe.get_cached_value('Company',  self.company,  "default_currency")) | ||||
| 
 | ||||
| 		self.prev_stock_value = self.previous_sle.stock_value or 0.0 | ||||
| 		self.stock_queue = json.loads(self.previous_sle.stock_queue or "[]") | ||||
|  | ||||
| @ -40,9 +40,9 @@ def unauthorized_user(supplier): | ||||
| 
 | ||||
| def update_supplier_details(context): | ||||
| 	supplier_doc = frappe.get_doc("Supplier", context.doc.supplier) | ||||
| 	context.doc.currency = supplier_doc.default_currency or frappe.db.get_value("Company", context.doc.company, "default_currency") | ||||
| 	context.doc.currency_symbol = frappe.db.get_value("Currency", context.doc.currency, "symbol") | ||||
| 	context.doc.number_format = frappe.db.get_value("Currency", context.doc.currency, "number_format") | ||||
| 	context.doc.currency = supplier_doc.default_currency or frappe.get_cached_value('Company',  context.doc.company,  "default_currency") | ||||
| 	context.doc.currency_symbol = frappe.db.get_value("Currency", context.doc.currency, "symbol", cache=True) | ||||
| 	context.doc.number_format = frappe.db.get_value("Currency", context.doc.currency, "number_format", cache=True) | ||||
| 	context.doc.buying_price_list = supplier_doc.default_price_list or '' | ||||
| 
 | ||||
| def get_link_quotation(supplier, rfq): | ||||
|  | ||||
| @ -27,7 +27,7 @@ def get_site_info(site_info): | ||||
| 		company = company[0][0] if company else None | ||||
| 
 | ||||
| 	if company: | ||||
| 		domain = frappe.db.get_value('Company', cstr(company), 'domain') | ||||
| 		domain = frappe.get_cached_value('Company',  cstr(company),  'domain') | ||||
| 
 | ||||
| 	return { | ||||
| 		'company': company, | ||||
|  | ||||
| @ -54,7 +54,7 @@ def get_help_messages(): | ||||
| 	if get_level() > 6: | ||||
| 		return [] | ||||
| 
 | ||||
| 	domain = frappe.db.get_value('Company', erpnext.get_default_company(), 'domain') | ||||
| 	domain = frappe.get_cached_value('Company',  erpnext.get_default_company(),  'domain') | ||||
| 	messages = [] | ||||
| 
 | ||||
| 	message_settings = [ | ||||
|  | ||||
| @ -103,7 +103,7 @@ def get_price(item_code, price_list, customer_group, company, qty=1): | ||||
| 				price_obj["formatted_price"] = fmt_money(price_obj["price_list_rate"], currency=price_obj["currency"]) | ||||
| 
 | ||||
| 				price_obj["currency_symbol"] = not cint(frappe.db.get_default("hide_currency_symbol")) \ | ||||
| 					and (frappe.db.get_value("Currency", price_obj.currency, "symbol") or price_obj.currency) \ | ||||
| 					and (frappe.db.get_value("Currency", price_obj.currency, "symbol", cache=True) or price_obj.currency) \ | ||||
| 					or "" | ||||
| 
 | ||||
| 				uom_conversion_factor = frappe.db.sql("""select	C.conversion_factor | ||||
|  | ||||
| @ -7,7 +7,7 @@ from erpnext.setup.doctype.setup_progress.setup_progress import get_action_compl | ||||
| 
 | ||||
| def get_slide_settings(): | ||||
| 	defaults = frappe.defaults.get_defaults() | ||||
| 	domain = frappe.db.get_value('Company', erpnext.get_default_company(), 'domain') | ||||
| 	domain = frappe.get_cached_value('Company',  erpnext.get_default_company(),  'domain') | ||||
| 	company = defaults.get("company") or '' | ||||
| 	currency = defaults.get("currency") or '' | ||||
| 
 | ||||
|  | ||||
| @ -234,6 +234,6 @@ def create_users(args_data): | ||||
| 
 | ||||
| @frappe.whitelist() | ||||
| def update_default_domain_actions_and_get_state(): | ||||
| 	domain = frappe.db.get_value('Company', erpnext.get_default_company(), 'domain') | ||||
| 	domain = frappe.get_cached_value('Company',  erpnext.get_default_company(),  'domain') | ||||
| 	update_domain_actions(domain) | ||||
| 	return get_domain_actions_state(domain) | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user