Merge pull request #16490 from nabinhait/gst_settings_perm
GST Settings permission and regional taxes creation
This commit is contained in:
commit
1467962f8a
@ -581,4 +581,5 @@ erpnext.patches.v10_0.repost_gle_for_purchase_receipts_with_rejected_items
|
||||
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
|
||||
erpnext.patches.v11_0.renamed_from_to_fields_in_project
|
||||
erpnext.patches.v11_0.add_permissions_in_gst_settings
|
12
erpnext/patches/v11_0/add_permissions_in_gst_settings.py
Normal file
12
erpnext/patches/v11_0/add_permissions_in_gst_settings.py
Normal file
@ -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)
|
@ -21,5 +21,23 @@ frappe.ui.form.on('GST Settings', {
|
||||
</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
|
||||
}
|
||||
};
|
||||
});
|
||||
}
|
||||
});
|
||||
|
@ -5,7 +5,7 @@ from __future__ import unicode_literals
|
||||
|
||||
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_custom_roles_for_reports():
|
||||
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")
|
||||
|
@ -94,6 +94,9 @@ class Company(NestedSet):
|
||||
|
||||
if frappe.flags.country_change:
|
||||
install_country_fixtures(self.name)
|
||||
self.create_default_tax_template()
|
||||
|
||||
|
||||
|
||||
if not frappe.db.get_value("Department", {"company": self.name}):
|
||||
from erpnext.setup.setup_wizard.operations.install_fixtures import install_post_company_fixtures
|
||||
@ -336,6 +339,9 @@ class Company(NestedSet):
|
||||
frappe.db.sql("delete from tabDepartment where company=%s", self.name)
|
||||
frappe.db.sql("delete from `tabTax Withholding Account` where company=%s", self.name)
|
||||
|
||||
frappe.db.sql("delete from `tabSales Taxes and Charges Template` where company=%s", self.name)
|
||||
frappe.db.sql("delete from `tabPurchase Taxes and Charges Template` where company=%s", self.name)
|
||||
|
||||
@frappe.whitelist()
|
||||
def enqueue_replace_abbr(company, old, new):
|
||||
kwargs = dict(company=company, old=old, new=new)
|
||||
|
@ -6,7 +6,7 @@ from __future__ import unicode_literals
|
||||
import frappe
|
||||
from frappe import _
|
||||
|
||||
from .operations import install_fixtures as fixtures, company_setup, taxes_setup, sample_data
|
||||
from .operations import install_fixtures as fixtures, company_setup, sample_data
|
||||
|
||||
def get_setup_stages(args=None):
|
||||
if frappe.db.sql("select name from tabCompany"):
|
||||
@ -37,18 +37,13 @@ def get_setup_stages(args=None):
|
||||
]
|
||||
},
|
||||
{
|
||||
'status': _('Setting up company and taxes'),
|
||||
'status': _('Setting up company'),
|
||||
'fail_msg': _('Failed to setup company'),
|
||||
'tasks': [
|
||||
{
|
||||
'fn': setup_company,
|
||||
'args': args,
|
||||
'fail_msg': _("Failed to setup company")
|
||||
},
|
||||
{
|
||||
'fn': setup_taxes,
|
||||
'args': args,
|
||||
'fail_msg': _("Failed to setup taxes")
|
||||
}
|
||||
]
|
||||
},
|
||||
@ -94,9 +89,6 @@ def stage_fixtures(args):
|
||||
def setup_company(args):
|
||||
fixtures.install_company(args)
|
||||
|
||||
def setup_taxes(args):
|
||||
taxes_setup.create_sales_tax(args)
|
||||
|
||||
def setup_post_company_fixtures(args):
|
||||
fixtures.install_post_company_fixtures(args)
|
||||
|
||||
@ -132,7 +124,6 @@ def login_as_first_user(args):
|
||||
def setup_complete(args=None):
|
||||
stage_fixtures(args)
|
||||
setup_company(args)
|
||||
setup_taxes(args)
|
||||
setup_post_company_fixtures(args)
|
||||
setup_defaults(args)
|
||||
stage_four(args)
|
||||
|
Loading…
x
Reference in New Issue
Block a user