frappe / hrms

Open Source HR and Payroll Software
https://frappe.io/hr
GNU General Public License v3.0
1.03k stars 573 forks source link

Installation Failure after Partial migration from version 13 #692

Open revant opened 1 year ago

revant commented 1 year ago

Information about bug

Unable to install app after partial migration.

bench --site site.name migrate --skip-failing

Patches skipped due to failure:

frappe.patches.v13_0.rename_desk_page_to_workspace in site.name (_f968aab114617520)
frappe.patches.v14_0.setup_likes_from_feedback in site.name (_f968aab114617520)
erpnext.patches.v12_0.rename_account_type_doctype in site.name (_f968aab114617520)
execute:frappe.rename_doc("Desk Page", "Getting Started", "Home", force=True) in site.name (_f968aab114617520)
execute:frappe.rename_doc("Desk Page", "Loan Management", "Loan", force=True) in site.name (_f968aab114617520)
execute:frappe.rename_doc("Workspace", "Loan", "Loan Management", ignore_if_exists=True, force=True) in site.name (_f968aab114617520)
execute:frappe.rename_doc("Workspace", "Loan Management", "Loans", force=True) in site.name (_f968aab114617520)
erpnext.patches.v13_0.enable_provisional_accounting in site.name (_f968aab114617520)

Module

other

Version

frappe v14.40.1 erpnext 14.29.1 hrms v14.5.0

Installation method

docker

Relevant log output / Stack trace / Full Error Message.

frappe@61682c382b8d:~/frappe-bench$ bench --site site.name install-app hrms
App erpnext already installed
Installing hrms...
Updating DocTypes for hrms:[======] 100%
Setting up Frappe HR...

Installation for Frappe HR app failed due to an error. Please try re-installing the app or report the issue on https://github.com/frappe/hrms/issues/new if not resolved.

An error occurred while installing hrms: For All at level in User in row 3: No basic permissions set
Traceback (most recent call last):
File "apps/frappe/frappe/commands/site.py", line 416, in install_app
_install app(app, verbose=context.verbose, force-force)
File "apps/frappe/frappe/installer.py", line 304, in install_app
frappe.get_attr(after_install)()
File "apps/hrms/hrms/install.py", line 21, in after_install
raise e
File "apps/hrms/hrms/install.py", line 9, in after_install
setup()
File "apps/hrms/hrms/setup.py", line 19, in after_install
add_non_standard_user_types()
File "apps/hrms/hrms/setup.py", line 509, in add_non_standard_user_types
create_user_type(user_type, data)
File "apps/hrms/hrms/setup.py", line 575, in create_user_type
doc.save(ignore_permissions=True)
File "apps/frappe/frappe/model/document.py" line 305. in save

Code of Conduct

ruchamahabal commented 1 year ago

Can't replicate it.

For All at level in User in row 3: No basic permissions set

It seems all the permissions for the "All" role have been removed on this site. By default, the All role has a select perm in the User doctype.

image

User Type updates existing users. But it does a DB update so the validations should not trigger.

Is this the complete traceback?

fnrfarid commented 1 year ago

@ruchamahabal

In [1]: from erpnext.patches.v12_0.rename_account_type_doctype import execute

In [2]: execute()
---------------------------------------------------------------------------
DoesNotExistError                         Traceback (most recent call last)
File <ipython-input-2-3fdbf122d5ea>:1
----> 1 execute()

File ~/frappe-bench/apps/erpnext/erpnext/patches/v12_0/rename_account_type_doctype.py:5, in execute()
      4 def execute():
----> 5         frappe.rename_doc("DocType", "Account Type", "Bank Account Type", force=True)
      6         frappe.rename_doc("DocType", "Account Subtype", "Bank Account Subtype", force=True)
      7         frappe.reload_doc("accounts", "doctype", "bank_account")

File ~/frappe-bench/apps/frappe/frappe/__init__.py:1316, in rename_doc(doctype, old, new, force, merge, ignore_if_exists, show_alert, rebuild_search)
   1308 """
   1309 Renames a doc(dt, old) to doc(dt, new) and updates all linked fields of type "Link"
   1310 
   1311 Calls frappe.model.rename_doc.rename_doc
   1312 """
   1314 from frappe.model.rename_doc import rename_doc
-> 1316 return rename_doc(
   1317         doctype=doctype,
   1318         old=old,
   1319         new=new,
   1320         force=force,
   1321         merge=merge,
   1322         ignore_if_exists=ignore_if_exists,
   1323         show_alert=show_alert,
   1324         rebuild_search=rebuild_search,
   1325 )

File ~/frappe-bench/apps/frappe/frappe/model/rename_doc.py:151, in rename_doc(doctype, old, new, force, merge, ignore_permissions, ignore_if_exists, show_alert, rebuild_search, doc, validate)
    148 meta = frappe.get_meta(doctype)
    150 if validate:
--> 151         old_doc = doc or frappe.get_doc(doctype, old)
    152         out = old_doc.run_method("before_rename", old, new, merge) or {}
    153         new = (out.get("new") or new) if isinstance(out, dict) else (out or new)

File ~/frappe-bench/apps/frappe/frappe/__init__.py:1187, in get_doc(*args, kwargs)
   1170 """Return a `frappe.model.document.Document` object of the given type and name.
   1171 
   1172 :param arg1: DocType name as string **or document JSON.
   (...)
   1183 
   1184 """
   1185 import frappe.model.document
-> 1187 doc = frappe.model.document.get_doc(*args, **kwargs)
   1189 # Replace cache if stale one exists
   1190 if (key := can_cache_doc(args)) and cache().hexists("document_cache", key):

File ~/frappe-bench/apps/frappe/frappe/model/document.py:74, in get_doc(*args, **kwargs)
     72 controller = get_controller(doctype)
     73 if controller:
---> 74         return controller(*args, **kwargs)
     76 raise ImportError(doctype)

File ~/frappe-bench/apps/frappe/frappe/model/document.py:106, in Document.init(self, *args, **kwargs)
    103         # for_update is set in flags to avoid changing load_from_db signature
    104         # since it is used in virtual doctypes and inherited in child classes
    105         self.flags.for_update = kwargs.get("for_update")
--> 106         self.load_from_db()
    107         return
    109 if isinstance(args[0], dict):
    110         # first argument is a dict

File ~/frappe-bench/apps/frappe/frappe/model/document.py:149, in Document.load_from_db(self)
    145         d = frappe.db.get_value(
    146                 self.doctype, self.name, "*", as_dict=1, for_update=self.flags.for_update
    147         )
    148         if not d:
--> 149                 frappe.throw(
    150                         _("{0} {1} not found").format(_(self.doctype), self.name), frappe.DoesNotExistError
    151                 )
    153         super().init(d)
    154 self.flags.pop("ignore_children", None)
File ~/frappe-bench/apps/frappe/frappe/__init__.py:528, in throw(msg, exc, title, is_minimizable, wide, as_list)
    516 def throw(
    517         msg: str,
    518         exc: type[Exception] = ValidationError,
   (...)
    522         as_list: bool = False,
    523 ) -> None:
    524         """Throw execption and show message (msgprint).
    525 
    526         :param msg: Message.
    527         :param exc: Exception class. Default frappe.ValidationError"""
--> 528         msgprint(
    529                 msg,
    530                 raise_exception=exc,
    531                 title=title,
    532                 indicator="red",
    533                 is_minimizable=is_minimizable,
    534                 wide=wide,
    535                 as_list=as_list,
    536         )

File ~/frappe-bench/apps/frappe/frappe/__init__.py:496, in msgprint(msg, title, raise_exception, as_table, as_list, indicator, alert, primary_action, is_minimizable, wide)
    493 if raise_exception and hasattr(raise_exception, "name"):
    494         local.response["exc_type"] = raise_exception.name
--> 496 _raise_exception()

File ~/frappe-bench/apps/frappe/frappe/__init__.py:445, in msgprint.<locals>._raise_exception()
    443 if raise_exception:
    444         if inspect.isclass(raise_exception) and issubclass(raise_exception, Exception):
--> 445                 raise raise_exception(msg)
    446         else:
    447                 raise ValidationError(msg)

DoesNotExistError: DocType Account Type not found

this is the full error after run this command on console

from erpnext.patches.v12_0.rename_account_type_doctype import execute

execute()
ruchamahabal commented 1 year ago

@fnrfarid This issue is in an ERPNext patch, unrelated to this thread.

revant commented 1 year ago

@fnrfarid just shared the traceback for other patches that failed as --skip-failing was set. Yes those patches are from ERPNext, if they help in debugging.

Will adding the permissions from Role Permissions Manager work? developer_mode is NOT enabled on site for users to make any changes to standard doctypes including User.