Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: 18.0
Choose a base branch
from

Conversation

kobros-tech
Copy link

@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
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
Author

@pedrobaeza
@victoralmau

@kobros-tech
Copy link
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
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
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
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
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
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
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
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
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
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

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
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants