【发布时间】:2020-09-28 06:29:55
【问题描述】:
我在 odoo 12 中创建了一个模块,允许门户用户管理他们的时间表。
从控制器模块的所有可用功能中,我使用了sudo(),这样门户用户就不会遇到任何访问权限问题。
创建新时间表控制器时直接调用create() 函数,删除时调用unlink() 但是当用户想要编辑时间表时,我将用户重定向到另一个页面,在该页面上,有一个编辑表单,但是当门户用户导航到该页面时,它会向我显示 403 禁止错误消息。
仅当我创建新的门户用户时才会出现此问题,它允许已经在 odoo 中的 Joel Willis。
我也在那个编辑时间表模板中添加了sudo(),但它不起作用。
像这样..
class EditTimesheet(http.Controller):
@http.route(['/edit_timesheet/<model("account.analytic.line"):timesheet>'], type='http', auth="public", website=True)
def _edit_timesheet(self, timesheet, category='', search='', **kwargs):
self.sudo().edit_timesheet(timesheet, category='', search='', **kwargs)
def edit_timesheet(self, timesheet, category='', search='', **kwargs):
return request.render("timesheet_module.edit_timesheet",{'timesheet':timesheet.sudo()})
记录器中的错误。
Traceback (most recent call last):
File "/home/milan/workspace/odoo/odoo12/odoo/api.py", line 1049, in get
value = self._data[key][field][record._ids[0]]
KeyError: 6
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/milan/workspace/odoo/odoo12/odoo/fields.py", line 1012, in __get__
value = record.env.cache.get(record, self)
File "/home/milan/workspace/odoo/odoo12/odoo/api.py", line 1051, in get
raise CacheMiss(record, field)
odoo.exceptions.CacheMiss: ('account.analytic.line(6,).display_name', None)
odoo.exceptions.AccessError: ('The requested operation cannot be completed due to security restrictions. Please contact your system administrator.\n\n(Document type: Analytic Line, Operation: read) - (Records: [6], User: 8)', None)
【问题讨论】:
标签: python-3.x odoo-12