frappe / erpnext

Free and Open Source Enterprise Resource Planning (ERP)
https://erpnext.com
GNU General Public License v3.0
21.92k stars 7.35k forks source link

When I try to add new company it's show TypeError: rebuild_tree() takes 1 positional argument but 2 were given Possible source of error: erpnext (app) #42217

Closed rohit200207 closed 4 months ago

rohit200207 commented 4 months ago

App Versions

{
    "erpnext": "14.0.0-dev",
    "frappe": "16.0.0-dev",
    "healthcare": "16.0.0-dev",
    "hrms": "16.0.0-dev"
}

Route

Form/Company/new-company-fwtidyjsax

Traceback

Traceback (most recent call last):
  File "apps/frappe/frappe/app.py", line 110, in application
    response = frappe.api.handle(request)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/api/__init__.py", line 49, in handle
    data = endpoint(**arguments)
           ^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/api/v1.py", line 36, in handle_rpc_call
    return frappe.handler.handle()
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/handler.py", line 49, in handle
    data = execute_cmd(cmd)
           ^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/handler.py", line 85, in execute_cmd
    return frappe.call(method, **frappe.form_dict)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/__init__.py", line 1803, in call
    return fn(*args, **newargs)
           ^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/utils/typing_validations.py", line 31, in wrapper
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/desk/form/save.py", line 39, in savedocs
    doc.save()
  File "apps/frappe/frappe/model/document.py", line 338, in save
    return self._save(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/model/document.py", line 360, in _save
    return self.insert()
           ^^^^^^^^^^^^^
  File "apps/frappe/frappe/model/document.py", line 316, in insert
    self.run_post_save_methods()
  File "apps/frappe/frappe/model/document.py", line 1132, in run_post_save_methods
    self.run_method("on_update")
  File "apps/frappe/frappe/model/document.py", line 966, in run_method
    out = Document.hook(fn)(self, *args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/model/document.py", line 1330, in composer
    return composed(self, method, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/model/document.py", line 1308, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))
                              ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/model/document.py", line 963, in fn
    return method_object(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/erpnext/erpnext/setup/doctype/company/company.py", line 139, in on_update
    self.create_default_accounts()
  File "apps/erpnext/erpnext/setup/doctype/company/company.py", line 205, in create_default_accounts
    create_charts(self.name, self.chart_of_accounts, self.existing_company)
  File "apps/erpnext/erpnext/accounts/doctype/account/chart_of_accounts/chart_of_accounts.py", line 77, in create_charts
    rebuild_tree("Account", "parent_account")
  File "apps/frappe/frappe/utils/typing_validations.py", line 31, in wrapper
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
TypeError: rebuild_tree() takes 1 positional argument but 2 were given

Request Data

{
    "type": "POST",
    "args": {
        "doc": "{\"docstatus\":0,\"doctype\":\"Company\",\"name\":\"new-company-xyxcugynnl\",\"__islocal\":1,\"__unsaved\":1,\"owner\":\"sm@gmail.com\",\"country\":\"India\",\"is_group\":0,\"create_chart_of_accounts_based_on\":\"\",\"allow_account_creation_against_child_company\":0,\"enable_perpetual_inventory\":1,\"enable_provisional_accounting_for_non_stock_items\":0,\"idx\":0,\"monthly_sales_target\":0,\"total_monthly_sales\":0,\"credit_limit\":0,\"lft\":0,\"rgt\":0,\"company_name\":\"sm\",\"abbr\":\"s\",\"default_currency\":\"INR\"}",
        "action": "Save"
    },
    "btn": {
        "jQuery370091898096214027711": {
            "events": {
                "click": [
                    {
                        "type": "click",
                        "origType": "click",
                        "guid": 2733,
                        "namespace": ""
                    }
                ]
            }
        }
    },
    "freeze": true,
    "headers": {},
    "error_handlers": {},
    "url": "/api/method/frappe.desk.form.save.savedocs",
    "request_id": null
}

Response Data

{
    "exception": "TypeError: rebuild_tree() takes 1 positional argument but 2 were given",
    "exc_type": "TypeError",
    "_exc_source": "erpnext (app)"
}
Nihantra-Patel commented 4 months ago

Hi @rohit200207,

Everything is working fine. No problems were encountered in the latest version 15 and dev.

First, Rebuild the Company Tree, Then reload Ctrl+Shift+R and create a new company.

image