fix: Added permission via regional setup and patch

This commit is contained in:
marination 2020-05-27 21:53:01 +05:30
parent 3da51984f2
commit 29d7a7ea05
4 changed files with 34 additions and 43 deletions

View File

@ -694,3 +694,4 @@ execute:frappe.delete_doc("Report", "Department Analytics")
execute:frappe.rename_doc("Desk Page", "Loan Management", "Loan", force=True)
erpnext.patches.v12_0.update_uom_conversion_factor
erpnext.patches.v13_0.delete_old_purchase_reports
erpnext.patches.v12_0.set_italian_import_supplier_invoice_permissions

View File

@ -0,0 +1,12 @@
# Copyright (c) 2017, Frappe and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import frappe
from erpnext.regional.italy.setup import add_permissions
def execute():
countries = frappe.get_all("Company", fields="country")
countries = [country["country"] for country in countries]
if "Italy" in countries:
add_permissions()

View File

@ -96,49 +96,7 @@
"module": "Regional",
"name": "Import Supplier Invoice",
"owner": "Administrator",
"permissions": [
{
"create": 1,
"email": 1,
"print": 1,
"read": 1,
"report": 1,
"role": "Accounts User",
"share": 1,
"write": 1
},
{
"email": 1,
"print": 1,
"read": 1,
"report": 1,
"role": "Purchase User"
},
{
"create": 1,
"delete": 1,
"email": 1,
"print": 1,
"read": 1,
"report": 1,
"role": "Accounts Manager",
"share": 1,
"write": 1
},
{
"email": 1,
"print": 1,
"read": 1,
"report": 1,
"role": "Auditor"
},
{
"permlevel": 1,
"read": 1,
"role": "Accounts Manager",
"write": 1
}
],
"permissions": [],
"sort_field": "modified",
"sort_order": "DESC",
"track_changes": 1

View File

@ -7,11 +7,13 @@ from __future__ import unicode_literals
import frappe
from frappe import _
from frappe.custom.doctype.custom_field.custom_field import create_custom_fields
from frappe.permissions import add_permission, update_permission_property
from erpnext.regional.italy import fiscal_regimes, tax_exemption_reasons, mode_of_payment_codes, vat_collectability_options
def setup(company=None, patch=True):
make_custom_fields()
setup_report()
add_permissions()
def make_custom_fields(update=True):
invoice_item_fields = [
@ -200,3 +202,21 @@ def setup_report():
dict(role='Accounts Manager')
]
)).insert()
def add_permissions():
doctype = 'Import Supplier Invoice'
add_permission(doctype, 'All', 0)
for role in ('Accounts Manager', 'Accounts User','Purchase User', 'Auditor'):
add_permission(doctype, role, 0)
update_permission_property(doctype, role, 0, 'print', 1)
update_permission_property(doctype, role, 0, 'report', 1)
if role in ('Accounts Manager', 'Accounts User'):
update_permission_property(doctype, role, 0, 'write', 1)
update_permission_property(doctype, role, 0, 'create', 1)
update_permission_property(doctype, 'Accounts Manager', 0, 'delete', 1)
add_permission(doctype, 'Accounts Manager', 1)
update_permission_property(doctype, 'Accounts Manager', 1, 'write', 1)
update_permission_property(doctype, 'Accounts Manager', 1, 'create', 1)