Browse Source

fix: patch failing while migrating from v7 to v13

develop
Rohit Waghchaure 4 years ago
parent
commit
a8f78fabfd
  1. 2
      erpnext/hooks.py
  2. 2
      erpnext/patches.txt
  3. 16
      erpnext/patches/v13_0/make_non_standard_user_type.py
  4. 12
      erpnext/setup/install.py

2
erpnext/hooks.py

@ -307,6 +307,8 @@ auto_cancel_exempted_doctypes= [
"Inpatient Medication Entry"
]
after_migrate = ["erpnext.setup.install.update_select_perm_after_install"]
scheduler_events = {
"cron": {
"0/30 * * * *": [

2
erpnext/patches.txt

@ -771,4 +771,4 @@ erpnext.patches.v12_0.add_gst_category_in_delivery_note
erpnext.patches.v12_0.purchase_receipt_status
erpnext.patches.v13_0.fix_non_unique_represents_company
erpnext.patches.v12_0.add_document_type_field_for_italy_einvoicing
erpnext.patches.v13_0.make_non_standard_user_type #31-03-2020
erpnext.patches.v13_0.make_non_standard_user_type #13-04-2021

16
erpnext/patches/v13_0/make_non_standard_user_type.py

@ -2,7 +2,23 @@
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import frappe
from six import iteritems
from erpnext.setup.install import add_non_standard_user_types
def execute():
doctype_dict = {
'projects': ['Timesheet'],
'payroll': ['Salary Slip', 'Employee Tax Exemption Declaration', 'Employee Tax Exemption Proof Submission'],
'hr': ['Employee', 'Expense Claim', 'Leave Application', 'Attendance Request', 'Compensatory Leave Request']
}
for module, doctypes in iteritems(doctype_dict):
for doctype in doctypes:
frappe.reload_doc(module, 'doctype', doctype)
frappe.flags.ignore_select_perm = True
frappe.flags.update_select_perm_after_migrate = True
add_non_standard_user_types()

12
erpnext/setup/install.py

@ -233,3 +233,15 @@ def create_role_permissions_for_doctype(doc, data):
args[perm] = 1
doc.append('user_doctypes', args)
def update_select_perm_after_install():
if not frappe.flags.update_select_perm_after_migrate:
return
frappe.flags.ignore_select_perm = False
for row in frappe.get_all('User Type', filters= {'is_standard': 0}):
print('Updating user type :- ', row.name)
doc = frappe.get_doc('User Type', row.name)
doc.save()
frappe.flags.update_select_perm_after_migrate = False

Loading…
Cancel
Save