Sunday, November 10, 2019
1 change · master
Enhancements to existing features
This change preserves the identity of the user who was active before elevated access was used. It helps custom business logic make decisions based on the original user's company or permissions even when an operation must run with higher privileges.
Original PR description
I faced a situation where I need to know which user was before doing sudo. Before this PR it's generally imposible to get such information. My example is below. One can add other usage of this feature in comments. My module [ir_config_parameter_multi_company](https://github.com/it-projects-llc/misc-addons/tree/11.0/ir_config_parameter_multi_company) make System Parameters company-dependent (works via ``ir.property``). The problem is that since odoo 11.0 ``get_param`` requires to be called via sudo(), so [it's not possible to know company of original user](https://github.com/it-projects-llc/misc-addons/blob/11.0/ir_config_parameter_multi_company/models/ir_config_parameter.py#L66). -- I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr