# HG changeset patch
# User Etienne Ferriere <etienne.ferriere@xcg-consulting.fr>
# Date 1528302244 -7200
#      Wed Jun 06 18:24:04 2018 +0200
# Branch 10.0
# Node ID 7678a4134080cbd7d19ca3f012432ddc647b71be
# Parent  1082c9a9078dc789d8e103009c3e4e62923a2e0e
Corrected a bug on record duplication.
When binding a dimension to a model, if there is a 'False' value instead of a
parent code, when seeking one, no ID must be extracted.

diff --git a/MetaAnalytic.py b/MetaAnalytic.py
--- a/MetaAnalytic.py
+++ b/MetaAnalytic.py
@@ -455,7 +455,7 @@
 
             if sync_parent:
                 cp = self._get_code_parent(vals)
-                if cp is not None:
+                if cp is not None and cp:
                     code_vals['code_parent_id'] = cp.id
 
             # Direct changes to the 'bound analytic code' field are ignored
@@ -480,7 +480,7 @@
 
                 if sync_parent:
                     cp = self._get_code_parent(vals)
-                    if cp is not None:
+                    if cp is not None and cp:
                         code_vals['code_parent_id'] = cp.id
 
                 new_code, vals = self._create_analytic_code(
@@ -521,13 +521,13 @@
 
             if sync_parent:
                 cp = self._get_code_parent(vals)
-                if cp is not None:
+                if cp is not None and cp:
                     code_vals['code_parent_id'] = cp.id
                 else:
                     parent = getattr(self, sync_parent)
                     if parent:
                         cp = getattr(parent, parent_column)
-                        if cp:
+                        if cp is not None and cp:
                             code_vals['code_parent_id'] = cp.id
 
             # Direct changes to the 'bound analytic code' field are ignored