Steps to reproduce
- Install
dms_field.
- Create a
dms.field.template manually from the UI.
- Set:
- a DMS storage
- a model
- one or more DMS access groups
- Open the
Documents tab of the template.
- Click the storage initialization button/icon.
Current behavior
The root dms.directory for the dms.field.template is created in the database, for example:
name = My embedded2
res_model = dms.field.template
res_id = <template_id>
is_root_directory = True
root_directory_id = <same directory id>
However, the newly created directory is not displayed in the DMS widget.
If the user clicks the storage initialization button again, create_dms_directory() tries to create the same root directory again and raises:
A directory with the same name already exists.
In some cases the created directory may also miss the template access groups, making it not readable by a regular user due to DMS record rules
Suggested fix
Make the dms.field.template branch of create_dms_directory() idempotent by returning the existing linked root directory when present, and ensure missing template groups are applied.
Additionally, in the JS controller, include a fallback domain based on:
res_model = dms.field.template
res_id = current template id
so the widget can display the newly created root directory even before the form one2many cache is refreshed.
Could you please confirm whether this is a duplicate of an existing issue or an expected behavior?
If this is confirmed as a bug, we have ready a pull request with the proposed backend and frontend adjustments.
Steps to reproduce
dms_field.dms.field.templatemanually from the UI.Documentstab of the template.Current behavior
The root
dms.directoryfor thedms.field.templateis created in the database, for example:However, the newly created directory is not displayed in the DMS widget.
If the user clicks the storage initialization button again,
create_dms_directory()tries to create the same root directory again and raises:In some cases the created directory may also miss the template access groups, making it not readable by a regular user due to DMS record rules
Suggested fix
Make the
dms.field.templatebranch ofcreate_dms_directory()idempotent by returning the existing linked root directory when present, and ensure missing template groups are applied.Additionally, in the JS controller, include a fallback domain based on:
so the widget can display the newly created root directory even before the form one2many cache is refreshed.
Could you please confirm whether this is a duplicate of an existing issue or an expected behavior?
If this is confirmed as a bug, we have ready a pull request with the proposed backend and frontend adjustments.