Skip to content

[IMP] dms: Add functionality to assign linked attachments record ID its value#401

Closed
kobros-tech wants to merge 1 commit intoOCA:18.0from
kencove:18.0-imp-dms-1
Closed

[IMP] dms: Add functionality to assign linked attachments record ID its value#401
kobros-tech wants to merge 1 commit intoOCA:18.0from
kencove:18.0-imp-dms-1

Conversation

@kobros-tech
Copy link
Copy Markdown
Contributor

@kobros-tech kobros-tech commented Apr 11, 2025

Similar to dms project we can select the model we want and then via a wizard, we can select the record id/ids of the same kind of the chosen model.

In the followers section I add the record of selected id there if the model is Partners

Based on the issue I raised in #399 that the field is readonly and is required on the same time. This commit is solving the problem and making it no problem at all in the UI.

@kobros-tech
Copy link
Copy Markdown
Contributor Author

kobros-tech commented Apr 11, 2025

Screenshot from 2025-04-12 16-55-00

Screenshot from 2025-04-12 16-55-26

Screenshot from 2025-04-12 16-55-37

@kobros-tech kobros-tech force-pushed the 18.0-imp-dms-1 branch 2 times, most recently from 785f62c to 9b2e2d7 Compare April 12, 2025 04:26
@kobros-tech
Copy link
Copy Markdown
Contributor Author

@pedrobaeza
@victoralmau

@kobros-tech
Copy link
Copy Markdown
Contributor Author

@rvalyi
@xaviedoanhduy

…ts value

Similar to dms project we can select the model we want and then via a wizard
we can select the record id/ids of the same kind of the chosen model.
Copy link
Copy Markdown
Member

@victoralmau victoralmau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO this is not necessary, it adds code to do something that should not be necessary because it is already done automatically: #404 (comment)

@kobros-tech
Copy link
Copy Markdown
Contributor Author

IMO this is not necessary, it adds code to do something that should not be necessary because it is already done automatically: #404 (comment)

excuse me, how can this be done automatically?
by sending an email for example? or what?

@victoralmau
Copy link
Copy Markdown
Member

Just create an attachment linked to a record (res.partner for example), the file (dms.file) will be created in the corresponding partner directory (the directory will be created automatically if it does not exist).

@kobros-tech
Copy link
Copy Markdown
Contributor Author

Just create an attachment linked to a record (res.partner for example), the file (dms.file) will be created in the corresponding partner directory (the directory will be created automatically if it does not exist).

If the field in the view of dms.file is readonly:

https://github.com/OCA/dms/blob/18.0/dms/views/dms_file.xml#L444

and is defined in the backend as related WITHOUT being editable there:
https://github.com/OCA/dms/blob/18.0/dms/models/dms_file.py#L193

from the code I see it is impossible to assign the res_id a value from the dms.file form view.

@kobros-tech
Copy link
Copy Markdown
Contributor Author

@victoralmau
instead of getting encoutagement to have this improvement and become a solution in similar cases, and even better to create a much easier code using OWL to select a record from the model we want, I am getting depressed.

I exerted some effort to understand the security of dms, and still need to understand it more so when I introduce my update it becomes smooth.

but for this PR, I see it very clear that a field is readonly and no way to create it in the GUI.

Shall I close this PR and finish discussion or we could have this new feature here and maybe in similar cases somewhere else?

@victoralmau
Copy link
Copy Markdown
Member

I think first of all, is this change necessary? The res_id field is readonly in the form view intentionally, according to the explained behavior, the directory and file will create itself.

What is the use case why you need to create the directory "manually" before? That would really be the initial question.

The security issue (there is no problem about it) is “simple” for files/directories that are linked to an attachment type storage with the “Inherit permissions from related record” checkbox checked, any user (portal or not) will be able to see the files/directories of a record, if they can see that record (res.partner or sale.order for example).

@kobros-tech
Copy link
Copy Markdown
Contributor Author

@victoralmau

usecase is just each customer should have access to exemption documents they sign or upload or send by email or even I add them to their related directories.

here what I like that each partner can have their own directory, but I don't understand how you create a folder for each partner at least this is not explained in the readme.

you and pedro told me once I upload attachment it will be in partner dir., but how you create the dir. without a required field and readonly at the same time.

for the access security, it is fine but I like to add access rules it will minimize the need to create a single group for each single user.

Please write to me steps from scratch to create a folder for Joel portal or any demo partner or record a video and I will continue working on.

I need to have a smooth update and minimize code and make it efficient.

in dms.dir I am blocked and in dms.file and even in the attachment dashboard due to res_id, maybe you have something I did not understand yet.

@victoralmau
Copy link
Copy Markdown
Member

I think an example use case with sales orders will help you to understand it.

Storage:
ejemplo-1

Creating several sales orders to different customers (each order has a linked attachment when sent by email).
ejemplo

The customerA portal user will only see your sales orders.
test-customer-a

The customerB portal user will only see your sales orders.
test-customer-b

Does this clarify how it works? I guess with this example you will understand that the directories are created automatically and it is NOT necessary to add access groups or specific rules, if the user can access the linked record (sales order) he will be able to see the directory and related files.

@kobros-tech
Copy link
Copy Markdown
Contributor Author

@victoralmau

thank you very much, I guess I will update the readme with a use case for very new users.

I will work on that if I don't need updating or not.

@hitrosol
Copy link
Copy Markdown

Thanks for the explanation of using the dms_attachment_link. I just know how to use it :)
But I believe there will be some space for improvement, and having the capability to manage the sub folder below Attachment Storage will be great 👍

@victoralmau
Copy link
Copy Markdown
Member

victoralmau commented Apr 22, 2025

Thanks for the explanation of using the dms_attachment_link. I just know how to use it :) But I believe there will be some space for improvement, and having the capability to manage the sub folder below Attachment Storage will be great 👍

I think it is important to clarify that the above explanation is ONLY of the dms module.

The dms_attachment_link module is an extra module that has a “different” functionality: Through a wizard it allows you to create an attachment linked to the corresponding element using the selected file as a “template”. An example of this would be to create an attachment in a sales order “installation manual” through that wizard.

@kobros-tech
Copy link
Copy Markdown
Contributor Author

@victoralmau

is dms able to include sign requests (signed) docs, or I can add this feature similar to sales orders you showed me?

@victoralmau
Copy link
Copy Markdown
Member

The sign request can be linked to any record through the record_ref field, but if you consider it necessary, you can create a module similar to maintenance_sign_oca for dms.

@kobros-tech
Copy link
Copy Markdown
Contributor Author

@victoralmau

I tried to follow but I didn't have the same result, not directories created for sales orders.
I did this work locally without real mailing!

Screenshot from 2025-05-13 17-18-49

Screenshot from 2025-05-13 17-18-42

Screenshot from 2025-05-13 17-18-37

@kobros-tech
Copy link
Copy Markdown
Contributor Author

whether for Partners dir once I upoaded attachment for admin, I sow it.

This means the dms did not create a root dir for sales orders and did not create subfolders as a result.

In contrast for already created root dirs like Partners subfolders are created as expexted.

Please make sure the function is as expected and introduced so I can find a base to start from.

@kobros-tech
Copy link
Copy Markdown
Contributor Author

We may write about this in readme so that users can use it easily.

@victoralmau
Copy link
Copy Markdown
Member

You have forgotten an important step, it is necessary to create a root folder linked to this storage and to the sale.order model.

ejemplo-1
ejemplo-2

@kobros-tech
Copy link
Copy Markdown
Contributor Author

@victoralmau

do you mean I should create the root directory for the specific model like sales orders and for each new attachment in a record another new related dms dir record will be created?

let me try then.

@github-actions
Copy link
Copy Markdown

There hasn't been any activity on this pull request in the past 4 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 30 days.
If you want this PR to never become stale, please ask a PSC member to apply the "no stale" label.

@github-actions github-actions Bot added the stale PR/Issue without recent activity, it'll be soon closed automatically. label Sep 14, 2025
@github-actions github-actions Bot closed this Oct 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stale PR/Issue without recent activity, it'll be soon closed automatically.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants