MerginMaps / MerginMaps/qgis-plugin
Custom photo naming expressions disappear after reopening the project
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 44
- Forks
- 20
- Avg merge
- 3d 12h
- Merged PRs (30d)
- 5
Description
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//
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 ``, 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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in the Photo attachments configuration and trace how PhotoNaming// is written to QGIS project properties and read after reopening. Verify the behavior with a field containing whitespace, a leading digit, or punctuation, then check how the Mergin mobile app reads the property. Done means the expression round-trips after reopening and remains compatible with mobile consumption.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- json, python
- Domain
- desktop, mobile
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100