-
Book Overview & Buying
-
Table Of Contents
Odoo Development Cookbook
By :
When writing business logic code, you may have to perform some actions with a different security context. A typical case is performing an action with the rights of the Administrator, who bypasses security checks.
This recipe shows how to let normal users modify the phone number of a company by using sudo().
We will be working on records of the res.company model. By default, only members of the Administration/Access Rights user group can modify records of res.company, but in our case, we need to provide an access point to change only the phone number to users who are not necessarily members of that group.
In order to let normal users modify the phone number of a company, you need to perform the following steps:
Define a model extending the res.company model:
class ResCompany(models.Model):
_inherit = 'res.company'Add a method called update_phone_number():
@api.multi
def update_phone_number(self, new_number):In the method...