# HG changeset patch
# User Etienne Ferriere <etienne.ferriere@xcg-consulting.fr>
# Date 1621588528 -7200
#      Fri May 21 11:15:28 2021 +0200
# Branch 11.0
# Node ID 3931edcf2fe415296220e1d306eb0b0b0591f180
# Parent  6ea1a5ccf9078cdddd0cf3db5391a68718d14f98
Corrected a bug, when seeking if analytic codes are required in a form or tree
view. If the associated analytic structures were defined with a model name,
which did not match the original model technical name, the system was unable to
determine, if the analytic codes were wanted as required.

diff --git a/MetaAnalytic.py b/MetaAnalytic.py
--- a/MetaAnalytic.py
+++ b/MetaAnalytic.py
@@ -219,7 +219,14 @@
                 self.env["analytic.structure"]
                 .search(
                     [
-                        ("model_name", "=", self._name.replace(".", "_")),
+                        (
+                            "model_name",
+                            "=",
+                            self._analytic
+                            if hasattr(self, "_analytic")
+                            and isinstance(self._analytic, str)
+                            else self._name.replace(".", "_"),
+                        ),
                         ("required", "=", True),
                     ]
                 )
diff --git a/NEWS.rst b/NEWS.rst
--- a/NEWS.rst
+++ b/NEWS.rst
@@ -2,6 +2,16 @@
 Changes
 =======
 
+.. _10.0.1.1.0:
+
+10.0.1.1.0
+----------
+
+Corrected a bug, when seeking if analytic codes are required in a form or tree
+view. If the associated analytic structures were defined with a model name,
+which did not match the original model technical name, the system was unable to
+determine, if the analytic codes were wanted as required.
+
 .. _10.0.1.0.0:
 
 10.0.1.0.0
diff --git a/models/analytic_structure.py b/models/analytic_structure.py
--- a/models/analytic_structure.py
+++ b/models/analytic_structure.py
@@ -350,7 +350,12 @@
                 # Now we can insert the fields in the view's architecture.
 
                 model_map = {
-                    model._name.replace(".", "_"): model._name
+                    (
+                        model._analytic
+                        if hasattr(model, "_analytic")
+                        and isinstance(model._analytic, str)
+                        else model._name.replace(".", "_")
+                    ): model._name
                     for name, model in iter(self.env.registry.items())
                 }
                 required = self.env[