Skip to content
Snippets Groups Projects
Commit d11003bb260b authored by Houzefa Abbasbhay's avatar Houzefa Abbasbhay :slight_smile:
Browse files

Bound analytic codes: Bypass security rules

Behind-the-scenes objects; main object security rules are enough.
parent 924a771ece9d
No related branches found
No related tags found
No related merge requests found
...@@ -434,7 +434,8 @@ ...@@ -434,7 +434,8 @@
# inherits. # inherits.
code_obj = self.env['analytic.code'] code_obj = self.env['analytic.code']
code_vals['nd_id'] = self._get_bound_dimension_id() code_vals['nd_id'] = self._get_bound_dimension_id()
code = code_obj.create(code_vals) # These are behind-the-scenes links so bypass security rules.
code = code_obj.sudo().create(code_vals)
vals[column] = code.id vals[column] = code.id
new_code = code new_code = code
...@@ -497,7 +498,8 @@ ...@@ -497,7 +498,8 @@
self._generate_code_ref_id(res) self._generate_code_ref_id(res)
if new_code: if new_code:
new_code.write({ # These are behind-the-scenes links so bypass security rules.
new_code.sudo().write({
'origin_id': '{},{}'.format(self._name, res.id), 'origin_id': '{},{}'.format(self._name, res.id),
}) })
...@@ -574,8 +576,11 @@ ...@@ -574,8 +576,11 @@
rec_code_vals['nd_id'] = rec._get_bound_dimension_id() rec_code_vals['nd_id'] = rec._get_bound_dimension_id()
rec_code_vals['origin_id'] = \ rec_code_vals['origin_id'] = \
'{},{}'.format(self._name, rec.id) '{},{}'.format(self._name, rec.id)
rec_vals[column] = code_obj.create(rec_code_vals).id # These are behind-the-scenes links so bypass security
# rules.
rec_vals[column] = (code_obj.sudo()
.create(rec_code_vals)).id
super(superclass, rec).write(rec_vals, **kwargs) super(superclass, rec).write(rec_vals, **kwargs)
elif rec_code_vals: elif rec_code_vals:
...@@ -578,8 +583,10 @@ ...@@ -578,8 +583,10 @@
super(superclass, rec).write(rec_vals, **kwargs) super(superclass, rec).write(rec_vals, **kwargs)
elif rec_code_vals: elif rec_code_vals:
code.write(rec_code_vals) # These are behind-the-scenes links so bypass security
# rules.
code.sudo().write(rec_code_vals)
if code_ref_ids and news is not False: if code_ref_ids and news is not False:
for new in news: for new in news:
...@@ -604,7 +611,8 @@ ...@@ -604,7 +611,8 @@
res = super(superclass, self).unlink() res = super(superclass, self).unlink()
codes.unlink(**kwargs) # These are behind-the-scenes links so bypass security rules.
codes.sudo().unlink(**kwargs)
return res return res
...@@ -626,7 +634,8 @@ ...@@ -626,7 +634,8 @@
"analytic dimension {}".format(dimension_name) "analytic dimension {}".format(dimension_name)
) )
if code_vals: if code_vals:
force_code.write(code_vals) # These are behind-the-scenes links so bypass security rules.
force_code.sudo().write(code_vals)
if sync_parent: if sync_parent:
# This function is called as a method and can be overridden. # This function is called as a method and can be overridden.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment