[18.0][FIX] dms_field: make template root directory creation idempotent - #501
[18.0][FIX] dms_field: make template root directory creation idempotent#501DealTechSrl wants to merge 2 commits into
Conversation
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.
|
Hi @CarlosRoca13, |
|
In my opinion, the best solution would be not to display the button to create the directory if it already exists. |
|
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. |
I still think this change just masks the problem; that is, why is the method being called multiple times? |
Issue: #500
Changed files:
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.