From f49b08562567d112471fdeecfe8d8c3eb6e6e861 Mon Sep 17 00:00:00 2001 From: Neil Trini Lasrado Date: Tue, 13 Oct 2015 14:54:26 +0530 Subject: [PATCH 1/4] Allowed Income account to be added to Cost Center --- erpnext/accounts/doctype/cost_center/cost_center.js | 3 +-- erpnext/accounts/doctype/cost_center/cost_center.py | 6 +++--- erpnext/accounts/utils.py | 2 +- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/erpnext/accounts/doctype/cost_center/cost_center.js b/erpnext/accounts/doctype/cost_center/cost_center.js index fb649e6d1b..e4db510cad 100644 --- a/erpnext/accounts/doctype/cost_center/cost_center.js +++ b/erpnext/accounts/doctype/cost_center/cost_center.js @@ -17,8 +17,7 @@ erpnext.accounts.CostCenterController = frappe.ui.form.Controller.extend({ return { filters:[ ['Account', 'company', '=', me.frm.doc.company], - ['Account', 'root_type', '=', 'Expense'], - ['Account', 'is_group', '=', '0'], + ['Account', 'is_group', '=', '0'] ] } }); diff --git a/erpnext/accounts/doctype/cost_center/cost_center.py b/erpnext/accounts/doctype/cost_center/cost_center.py index 0f51a00cd6..072bf60863 100644 --- a/erpnext/accounts/doctype/cost_center/cost_center.py +++ b/erpnext/accounts/doctype/cost_center/cost_center.py @@ -32,13 +32,13 @@ class CostCenter(NestedSet): for d in self.get('budgets'): if d.account: account_details = frappe.db.get_value("Account", d.account, - ["is_group", "company", "root_type"], as_dict=1) + ["is_group", "company", "report_type"], as_dict=1) if account_details.is_group: frappe.throw(_("Budget cannot be assigned against Group Account {0}").format(d.account)) elif account_details.company != self.company: frappe.throw(_("Account {0} does not belongs to company {1}").format(d.account, self.company)) - elif account_details.root_type != "Expense": - frappe.throw(_("Budget cannot be assigned against {0}, as it's not an Expense account") + elif account_details.report_type != "Profit and Loss": + frappe.throw(_("Budget cannot be assigned against {0}, as it's not an Income or Expense account") .format(d.account)) if [d.account, d.fiscal_year] in check_acc_list: diff --git a/erpnext/accounts/utils.py b/erpnext/accounts/utils.py index 199769416e..07606be1f7 100644 --- a/erpnext/accounts/utils.py +++ b/erpnext/accounts/utils.py @@ -310,7 +310,7 @@ def get_stock_and_account_difference(account_list=None, posting_date=None): def validate_expense_against_budget(args): args = frappe._dict(args) - if frappe.db.get_value("Account", {"name": args.account, "report_type": "Profit and Loss"}): + if frappe.db.get_value("Account", {"name": args.account, "root_type": "Expense"}): budget = frappe.db.sql(""" select bd.budget_allocated, cc.distribution_id from `tabCost Center` cc, `tabBudget Detail` bd From 486bf2e1132f3b4e85c7ab04f706c6f22121fd99 Mon Sep 17 00:00:00 2001 From: Neil Trini Lasrado Date: Tue, 13 Oct 2015 15:17:53 +0530 Subject: [PATCH 2/4] Added Change Log --- erpnext/change_log/current/cost_center.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 erpnext/change_log/current/cost_center.md diff --git a/erpnext/change_log/current/cost_center.md b/erpnext/change_log/current/cost_center.md new file mode 100644 index 0000000000..956d4fc0f4 --- /dev/null +++ b/erpnext/change_log/current/cost_center.md @@ -0,0 +1 @@ +- Allowed Income account to be added to Cost Center \ No newline at end of file From ec5deb6e48bfba790b7ddc5d86bd8d884db2997b Mon Sep 17 00:00:00 2001 From: Neil Trini Lasrado Date: Tue, 13 Oct 2015 15:28:12 +0530 Subject: [PATCH 3/4] Changed label in Company --- erpnext/setup/doctype/company/company.json | 110 +-------------------- 1 file changed, 5 insertions(+), 105 deletions(-) diff --git a/erpnext/setup/doctype/company/company.json b/erpnext/setup/doctype/company/company.json index 12faa18ed5..d215066b27 100644 --- a/erpnext/setup/doctype/company/company.json +++ b/erpnext/setup/doctype/company/company.json @@ -702,7 +702,7 @@ "ignore_user_permissions": 0, "in_filter": 0, "in_list_view": 0, - "label": "If Yearly Budget Exceeded", + "label": "If Yearly Budget Exceeded (for expense account)", "no_copy": 0, "oldfieldname": "yearly_bgt_flag", "oldfieldtype": "Select", @@ -727,7 +727,7 @@ "ignore_user_permissions": 0, "in_filter": 0, "in_list_view": 0, - "label": "If Monthly Budget Exceeded", + "label": "If Monthly Budget Exceeded (for expense account)", "no_copy": 0, "oldfieldname": "monthly_bgt_flag", "oldfieldtype": "Select", @@ -1092,7 +1092,7 @@ "is_submittable": 0, "issingle": 0, "istable": 0, - "modified": "2015-09-14 02:55:54.678003", + "modified": "2015-10-13 05:57:44.817277", "modified_by": "Administrator", "module": "Setup", "name": "Company", @@ -1120,7 +1120,7 @@ }, { "amend": 0, - "apply_user_permissions": 0, + "apply_user_permissions": 1, "cancel": 0, "create": 0, "delete": 0, @@ -1132,107 +1132,7 @@ "print": 1, "read": 1, "report": 0, - "role": "Accounts User", - "set_user_permissions": 0, - "share": 0, - "submit": 0, - "write": 0 - }, - { - "amend": 0, - "apply_user_permissions": 0, - "cancel": 0, - "create": 0, - "delete": 0, - "email": 0, - "export": 0, - "if_owner": 0, - "import": 0, - "permlevel": 0, - "print": 0, - "read": 1, - "report": 0, - "role": "Employee", - "set_user_permissions": 0, - "share": 0, - "submit": 0, - "write": 0 - }, - { - "amend": 0, - "apply_user_permissions": 0, - "cancel": 0, - "create": 0, - "delete": 0, - "email": 0, - "export": 0, - "if_owner": 0, - "import": 0, - "permlevel": 0, - "print": 0, - "read": 1, - "report": 0, - "role": "Sales User", - "set_user_permissions": 0, - "share": 0, - "submit": 0, - "write": 0 - }, - { - "amend": 0, - "apply_user_permissions": 0, - "cancel": 0, - "create": 0, - "delete": 0, - "email": 0, - "export": 0, - "if_owner": 0, - "import": 0, - "permlevel": 0, - "print": 0, - "read": 1, - "report": 0, - "role": "Purchase User", - "set_user_permissions": 0, - "share": 0, - "submit": 0, - "write": 0 - }, - { - "amend": 0, - "apply_user_permissions": 0, - "cancel": 0, - "create": 0, - "delete": 0, - "email": 0, - "export": 0, - "if_owner": 0, - "import": 0, - "permlevel": 0, - "print": 0, - "read": 1, - "report": 0, - "role": "Stock User", - "set_user_permissions": 0, - "share": 0, - "submit": 0, - "write": 0 - }, - { - "amend": 0, - "apply_user_permissions": 0, - "cancel": 0, - "create": 0, - "delete": 0, - "email": 0, - "export": 0, - "if_owner": 0, - "import": 0, - "permlevel": 0, - "print": 0, - "read": 1, - "report": 0, - "role": "Projects User", + "role": "All", "set_user_permissions": 0, "share": 0, "submit": 0, From 58e959085093b46fac0998a4a52000c6b143c29d Mon Sep 17 00:00:00 2001 From: Neil Trini Lasrado Date: Tue, 13 Oct 2015 17:40:43 +0530 Subject: [PATCH 4/4] Fixed issues with Permissions in Company Doctype --- erpnext/setup/doctype/company/company.json | 106 ++++++++++++++++++++- 1 file changed, 103 insertions(+), 3 deletions(-) diff --git a/erpnext/setup/doctype/company/company.json b/erpnext/setup/doctype/company/company.json index d215066b27..910fc2e489 100644 --- a/erpnext/setup/doctype/company/company.json +++ b/erpnext/setup/doctype/company/company.json @@ -1092,7 +1092,7 @@ "is_submittable": 0, "issingle": 0, "istable": 0, - "modified": "2015-10-13 05:57:44.817277", + "modified": "2015-10-13 08:15:29.028637", "modified_by": "Administrator", "module": "Setup", "name": "Company", @@ -1120,7 +1120,7 @@ }, { "amend": 0, - "apply_user_permissions": 1, + "apply_user_permissions": 0, "cancel": 0, "create": 0, "delete": 0, @@ -1132,7 +1132,107 @@ "print": 1, "read": 1, "report": 0, - "role": "All", + "role": "Accounts User", + "set_user_permissions": 0, + "share": 0, + "submit": 0, + "write": 0 + }, + { + "amend": 0, + "apply_user_permissions": 0, + "cancel": 0, + "create": 0, + "delete": 0, + "email": 0, + "export": 0, + "if_owner": 0, + "import": 0, + "permlevel": 0, + "print": 0, + "read": 1, + "report": 0, + "role": "Employee", + "set_user_permissions": 0, + "share": 0, + "submit": 0, + "write": 0 + }, + { + "amend": 0, + "apply_user_permissions": 0, + "cancel": 0, + "create": 0, + "delete": 0, + "email": 0, + "export": 0, + "if_owner": 0, + "import": 0, + "permlevel": 0, + "print": 0, + "read": 1, + "report": 0, + "role": "Sales User", + "set_user_permissions": 0, + "share": 0, + "submit": 0, + "write": 0 + }, + { + "amend": 0, + "apply_user_permissions": 0, + "cancel": 0, + "create": 0, + "delete": 0, + "email": 0, + "export": 0, + "if_owner": 0, + "import": 0, + "permlevel": 0, + "print": 0, + "read": 1, + "report": 0, + "role": "Purchase User", + "set_user_permissions": 0, + "share": 0, + "submit": 0, + "write": 0 + }, + { + "amend": 0, + "apply_user_permissions": 0, + "cancel": 0, + "create": 0, + "delete": 0, + "email": 0, + "export": 0, + "if_owner": 0, + "import": 0, + "permlevel": 0, + "print": 0, + "read": 1, + "report": 0, + "role": "Stock User", + "set_user_permissions": 0, + "share": 0, + "submit": 0, + "write": 0 + }, + { + "amend": 0, + "apply_user_permissions": 0, + "cancel": 0, + "create": 0, + "delete": 0, + "email": 0, + "export": 0, + "if_owner": 0, + "import": 0, + "permlevel": 0, + "print": 0, + "read": 1, + "report": 0, + "role": "Projects User", "set_user_permissions": 0, "share": 0, "submit": 0,