Bug report #21852

In Value Relation widget the new function current_value in filter expression is not affected by a settext of a python initialization function.

Added by Alain FERRATON 7 months ago.

Status:Open
Priority:Normal
Assignee:-
Category:Forms
Affected QGIS version:3.4.5 Regression?:No
Operating System: Easy fix?:No
Pull Request or Patch supplied:No Resolution:
Crashes QGIS or corrupts data:No Copied to github as #:29667

Description

I'm not sure it's a bug, because the problem is a bit complex.

I am in a case where I have to initialize a field, in reality by recovering a value in another layer that contains the entered point, but for the example just by assignment in a form open function

from PyQt5.QtWidgets import QDialogButtonBox, QLineEdit
def my_form_open(dialog, layer, feature):
dialog.findChild(QLineEdit,'id').*setText*('10')

Another field (ref) is defined as a relational value and uses a filter for this purpose
id" = current_value("id')

when the form is initialized, the id value is not recovered by the current_value() function. All layer values are displayed instead of being filtered.
it is necessary to retype the value in the field so that the field 'ref' is filtered

In the same case, the formValuerelation plugin worked correctly with QGIS 2.

attached two layers gpkg and a project for testing

test.qgz (4.71 KB) Alain FERRATON, 2019-04-15 04:09 PM

MyLayerA.gpkg (96 KB) Alain FERRATON, 2019-04-15 04:09 PM

ref.gpkg (76 KB) Alain FERRATON, 2019-04-15 04:09 PM

Also available in: Atom PDF