How can a portal user change their partner details in Odoo 8?

I tried to create a module in which portal users could modify the partner’s related data. But I get a security error that only administrators can modify with configurations.

File "... / server / OpenERP / add-ons / base / RES / res_config.py", line 541, executed by raise openerp.exceptions.AccessError (_ ("Only administrators can change the settings"))

I tried to give him access to security as follows:

access_config_portal, portal_partner_config.settings, model_portal_partner_config_settings, base.group_portal, 1,1,0,0

But this did not work ... I think because the error shows that in the res_config.py execution function it checks users as 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) 

Is there a way for portal users to change their user data, to associate a payment source, like a credit card?

+6
source share
1 answer

Solved!

In the view definition, change the res_config invocation method as follows:

 <button string="Apply" type="object" name="execute2" class="oe_highlight" /> 

and in the res_config model, copy execute def and remove the SUPERUSERID check. I do not override the execute function, so in other configurations, the SUPERUSERID check is performed by the performance

+2
source

All Articles