Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
qgib opened this issue Apr 15, 2019 · 4 comments
Assignees
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Feedback Waiting on the submitter for answers Forms PyQGIS Related to the PyQGIS API

Comments

@qgib
Copy link
Contributor

qgib commented Apr 15, 2019

Author Name: Alain FERRATON (@FERRATON)
Original Redmine Issue: 21852
Affected QGIS version: 3.4.5
Redmine category:forms


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


@qgib qgib added Bug Either a bug report, or a bug fix. Let's hope for the latter! Forms labels May 25, 2019
@FERRATON
Copy link

FERRATON commented Jun 4, 2019

dataset.zip
the file ref.gpkg in the data set was empty.

@FERRATON
Copy link

FERRATON commented Jun 4, 2019

Another problem that may be related.
If you enter the filter field manually, the combobox is updated.
but if , for example, you choose the 2nd value in the list, it is displayed, but when you save, the 1st value is saved.

example if you enter 10 the list will be for example 10a, 10b, 10c... we choose 10b which is displayed, but it is the value 10a which is saved.

@gioman gioman added the PyQGIS Related to the PyQGIS API label Jun 5, 2019
@troopa81
Copy link
Contributor

I'm not sure this really an issue. When forcing the value at form opening the relational widget (the combobox) is filtered as expected. The value ref is indeed not modified but it looks normal to me to not change the value, it's the user choice to change or not the value.

We get the same behavior when changing the value id manually, the ref value isn't changed until you decide to edit the value through the relational widget.

I fail to reproduce the second issue, the expression id_ref = current_value('id') didn't give a list with 2 elements because "10" != "102", but even with this expression left(id_ref,2) = left(current_value('id'),2) everything works fine.

@gioman gioman added the Feedback Waiting on the submitter for answers label Jun 29, 2019
troopa81 added a commit to troopa81/QGIS that referenced this issue Jul 4, 2019
@troopa81
Copy link
Contributor

troopa81 commented Jul 4, 2019

Proposed PR #30554

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Feedback Waiting on the submitter for answers Forms PyQGIS Related to the PyQGIS API
Projects
None yet
Development

No branches or pull requests

4 participants