This question has been flagged
1 Reply
2655 Views

Odoo v.12

Hello all,

I'm struggling against this :


I'm looking for a way that allow me to 

click on  the link underlined




(this link referes to a folder shared in a close net) of the field “Path Pratica”  ,then should be open a filesystem pop-up(  or something else)  that allow the users  to browse inside the directory and open/create/delete the file inside as normally do windows when we open the archive

 

 

 I hope I was clear,


I would be glad if someone could help me,

Avatar
Discard

Same issue here.
Dit you resolve this?

I am also looking for this Harri Matero, did you solve this?

Best Answer

Hello,

To achieve the functionality you’ve described for Odoo v12, you can follow these steps:

  1. Create a new custom module in Odoo to add this feature.
  2. Add a new Python method in the model where the “Path Pratica” field is located. This method will handle opening the folder when the link is clicked.
from odoo import models, fields, api
import os

class YourModel(models.Model):
    _inherit = 'your.model.name'

    def open_folder(self):
        path = self.path_pratica
        if path:
            try:
                os.startfile(path)
            except Exception as e:
                raise Warning('An error occurred while opening the folder: {}'.format(e))
        else:
            raise Warning('No folder path specified.')
  1. Next, add a button on the form view of your model to invoke this function:
  1. (Optional) To make it appear like an underlined link, you may need to add some CSS styling to that button:
  oe_link

Just replace 'your.model.name' with the correct model name where the “Path Pratica” field is located.

Once implemented, users should be able to click on the underlined button/link in Odoo’s form view which will then open a file explorer window allowing them to browse and interact with files within the specified directory.

Please let me know if you have any questions or need further assistance!


Avatar
Discard

Anything done in Python will open the file on the server side. I believe the user wants to see it in the clients local computer (since they are using a shared filesystem)