diff --git a/addons/hr_gamification/wizard/gamification_badge_user_wizard.py b/addons/hr_gamification/wizard/gamification_badge_user_wizard.py index a2feb024688..5bbb6848bd3 100644 --- a/addons/hr_gamification/wizard/gamification_badge_user_wizard.py +++ b/addons/hr_gamification/wizard/gamification_badge_user_wizard.py @@ -2,14 +2,27 @@ # Part of Odoo. See LICENSE file for full copyright and licensing details. from odoo import api, fields, models, _ -from odoo.exceptions import UserError +from odoo.exceptions import UserError, AccessError class GamificationBadgeUserWizard(models.TransientModel): _inherit = 'gamification.badge.user.wizard' employee_id = fields.Many2one('hr.employee', string='Employee', required=True) - user_id = fields.Many2one('res.users', string='User', related='employee_id.user_id', store=True) + user_id = fields.Many2one('res.users', string='User', + related='employee_id.user_id', store=True, readonly=True) + + # TODO 12.0/master remove this hack by changing the model + @api.model + def create(self, values): + employee = self.env['hr.employee'].browse(values['employee_id']) + values['user_id'] = employee.user_id.id + try: + return super(GamificationBadgeUserWizard, self).create(values) + except AccessError: + # an employee can not write on another employee + # force sudo because of related + return super(GamificationBadgeUserWizard, self.sudo()).create(values) @api.multi def action_grant_badge(self): diff --git a/doc/cla/individual/abdur-rahmaanJ.md b/doc/cla/individual/abdur-rahmaanJ.md new file mode 100644 index 00000000000..257221f1a91 --- /dev/null +++ b/doc/cla/individual/abdur-rahmaanJ.md @@ -0,0 +1,11 @@ +Mauritius, 2018-08-27 + +I hereby agree to the terms of the Odoo Individual Contributor License +Agreement v1.0. + +I declare that I am authorized and able to make this agreement and sign this +declaration. + +Signed, + +Abdur-Rahmaan Janhangeer cryptolabour@gmail.com https://github.com/Abdur-RahmaanJ diff --git a/doc/howtos/backend.rst b/doc/howtos/backend.rst index 575cb23e3ae..fb6dd9736df 100644 --- a/doc/howtos/backend.rst +++ b/doc/howtos/backend.rst @@ -1771,7 +1771,7 @@ Examples can be easily adapted from XML-RPC to JSON-RPC. systems without *explicitly* going through XML-RPC or JSON-RPC, such as: * https://github.com/akretion/ooor - * https://github.com/syleam/openobject-library + * https://github.com/OCA/odoorpc * https://github.com/nicolas-van/openerp-client-lib * http://pythonhosted.org/OdooRPC * https://github.com/abhishek-jaiswal/php-openerp-lib