How to open a doc or pdf document from Odoo website? - html

How can we open a word document or pdf file by clicking on any link in Odoo? What are the steps need to be done?

1) Install module Document Management System (document).
2) Create directory (knowledge menu unit) or use existing one. Attach to this category required file (button "Attachments" above the form)
3) Since it was downloaded, it would generate an url. To access it: mouse right click on downloaded file - save url
4) Add the url to the website. Pressing it will download the file (publically available).
Note : Above Functionlity Work on odoo 8.
Document Management System module Remove in odoo 9 community and enterprice so this all file store in ir.attachment model.
So. Programatically, it is pretty much the same. The module 'document' allows to attach files to any object, including product.product (or product.template). So you have to find it:
attachment_ids = self.env['ir.attachment'].search([('res_model','=','product.product'),('res_id','=',product.id)]).
Where product.id - is id of needed product. E.g. you can store attachment_ids in product.product class as one2many field. After that you can get an url of any attachment. For example, for binary files:
for attach in attachment_ids:
url = 'https://yourcompany.com'+'/web/binary/saveas?model=ir.attachment&field=datas&filename_field=name&id='+str(attach.id)
This url may be easily added to the website product site, using foreach in product.attachment_ids

Related

Download files from object storage in visual app of Oracle Visual Builder. How to use data from ATP Database to get dinamically the name of the files

I am trying to download specific files from the Object Storage in the Oracle Cloud in my Oracle Visual Builder App (my visual builder is inside OIC, Oracle Integration Cloud).
I'd like to use the name of the "File URL" column (see the picture above) as the file name of the file to download from the Object storage, but this file name should be different from every download button (again in the picture above, you can see that every download button should download the file that has the name of the value of the "File URL" column). The File URL column is the field of a business object which is linked to the SDP variable and the data arrives from an ATP database that is inside the Oracle Cloud Infrastructure. The column "First File" contains the Download buttons. In the properties of this button there is an ojAction event which is linked to an action chain (see picture below).
I followed this guide (Download from OCI Storage section) to download one file, but I mapped the "filename" input parameter with a fixed value (the name of an existing files inside the object storage). Now, I'd like to make the filename value dynamic, but I don't know how to create a variable that gathers all the values of the specific column (File URL) in the DB and how to pass the single value of this column to the filename parameter. I have tried to create an SDP type variable that gets only the File URL values, but it's not getting the values of the file names. Do you have suggestions or have you seen a guide that is maybe useful to solve this issue?
If I understood the problem correctly, you can't retrive the specific file URL linked to the row button the user click in order to download the right file.
If that's the case, then instead of using a button, you could use the "first-selected-row" event linked to the table itself; that will pass all the values of the selected row as parameter, and will allow you to link "$variables.rowData.fileURL" or whatever the field is called to the REST call.

AngularJS: simulate URL click and rename file to be downloaded

I have this dashboard (in angularjs) where you can see some files you uploaded through a custom service. In the interface, every object has its own file_id property. The service I use can generate an URL to download the file based on this id, but it's available only for 15 minutes (which is an inconvenient, but I have to work with it).
What I did was the following: when I click on the Download button in the interface, I make a call in the back-end to a service that generates a new URL (every time) and then sends it to front-end.
Here, I am trying to simulate a click on that link with the following code:
var downloadLink = document.createElement('a');
document.body.appendChild(downloadLink);
downloadLink.setAttribute('download', 'result.' + fileExtension);
downloadLink.setAttribute('href', downloadURI);
downloadLink.click();
The download it's working, but the filename is not the desired one (it's a random string - actually a hash that service is using - without an extension) and that can trick the inexperienced users.
Can I do something regarding this? Is there a better method to achieve this?
Thanks!

Chm file displaying Page can not be displayed

I have created compiled html (chm) file using the Microsoft html Help Workshop. when I tried to open the generated chm file, it is showing message "Page Can not be displayed". But when I click on content topic only then I am able to see corresponding page content.
Do I need to set any thing so show the selected page by default.
The short way:
If the CHM help file resides on a network drive please copy this file to a local hard drive first and try again. You'll find some additional and troubleshooting information at:
http://www.help-info.de/en/xml/maml_troubleshooting_hh.xml
http://www.grainge.org/pages/authoring/chm_mspatch/896358.htm
Problem: The help file will appear, but instead of the topic text you will see an error message "this page cannot be displayed".
Cause: Microsoft released some security patches that makes it impossible to view CHM files that are stored on a network drive (as opposed to CHM files stored on your own computer).
Solution: There is a work-around to allow viewing across a network as discussed on the following links:
http://west-wind.com/weblog/posts/2928.aspx
http://www.helpscribble.com/chmnetwork.html
The problems can also occur if the CHM file name or the path to the file contains a number sign (#). If the CHM file name contains the # symbol, then the topics in the table of contents do not appear. If the path contains the # symbol, then you may receive an access violation error message.
To work around this issue, remove the # symbol from the file name or from the path to the file.
If you have a compiled collection of CHM's (so called "merged CHM") some other problems are possible.
If you are new in using HTMLHelp Workshop:
Question: Is there a way to set a default page to be displayed when a .chm file is opened? I would like to display the page associated with the first item in the Table of Contents.
Answer: You can do this with Microsoft HTMLHelp Workshop.
Open your HHP file with HH Workshop
Click the first icon "Change project options" on the "Project" tab
Set the "Default file" from the file list of the combo box
Compile your project
HHP file example (open with notepad):
\\\
..
[OPTIONS]
Binary TOC=No
Binary Index=Yes
Compiled File=Help_Coding-Example_VB6.chm
Contents File=Help_Coding-Example_VB6.hhc
Index File=Help_Coding-Example_VB6.hhk
Default Window=main
Default Topic=index.htm
..
///
There is a solution:
In your HTML Help Workshop go to the "Project" tab
Press button "Change project options"
In the "Default file" field put the name of your default file which is already exist in your project. File should have .htm extension (for example about.htm)
Compile project again and you will see that problem is fixed

HTML/CSS Editor with Multi-Computer Code Folding

I'm looking for a code editor that saves folded/collapsed code. I want to be able to open the file on a 2nd computer and have the same folded/collapsed code structure. I understand that HTML/CSS cannot have this preference built in. If the editor needs to save the file in some propriety file type, I'm fine with that. I just need to be able to export it as plain HTML/CSS files once it's ready for publishing.
(Windows 7)
UltraEdit supports code folding for text files of any type and it supports also saving/restoring of folds on close/open.
In menu Advanced there is the menu item Configuration. In the settings tree navigate to Editor Display - Code Folding and enable at least the settings Save folded lines and Enable show/hide lines and code folding.
By default UltraEdit remembers which file are open with which lines hidden/folded on exit in file uedit32.ini stored on Windows computers by default in directory %APPDATA%\IDMComp\UltraEdit\. But this file contains also all other user configurations like the 2 settings I wrote above.
Therefore it is better to use a project or at least a workspace for editing the HTML/CSS files for your website(s). A project/workspace can be created in menu Project with New Project/Workspace. Using a project/workspace results in remembering which files are open on closing the project in a separate project related workspace file instead of uedit32.ini. The workspace file remembers not only the open files on closing the project, it remebers also which lines are folded, where the caret is positioned in each file, which file was the active file on close, and some other information to restore the workspace on next opening of the project/workspace.
But before creating the project/workspace, you need to enable the setting Save project information for use on multiple systems at Advanced - Configuration - File Handling - Advanced. As you can read on help page opened by clicking on button Help of this configuration dialog, this setting results in storing the workspace file of a project in same directory as the project file.
The location of the project file is defined by you on creating the project/workspace and is quite often in root directory or a subdirectory of a local copy of a website. With *.prj (the project file) and *.pui (the project user interface file = workspace file) somewhere in directory tree of the website, you have those 2 files also shared between multiple systems together with the HTML and CSS files.
See the user forum topics Create project from an existing directory tree? and Why save files to a Project? in the user-to-user forums of UltraEdit and take also a look on Tutorials/Power Tips page of IDM Computer Solutions, Inc.
SynWrite (Windows) supports it. Make some folding, then save a session file (*.syn). This file contains folded states and more. Anytime later, just open session file (menu File - Sessions) and folding (and more) restored.
You have a CSSMENU editor where you can create menu bars. This editor saves a file in such a way that it can be moved to any other pc as you mentioned . Html file will be saved and the related Css files are stored in another folder where you can move those files as your wish. No need of changing any code.

Explore for files in Access

I have a form that a user uses to upload a CSV file. Right now the user has to type the full file path of the file into a text box. How can I get a browse for file popup to allow the user to navigate to the file instead of having to type the whole path? Is the functionality already present and I just don't know how to use it yet?
you can create your own class with API calls. Here you have the code. Or you can add a reference to Microsoft Office xx Object Library and use the FileDialog class.
Here you have an example of usage.
I prefer the first method, because you are not attached to an external library.