I am having problem using sudo
in Odoo version 11. Checking doc, I think the same problem exists in version 12. Using sudo
generate log with wrong(?) user. For e.g. I override confirm_sale
to use sudo
.
from odoo import api, fields, models
class SaleOrder(models.Model):
_inherit = 'sale.order'
def action_confirm(self):
return super(SaleOrder, self.sudo()).action_confirm()
Then let say when "Sale User" confirm sale order, log is shown as if "Administrator" approved sale order. Information is lost on who really confirmed sale order.
Question: So, my question is I want to use sudo
but still record correctly who made changes.
Clarification/Use Case: Removing sudo
and adding necessary permissions for user can solve the problem. But my very often use case is one group of users can only create/edit data and one or more groups can only confirm/approve data without edit permission. So, sudo
is necessary.
You can use this OCA module https://apps.odoo.com/apps/modules/11.0/base_suspend_security/
Just install the module and use suspend_security() instead of sudo(), it will bypass access rights but keep the current user on log