# HG changeset patch
# User Houzefa Abbasbhay <houzefa.abba@xcg-consulting.fr>
# Date 1561455170 -7200
#      Tue Jun 25 11:32:50 2019 +0200
# Branch 11.0
# Node ID 92102b656827d810a9b4c5f5cfdffa78e3a357b3
# Parent  21ab76f33c62eabef4c27dc2627175bb6ee0836d
Backed out changeset af2f7565c198 (security)

Will be done better (more cases handled, more comments) by grafting rev
d11003bb260b6fd930a7d3adb3aca0b0de919266.

diff --git a/MetaAnalytic.py b/MetaAnalytic.py
--- a/MetaAnalytic.py
+++ b/MetaAnalytic.py
@@ -476,9 +476,7 @@
                 vals[column] = force_code_id
 
             else:
-                new_code, vals = self.sudo()._create_analytic_code(
-                    vals, code_vals
-                )
+                new_code, vals = self._create_analytic_code(vals, code_vals)
 
             res = super(superclass, self).create(vals, **kwargs)
 
@@ -489,7 +487,7 @@
                     if cp is not None and cp:
                         code_vals["code_parent_id"] = cp.id
 
-                new_code, vals = self.sudo()._create_analytic_code(
+                new_code, vals = self._create_analytic_code(
                     {
                         field: extract(getattr(res, field), field_data["type"])
                         for field, field_data in list(res.fields_get().items())
@@ -588,7 +586,7 @@
                         super(superclass, rec).write(rec_vals, **kwargs)
 
                     elif rec_code_vals:
-                        code.sudo().write(rec_code_vals)
+                        code.write(rec_code_vals)
 
             if code_ref_ids and news is not False:
                 for new in news: