Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
1 ตอบกลับ
4158 มุมมอง

I just want a button that opens a specific folder on my computer in file explorer (windows) or finder (apple), based on a setting in the user's form (windows or apple) and a char field (specifying the path) on the project record.

The following is what I was testing: 

based on this video :
https://www.youtube.com/watch?v=ROQoJrLZR98

In the project form I have a char variable "link"   (D:\OneDrive\10 PROJECTS)

In the user's form I have a selection field  "os_user" with selection of 'windows' or 'apple'.

I could create a server action with "execute python code" like this:
import os
if user.os_user == "windows":
    os.system('explorer')

else:  

    os.system('finder')
os.startfile(record.link)

But Odoo won't allow me to use "import os" in the server action.


Is there any other way to achieve the result? (beside making a custom module?)


PS if there is a solution for only windows or only apple, i would also be very gratefull!!!


thanks guys!


roeland

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Maybe you can use the storage_backend module from OCA.

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
1
ม.ค. 21
3423
[Odoo12] Store file to folder on HDD แก้ไขแล้ว
1
ต.ค. 19
6460
0
ก.ค. 17
5779
2
ต.ค. 24
3891
0
ก.ย. 23
1234