fix: Added permissions in GST Settings and added filters for accounts based on company
diff --git a/erpnext/patches.txt b/erpnext/patches.txt
index 69ad5d1..1544f99 100755
--- a/erpnext/patches.txt
+++ b/erpnext/patches.txt
@@ -581,4 +581,5 @@
erpnext.patches.v11_0.set_missing_gst_hsn_code
erpnext.patches.v11_0.rename_bom_wo_fields
erpnext.patches.v11_0.rename_additional_salary_component_additional_salary
-erpnext.patches.v11_0.renamed_from_to_fields_in_project
\ No newline at end of file
+erpnext.patches.v11_0.renamed_from_to_fields_in_project
+erpnext.patches.v11_0.add_permissions_in_gst_settings
\ No newline at end of file
diff --git a/erpnext/patches/v11_0/add_permissions_in_gst_settings.py b/erpnext/patches/v11_0/add_permissions_in_gst_settings.py
new file mode 100644
index 0000000..e8fcf33
--- /dev/null
+++ b/erpnext/patches/v11_0/add_permissions_in_gst_settings.py
@@ -0,0 +1,12 @@
+import frappe
+from frappe.permissions import add_permission, update_permission_property
+
+def execute():
+ company = frappe.get_all('Company', filters = {'country': 'India'})
+ if not company:
+ return
+
+ for doctype in ('GST HSN Code', 'GST Settings'):
+ add_permission(doctype, 'Accounts Manager', 0)
+ update_permission_property(doctype, 'Accounts Manager', 0, 'write', 1)
+ update_permission_property(doctype, 'Accounts Manager', 0, 'create', 1)
\ No newline at end of file
diff --git a/erpnext/regional/doctype/gst_settings/gst_settings.js b/erpnext/regional/doctype/gst_settings/gst_settings.js
index ab2358f..808f9bc 100644
--- a/erpnext/regional/doctype/gst_settings/gst_settings.js
+++ b/erpnext/regional/doctype/gst_settings/gst_settings.js
@@ -21,5 +21,23 @@
</tr>
</tbody></table>`
);
+ },
+
+ setup: function(frm) {
+ $.each(["cgst_account", "sgst_account", "igst_account", "cess_account"], function(i, field) {
+ frm.events.filter_accounts(frm, field);
+ });
+ },
+
+ filter_accounts: function(frm, account_field) {
+ frm.set_query(account_field, "gst_accounts", function(doc, cdt, cdn) {
+ var row = locals[cdt][cdn];
+ return {
+ filters: {
+ company: row.company,
+ is_group: 0
+ }
+ };
+ });
}
});
diff --git a/erpnext/regional/india/setup.py b/erpnext/regional/india/setup.py
index ec4da0d..a6d723a 100644
--- a/erpnext/regional/india/setup.py
+++ b/erpnext/regional/india/setup.py
@@ -5,7 +5,7 @@
import frappe, os, json
from frappe.custom.doctype.custom_field.custom_field import create_custom_fields
-from frappe.permissions import add_permission
+from frappe.permissions import add_permission, update_permission_property
from erpnext.regional.india import states
from erpnext.accounts.utils import get_fiscal_year
from frappe.utils import today
@@ -79,6 +79,9 @@
def add_permissions():
for doctype in ('GST HSN Code', 'GST Settings'):
add_permission(doctype, 'All', 0)
+ add_permission(doctype, 'Accounts Manager', 0)
+ update_permission_property(doctype, 'Accounts Manager', 0, 'write', 1)
+ update_permission_property(doctype, 'Accounts Manager', 0, 'create', 1)
def add_print_formats():
frappe.reload_doc("regional", "print_format", "gst_tax_invoice")