[19.0][MIG] report_py3o: Migration to 19.0#1132
Conversation
Replace README.md by README.rst (not finished)
Remove <data> in views Protect import of py3o libs Remove dep on base module Other small changes
Rename __openerp__.py to __manifest__.py
d72b1dd to
af7e4f6
Compare
There was a problem hiding this comment.
How do you deal with the [report_py3o] section of the Odoo conf file which contains the root_tmpl_path key ?
Shouldn't you have something like this ?https://github.com/OCA/queue/blob/d2a8e902eef111cee495e96bd8bc903155ba29ae/queue_job/jobrunner/__init__.py#L13
report_py3o/wizard/py3o_report.py
Outdated
| """Check if the path is a trusted path for py3o templates.""" | ||
| real_path = os.path.realpath(path) | ||
| root_path = tools.config.get_misc("report_py3o", "root_tmpl_path") | ||
| root_path = tools.config.get("root_tmpl_path") |
There was a problem hiding this comment.
Почему убрал? Должен читать секцию report_py3o и данные оттуда
There was a problem hiding this comment.
в 19.0 убрали misc/get_misc, поэтому заменил на tools.config.get("root_tmpl_path")
There was a problem hiding this comment.
I've also seen that get_misc was removed but there is no automatic mechanism to get the report_py3o section in tools.config. So apart from the tests where you 'artificially' put root_tmpl_path directly into tools.config it won't work.
There was a problem hiding this comment.
тогда добавь реализацию, похожую на это https://github.com/OCA/queue/blob/d2a8e902eef111cee495e96bd8bc903155ba29ae/queue_job/jobrunner/__init__.py#L13
Как glitchov предложил
92af02a to
62ca952
Compare
62ca952 to
c4731ee
Compare
| def report_routes(self, reportname, docids=None, converter=None, **data): | ||
| if converter != "py3o": | ||
| return super().report_routes( | ||
| reportname=reportname, docids=docids, converter=converter, **data | ||
| ) | ||
| context = dict(request.env.context) | ||
|
|
||
| if docids: | ||
| docids = [int(i) for i in docids.split(",")] | ||
| if data.get("options"): | ||
| data.update(json.loads(data.pop("options"))) | ||
| if data.get("context"): | ||
| # Ignore 'lang' here, because the context in data is the | ||
| # one from the webclient *but* if the user explicitely wants to | ||
| # change the lang, this mechanism overwrites it. | ||
| data["context"] = json.loads(data["context"]) | ||
| if data["context"].get("lang"): | ||
| del data["context"]["lang"] | ||
| context.update(data["context"]) | ||
|
|
||
| ir_action = request.env["ir.actions.report"] | ||
| action_py3o_report = ir_action.get_from_report_name( | ||
| reportname, "py3o" |
There was a problem hiding this comment.
Traceback (most recent call last):
File "/opt/odoo/odoo/http.py", line 2298, in _serve_db
return service_model.retrying(serve_func, env=self.env)
File "/opt/odoo/odoo/service/model.py", line 188, in retrying
result = func()
File "/opt/odoo/odoo/http.py", line 2353, in _serve_ir_http
response = self.dispatcher.dispatch(rule.endpoint, args)
File "/opt/odoo/odoo/http.py", line 2475, in dispatch
return self.request.registry['ir.http']._dispatch(endpoint)
File "/opt/odoo/odoo/addons/base/models/ir_http.py", line 355, in _dispatch
result = endpoint(**request.params)
File "/opt/odoo/odoo/http.py", line 808, in route_wrapper
result = endpoint(self, *args, **params_ok)
File "/mnt/data/odoo-addons-dir/report_py3o/controllers/main.py", line 39, in report_routes
action_py3o_report = ir_action.get_from_report_name(
File "/mnt/data/odoo-addons-dir/report_py3o/models/ir_actions_report.py", line 154, in get_from_report_name
return self.search(
File "/opt/odoo/odoo/orm/models.py", line 1378, in search
return self.search_fetch(domain, [], offset=offset, limit=limit, order=order)
File "/opt/odoo/odoo/orm/models.py", line 1408, in search_fetch
query = self._search(domain, offset=offset, limit=limit, order=order or self._order)
File "/opt/odoo/odoo/orm/models.py", line 5351, in _search
self.browse().check_access('read')
File "/opt/odoo/odoo/orm/models.py", line 4115, in check_access
raise result[1]()
odoo.exceptions.AccessError: You are not allowed to access 'Report Action' (ir.actions.report) records.
This operation is allowed for the following groups:
- Role / Administrator
- Role / User
Contact your administrator to request access if necessary.
Воспроизвел при попытке открыть демо-отчет о портального пользователя портальным пользователем.
В ранбоате это можно воспроизвести через portal:portal в базе "baseony".
Заодно добавь пожалуйста тест, что обращение к такому отчету от имени портального пользователя не возвращал 403
No description provided.