Odoo Help


How to add menu item and show all files attached to all projects?

on 10/14/14, 2:37 AM 5,237 views

Hey everybody

Since today I'm experimenting with Odoo 8 its project management module. What I really miss is an overview of all files that are attached to all projects. In essence a way to view all files stored for any project in a list.
What I would like to get is this:

And then when you click on this menu item you would get a view which shows ALL attached files for ALL projects. For example:

Could anybody tell me how to program this or build it? I'd like to learn more about customizing modules but I don't know how or where to start..
EDIT: I found some documentation at https://www.odoo.com/documentation/8.0/howtos/backend.html but it doesn't help me much further..

Thank you


René Schuster

--René Schuster--
| 5 5 8
Weinheim, Germany
--René Schuster--

Challenge Everything!

René Schuster
On 10/14/14, 10:12 AM

This is not the easiest task to start customizing Odoo (OpenERP).

Anyways, there are two ways to achieve your goal:

  1. Either use the web interface to add your menu and view
  2. Or create a custom module with python and xml

A quick overview of the seperate steps (for both ways mentioned above):

  • Create your new menu item at the specific position
  • Add a window action to the menu item to open your view
  • Create the view for your attachments


Let's start with the view. From your screenshots I can see, that you want a kanban view for the attachments. I'm not very experienced with kanban views, so I will show you how to add a list view and you can add the kanban (and form) views, referring the offical view of the ir.attachment module.

If you choose to create a custom module, you will need a xml file with a designative name like project_attachment_view.xml. This file will contain the view, the action and the menu. The complete file content is surrounded by the tags <openerp> and <data> (xml tags are closed with the same tag with a slash in front </data> </openerp>). A view is a record of the module ir.ui.view and might look like that:

<record id="project_attachment_list_view" model="ir.ui.view">
    <field name="name">project.attachment.list.view</field>
    <field name="model">ir.attachment</field>
    <field name="arch" type="xml">
        <tree string="Project Attachments">
            <field name="name"/>
            <field name="datas_fname"/>
            <field name="description"/>
            <field name="res_name"/>
            <field name="file_size"/>

The record name can be any name and the model is ir.attachments, since you want records of that model to be displayed. The architecture is of type xml and contains a tree view with some fields of the ir.attachment model. You can add all fields that are defined in a model (check ir_attachment.py for more fields).

If you decide to create your view via the web interface, create a new view under Settings -> Technical -> User Interface -> Views. (Make sure your user has Technical Settings checked under the users Access Rights).

Menu Items and Window Actions are also found under the Technical Settings menu.
Add all the required information according to the given code examples through the web interface.


Now for the new Window Action! In the same xml file add a new record for window actions like that:

<record id="open_project_attachment_view" model="ir.actions.act_window">
    <field name="name">All Files</field>
    <field name="res_model">ir.attachment</field>
    <field name="view_type">form</field>
    <field name="view_mode">kanban,tree,form</field>
    <field name="domain">[('res_model', '=', 'project.project')]</field>
    <field name="context">{}</field>
    <field name="view_id" ref="project_attachment_list_view"/>
    <field name="search_view_id" ref=""/>

The view_id should be the id that you have used for your previously coded view. view_type and view_mode are used to controll what kind of view are possible. The most tricky part is the domain. Since you want only documents displayed, that belong to projects, you have to filter all ir.attachment records. The field res_model contains the name of the related model. For the project model, the name is project.project.


Finally the menu item. Still in the same xml file add this:

    name="All Files"

The action is the id of the previously coded window action. The sequence gives the order of the menu items with the same parent menu. To have your menu item displayed after the Projects and Task menu, simply make the sequence big enough.


Last but not least, to make a module out of your xml file you need a new folder with a name like project_attachment. This folder should contain your xml file, a plain __init__.py file to tell python that the folder is a module, and a __openerp__.py file with further information. Your __openerp__.py should look like this:

    'name': 'Project Attachment Menu',
    'version': '1.0',
    'author': 'you@example.com',
    'description': """
Project Attachments

    'depends': ['project', 'ir.attachment'],
    'data': [
    'installable': True,


you should be able to install your new module if you place your new project_attachment folder under an valid addons folder. All addon folders are listed in the openerp-server.conf file of your OpenERP installation after the keyword addons_path as comma seperated list.


Hope I could help.


Thank you very much for this big answer René! Could you tell me why I'm not seeing any attachments though? I can see the new menu items, see that I can access the kanban view etc but I can't see any files.. Is there a reason for that? And would you mind asking me some more questions tommorow? This is quite a lot and I'd love to understand every part so I can do this for myself from now on! This put me a step forward!

on 10/14/14, 11:13 AM

@René I do understand this for the most part but why doesn't it show me any files? I've tried without the domain etc but I can't get any files to show up. What am I missing / is missing in the code? Don't seem to get this working..

on 10/15/14, 4:28 AM

Are there attachments stored in your current database? There is the option, that your user does not have access rights for the ir.attachment module.

René Schuster
on 10/15/14, 5:32 AM

Yes I have multiple attachments in my database as I've attached a few files to my projects. My user is the main administrator, with technical features and developer mode on so he should be able to see everything? I'm not sure why nothing is showing up.

on 10/15/14, 5:34 AM

Strange. Try to alter the view_mode to "tree,form" in the window action, or remove the whole lines for "view_id" and "search_view_id".

René Schuster
on 10/15/14, 6:00 AM

Removing the view_id and search_view_id doesn't fix anything. What exactly do you mean by altering the view mode in the window action? Do you mean in the code to edit the record and then under tree,form in place of tree,form,kanban? Because this doesn't work either..

on 10/15/14, 7:35 AM
Pau Ubach
On 10/14/14, 6:15 AM

You can start here:


Sadly there is no information about customizing menu's or about how to write your own modules..

on 10/14/14, 7:06 AM
You must search a bit, but the info is there:


Example of module creation

Menus information
Pau Ubach
on 10/14/14, 9:09 PM

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 10/14/14, 2:37 AM
Seen: 5237 times
Last updated: 3/16/15, 8:10 AM