预期单例:以编程方式创建新发票时的 res.users()
我正在尝试在控制器中创建新发票:
request.env['account.move'].sudo().create([
{
'move_type': 'out_invoice',
'journal_id': 1,
'invoice_date': '2020-01-10',
'invoice_line_ids': [(0, 0, {'product_id': 21, 'price_unit': 1000.0})],
}])
但我收到此错误
预期单例:res.users()
I'm trying to create a new invoice in controller:
request.env['account.move'].sudo().create([
{
'move_type': 'out_invoice',
'journal_id': 1,
'invoice_date': '2020-01-10',
'invoice_line_ids': [(0, 0, {'product_id': 21, 'price_unit': 1000.0})],
}])
But i got this error
Expected singleton: res.users()
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我在领导的帮助下找到了答案,如下:
这个问题是因为我们缺少
self.env.user
,为此,我们必须添加.with_user(SUPERUSER_ID )
模型调用后。例子:
I've found the answer with the help of my leader, here it is:
This issue is because we missing
self.env.user
, to do this, we must add.with_user(SUPERUSER_ID)
after model call.Example: