Skip to content

Commit

Permalink
Fix importing project with RelationReference widget
Browse files Browse the repository at this point in the history
  • Loading branch information
wlorenzetti committed Nov 15, 2023
1 parent 345dbe8 commit c26b607
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions g3w-admin/qdjango/utils/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -627,15 +627,16 @@ def _getDataEditTypes(self):
# If ewidget.type() is ReferenceValue, add DisplayExpression of referencedlayer
elif ewidget.type() == 'RelationReference':

# Remove from layer dotasource data
del(options['ReferencedLayerDataSource'],
options['ReferencedLayerProviderKey'])

# Add DisplayExpression of ReferencedLayer
# Set it into a try except routine for a possible bug of QGIS:
# If in QGIS project is set a RelationReference form widget, if the referenced layer is changed
# the ReferencedLayerId is not changed and was the old layer id not more present into the project
try:

# Remove from layer dotasource data
del (options['ReferencedLayerDataSource'],
options['ReferencedLayerProviderKey'])

options['display_expression'] = self.qgisProject.qgs_project.mapLayer(
options['ReferencedLayerId']).displayExpression()
except Exception as e:
Expand Down

0 comments on commit c26b607

Please sign in to comment.