Anand Doshi | 227b238 | 2016-06-09 16:29:12 +0530 | [diff] [blame] | 1 | # -*- coding: utf-8 -*- |
| 2 | from __future__ import unicode_literals |
Rushabh Mehta | 86a824c | 2016-04-15 16:44:44 +0530 | [diff] [blame] | 3 | import frappe |
| 4 | |
Nabin Hait | e7e920b | 2016-10-03 14:42:53 +0600 | [diff] [blame^] | 5 | __version__ = '7.0.52' |
Anand Doshi | 227b238 | 2016-06-09 16:29:12 +0530 | [diff] [blame] | 6 | |
Rushabh Mehta | 86a824c | 2016-04-15 16:44:44 +0530 | [diff] [blame] | 7 | def get_default_company(user=None): |
| 8 | '''Get default company for user''' |
| 9 | from frappe.defaults import get_user_default_as_list |
| 10 | |
| 11 | if not user: |
| 12 | user = frappe.session.user |
| 13 | |
| 14 | companies = get_user_default_as_list(user, 'company') |
| 15 | if companies: |
| 16 | default_company = companies[0] |
| 17 | else: |
| 18 | default_company = frappe.db.get_single_value('Global Defaults', 'default_company') |
| 19 | |
| 20 | return default_company |
| 21 | |
| 22 | def get_default_currency(): |
| 23 | '''Returns the currency of the default company''' |
| 24 | company = get_default_company() |
| 25 | if company: |
Anand Doshi | 227b238 | 2016-06-09 16:29:12 +0530 | [diff] [blame] | 26 | return frappe.db.get_value('Company', company, 'default_currency') |