Skip to content

[18.0][FIX] dms_field: make template root directory creation idempotent - #501

Open
DealTechSrl wants to merge 2 commits into
OCA:18.0from
DealTechSrl:18.0-fix-dms_field-root_directory_duplicate
Open

[18.0][FIX] dms_field: make template root directory creation idempotent#501
DealTechSrl wants to merge 2 commits into
OCA:18.0from
DealTechSrl:18.0-fix-dms_field-root_directory_duplicate

Conversation

@DealTechSrl

Copy link
Copy Markdown

Issue: #500
Changed files:

  • dms_field/models/dms_field_template.py
  • dms_field/static/src/views/dms_list/dms_list_controller.esm.js

Root cause:
When initializing the Documents tab of a dms.field.template, the backend created the template root directory, but repeated calls to create_dms_directory() could try to create the same root again, causing:

"A directory with the same name already exists."

The created directory could also be missing template access groups, making it invisible to regular users. On the frontend, the DMS widget relied on cached dms_directory_ids, so a newly created template root directory could exist in the database but not appear immediately in the tree.

Solution:
Make dms.field.template root directory creation idempotent, keep access groups aligned with the template, and adjust the widget domain so the created root can be displayed after refresh.

Changed files:
- dms_field/models/dms_field_template.py
- dms_field/static/src/views/dms_list/dms_list_controller.esm.js

Root cause:
When initializing the Documents tab of a dms.field.template, the backend created
the template root directory, but repeated calls to create_dms_directory() could
try to create the same root again, causing:

"A directory with the same name already exists."

The created directory could also be missing template access groups, making it
invisible to regular users. On the frontend, the DMS widget relied on cached
dms_directory_ids, so a newly created template root directory could exist in the
database but not appear immediately in the tree.

Solution:
Make dms.field.template root directory creation idempotent, keep access groups
aligned with the template, and adjust the widget domain so the created root can
be displayed after refresh.
@OCA-git-bot

Copy link
Copy Markdown
Contributor

Hi @CarlosRoca13,
some modules you are maintaining are being modified, check this out!

@victoralmau

Copy link
Copy Markdown
Member

In my opinion, the best solution would be not to display the button to create the directory if it already exists.

@DealTechSrl

Copy link
Copy Markdown
Author

The PR fix problems due to recursive call of create_dms_directory() made by py and js.

Yes, hide the button when directory already exists can be an addition festure to add.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants