0

I would like to ask, what is the point of checking whether superuser has specific access groups in Odoo 14?
My understanding was, that superuser has/ignores all access groups.
stock/models/res_config_settings.py

    def set_values(self):
    ...
    was_operations_showed = self.env['stock.picking.type'].with_user(SUPERUSER_ID)._default_show_operations()
    res = super(ResConfigSettings, self).set_values()
    ...    
    return res

addons/stock/models/stock_picking.py

def _default_show_operations(self):
    return self.user_has_groups('stock.group_production_lot,'
                                'stock.group_stock_multi_locations,'
                                'stock.group_tracking_lot')
xixo222
  • 157
  • 2
  • 9

1 Answers1

1

SUPERUSER_ID matches OdooBot user. Using with_user(SUPERUSER_ID) is equal to sudo()

_default_show_operations method checks if user in context has rights because it is not obvious method is going to be called from OdooBot. It may be called from an user too in a different piece of code.

For sure was_operations_showed could just be set to True in this case to optimize code, but this wouldn't be passively in case _default_show_operations gets a logic refactoring (for example enforcing the check with further conditions not related to user permissions)

icra
  • 460
  • 3
  • 14