I was trying to create a module, where portal users could modify the associated partner data. But I get a security error that only admin users could modify configs.
File ".../server/openerp/addons/base/res/res_config.py", line 541, in execute raise openerp.exceptions.AccessError(_("Only administrators can change the settings"))
I tried giving it security access like this:
access_config_portal,portal_partner_config.settings,model_portal_partner_config_settings,base.group_portal,1,1,0,0
But didn't work... i think it's becouse the error shows that in res_config.py execute function it's check the users to be SUPERUSER:
if uid != SUPERUSER_ID and not self.pool['res.users'].has_group(cr, uid, 'base.group_erp_manager'):
raise openerp.exceptions.AccessError(_("Only administrators can change the settings"))
Like this:
class Configuration(models.TransientModel):
_inherit = 'res.config.settings'
_name = 'portal_partner_config.settings'
name = fields.Char()
street = fields.Char()
city = fields.Char()
@api.model
def get_default_inova_values(self,fields):
users = self.pool.get('res.users')
current_user = users.browse(self._cr, self._uid, self._uid, context=self._context)
name = current_user.partner_id.name
street = current_user.partner_id.street
city = current_user.partner_id.city
return {
'name': name,
'street': street,
'city': city,}
@api.one
def set_inova_values(self):
users = self.pool.get('res.users')
current_user = users.browse(self._cr, self._uid, self._uid, context=self._context)
users.sudo().write(self._cr, self._uid, current_user.id, {'name': self.name,
'street': self.street,
'city': self.city,
},
context=self._context)
There a way to portal users change their custom data, an associate a payment source, like a credit card?
Solved!
In the view definition change the call method of the res_config like this:
<button string="Apply" type="object" name="execute2" class="oe_highlight" />
and in the res_config model copy the execute def and erase the SUPERUSERID check. I don't overrite the execute function so in the others config the SUPERUSERID check is perfom
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With