ignore permissions while creating records from charts builder portal
diff --git a/erpnext/accounts/doctype/account/chart_of_accounts/chart_of_accounts.py b/erpnext/accounts/doctype/account/chart_of_accounts/chart_of_accounts.py
index aaa0a18..e2e21fa 100644
--- a/erpnext/accounts/doctype/account/chart_of_accounts/chart_of_accounts.py
+++ b/erpnext/accounts/doctype/account/chart_of_accounts/chart_of_accounts.py
@@ -6,7 +6,7 @@
from frappe.utils import cstr
from unidecode import unidecode
-def create_charts(chart_name, company):
+def create_charts(chart_name, company, ignore_permissions=False):
chart = get_chart(chart_name)
if chart:
@@ -44,6 +44,8 @@
if root_account or frappe.local.flags.allow_unverified_charts:
account.flags.ignore_mandatory = True
+ account.flags.ignore_permissions = ignore_permissions
+
account.insert()
accounts.append(account_name_in_db)
diff --git a/erpnext/accounts/utils.py b/erpnext/accounts/utils.py
index 077fcb4..683b84b 100644
--- a/erpnext/accounts/utils.py
+++ b/erpnext/accounts/utils.py
@@ -131,12 +131,18 @@
args.pop("cmd")
ac = frappe.new_doc("Account")
+
+ if args.get("ignore_permissions"):
+ ac.flags.ignore_permissions = True
+ args.pop("ignore_permissions")
+
ac.update(args)
ac.old_parent = ""
ac.freeze_account = "No"
if cint(ac.get("is_root")):
ac.parent_account = None
- ac.flags.ignore_mandatory = True
+ ac.flags.ignore_mandatory = True
+
ac.insert()
return ac.name
diff --git a/erpnext/setup/doctype/company/company.py b/erpnext/setup/doctype/company/company.py
index c12fb8c..800e19e 100644
--- a/erpnext/setup/doctype/company/company.py
+++ b/erpnext/setup/doctype/company/company.py
@@ -67,7 +67,7 @@
self.create_default_accounts()
self.create_default_warehouses()
- self.install_country_fixtures()
+ self.install_country_fixtures()
if not frappe.db.get_value("Cost Center", {"is_group": 0, "company": self.name}):
self.create_default_cost_center()
@@ -92,19 +92,21 @@
stock_group = frappe.db.get_value("Account", {"account_type": "Stock",
"is_group": 1, "company": self.name})
if stock_group:
- frappe.get_doc({
+ warehouse = frappe.get_doc({
"doctype":"Warehouse",
"warehouse_name": whname,
"company": self.name,
"create_account_under": stock_group
- }).insert()
+ })
+ warehouse.flags.ignore_permissions = self.flags.ignore_permissions
+ warehouse.insert()
def create_default_accounts(self):
if not self.chart_of_accounts:
self.chart_of_accounts = "Standard"
from erpnext.accounts.doctype.account.chart_of_accounts.chart_of_accounts import create_charts
- create_charts(self.chart_of_accounts, self.name)
+ create_charts(self.chart_of_accounts, self.name, self.flags.ignore_permissions)
frappe.db.set(self, "default_receivable_account", frappe.db.get_value("Account",
{"company": self.name, "account_type": "Receivable"}))
diff --git a/erpnext/setup/doctype/company/fixtures/india/__init__.py b/erpnext/setup/doctype/company/fixtures/india/__init__.py
index 55185ac..e39c410 100644
--- a/erpnext/setup/doctype/company/fixtures/india/__init__.py
+++ b/erpnext/setup/doctype/company/fixtures/india/__init__.py
@@ -14,6 +14,8 @@
for d in docs:
try:
- frappe.get_doc(d).insert()
+ doc = frappe.get_doc(d)
+ doc.flags.ignore_permissions = True
+ doc.insert()
except frappe.NameError:
pass