Skip to content

Custom photo naming expressions disappear after reopening the project #940

Description

@harminius

Support ticket: https://odoo.lutraconsulting.co.uk/odoo/all-tickets/16929

What
In Photo attachments configuration in Project Properties, custom photo name expressions on fields with whitespace are lost after closing and reopening QGIS. Mobile fails to rename the photos.

Why
Expressions are stored as QGIS project properties under a key built from the field name:

PhotoNaming/<layer_id>/<field_name>
When QGIS writes the project, it strips characters that aren't valid in an XML element name - spaces, leading digits, punctuation. So a field named Photo before is saved as the tag <Photobefore>, but on reload the plugin looks it up by the original name Photo before, which no longer matches.

Affected: fields whose names contain spaces, start with a digit, or contain punctuation. Accented characters (ø, æ, ç) are fine.

Reproduce

  1. Add an attachment field whose name contains a space (e.g. pho to).
  2. Set a photo naming expression, apply, save the project.
  3. Close and reopen QGIS, reopen the project → the expression is gone.

The expression works within the session (the preview is correct), but reloading the project shows it blank.

Fix: stop embedding the names as key tokens (store the mapping as a value, e.g. JSON) - the field/layer names then round-trip safely.

Note: the Mergin mobile app reads this property too, so the storage-format change needs a matching update on the mobile side.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions