Monday, February 3, 2025
1 change · saas-17.4
Resolved issues and error corrections
This fix prevents Odoo from crashing when installing apps or generating accounting reports if old or archived company records are linked to journals. It keeps installation and reporting flows stable by only using journals from active companies.
Original PR description
When installing apps for ex: sale_stock or running specific processes related to journal filters and report generation. Keyerror occurs as Odoo attempts to access journal data for archived companies…
When installing apps for ex: sale_stock or running specific processes related to journal filters and report generation. Keyerror occurs as Odoo attempts to access journal data for archived companies that were not present in the initialized `per_company_map` dictionary.
### Root Cause:
The KeyError is triggered because the `journal.company_id.id` is not found in the `per_company_map` dictionary. This happens when the company associated with a journal is archived or inactive, and thus not part of the `report_companies` list.
```
RPC_ERROR
Odoo Server Error
Traceback (most recent call last):
File /Users/nea/src/odoo/odoo/http.py, line 1986, in _transactioning
return service_model.retrying(func, env=self.env)
File /Users/nea/src/odoo/odoo/service/model.py, line 134, in retrying
result = func()
File /Users/nea/src/odoo/odoo/http.py, line 1953, in _serve_ir_http
response = self.dispatcher.dispatch(rule.endpoint, args)
File /Users/nea/src/odoo/odoo/http.py, line 2197, in dispatch
result = self.request.registry[ir.http]._dispatch(endpoint)
File /Users/nea/src/odoo/odoo/addons/base/models/ir_http.py, line 227, in _dispatch
result = endpoint(**request.params)
File /Users/nea/src/odoo/odoo/http.py, line 757, in route_wrapper
result = endpoint(self, *args, **params_ok)
File /Users/nea/src/odoo/addons/web/controllers/dataset.py, line 40, in call_button
action = call_kw(request.env[model], method, args, kwargs)
File /Users/nea/src/odoo/odoo/api.py, line 459, in call_kw
result = getattr(recs, name)(*args, **kwargs)
File <decorator-gen-80>, line 2, in button_immediate_install
File /Users/nea/src/odoo/odoo/addons/base/models/ir_module.py, line 75, in check_and_log
return method(self, *args, **kwargs)
File /Users/nea/src/odoo/odoo/addons/base/models/ir_module.py, line 478, in button_immediate_install
return self._button_immediate_function(self.env.registry[self._name].button_install)
File /Users/nea/src/odoo/odoo/addons/base/models/ir_module.py, line 602, in _button_immediate_function
registry = modules.registry.Registry.new(self._cr.dbname, update_module=True)
File <decorator-gen-16>, line 2, in new
File /Users/nea/src/odoo/odoo/tools/func.py, line 84, in locked
return func(inst, *args, **kwargs)
File /Users/nea/src/odoo/odoo/modules/registry.py, line 124, in new
odoo.modules.load_modules(registry, force_demo, status, update_module)
File /Users/nea/src/odoo/odoo/modules/loading.py, line 480, in load_modules
processed_modules += load_marked_modules(env, graph,
File /Users/nea/src/odoo/odoo/modules/loading.py, line 364, in load_marked_modules
loaded, processed = load_module_graph(
File /Users/nea/src/odoo/odoo/modules/loading.py, line 245, in load_module_graph
getattr(py_module, post_init)(env)
File /Users/nea/src/odoo/addons/stock_account/__init__.py, line 41, in _configure_journals
ChartTemplate._post_load_data(template_code, company, template_data)
File /Users/nea/src/odoo/addons/stock_account/models/account_chart_template.py, line 12, in _post_load_data
super()._post_load_data(template_code, company, template_data)
File /Users/nea/src/enterprise/account_reports/models/chart_template.py, line 26, in _post_load_data
company._get_and_update_tax_closing_moves(fields.Date.today(), include_domestic=True)
File /Users/nea/src/enterprise/account_reports/models/res_company.py, line 171, in _get_and_update_tax_closing_moves
report, tax_closing_options = tax_closing_move._get_report_options_from_tax_closing_entry()
File /Users/nea/src/enterprise/account_reports/models/account_move.py, line 310, in _get_report_options_from_tax_closing_entry
report_options = tax_report.with_context(allowed_company_ids=company_ids).get_options(previous_options=options)
File /Users/nea/src/enterprise/account_reports/models/account_report.py, line 1773, in get_options
initializer(options, previous_options=previous_options)
File /Users/nea/src/enterprise/account_reports/models/account_report.py, line 225, in _init_options_journals
per_company_map[journal.company_id.id][available_journals] |= journal
KeyError: 1
The above server error caused the following client error: RPC_ERROR: Odoo Server Error
RPC_ERROR
at makeErrorFromResponse (http://localhost:8569/web/assets/7ad8aea/web.assets_web.min.js:2952:163)
at XMLHttpRequest.<anonymous> (http://localhost:8569/web/assets/7ad8aea/web.assets_web.min.js:2957:13)
```
### Fix:
Additional domain to make sure we only get journals for active companies.
### Expected Behavior:
This fix should prevent KeyErrors related to archived companies during module installation or report generation processes.
opw-4213746