This question has been flagged
2 Replies
7595 Views

I've created a new module named event_extended, which depends on the module named event. In my module, I've created a class ee.diploma. I created a new menu option to access to the views of this projects:

<menuitem name="Diplomas"
            id="menu_action_event_diploma" parent="base.menu_event_main"
            action="action_event_diploma" sequence="11"
            groups="event.group_event_manager,event.group_event_user"/>

As you can see, I've set some groups to the menuitem: I copied them from other existing menuitem which was set on the event module code. I did this because I want my menu option to bevahe like that menuitem.

As I want to use the same user groups as the ones declared in the module event, I didn't create any XML file in the security folder. I've only created a CSV file (which I've included in the array data of __openerp__.py). This is my CSV:

id, name, model_id:id, group_id:id, perm_read, perm_write, perm_create, perm_unlink

access_ee_diploma, ee.diploma, model_ee_diploma, event.group_event_user, 1, 1, 1, 1

The problem is: I can't see the menu option if I'm logged as a normal user (it doesn't mind if my user belongs to event.group_event_manager or event.group_event_user).

Can anyone help me, please? I've seen several questions which ask the same as I do, and I've tried their answers with no result. There must be something I'm missing.

EDIT

The rows I write in my CSV are being ignored. I have the next structure in my module

event_extended
|_ controllers
|_ i18n
|_ report
|_ security
|_ static
|_ wizard
|_ __openerp__.py
... etc

And my __openerp__.py is:

{
    "name": "Extended Events",
    "version": "0.1",
    "depends": [
        "web",
        "event",
        "res_partner_extended",
    ],
    "author": "Juan Formoso <xxx@xxx.es>",
    "category": "Events",
    "description": """
    Later.
    """,
    'demo': [],
    'data': [
       'security/ir.model.access.csv',
       'event_view.xml',
       'event_registration_view.xml',
       'res_partner_view.xml',
       'wizard/add_partner_to_event_view.xml',
       'reports.xml',
    ],
    'installable': True,
}

Avatar
Discard

If you got to your settings menu, in the event user group, is the menu defined? Also, under the access rules, is the line created that you made in your CSV? Just regular checks. I have experienced the same sort of error before but did not find a solution. Also, this might sound stupid, but did you try to remove the "parent" tag from the menu item? If you do, your menu item will appear in the top bar. If THAT occurs, then we have the exact same problem and I would be more than curious to find the solution as well.

Author

Thank you very much @Ludo! I did what you said, removed the parent tag and my menu item appears on the top bar, but once again, only for admin, not for non admin users.

Author

If I go to Settings -> Technical -> Security -> Access Controls List, I can't see the row I added in my CSV file. Why?

Are you 100% sure that you added the CSV file to the __openerp__.py file of your module? Otherwise, the CSV contents might not be valid. Try adding a second line for the event manager group as well.

Author

The problem must be that I'm not adding the access rights properly, because I've just created a new record from the interface with the data of my CSV row, and now, it works. Is my CSV file wrong?

Author

Ok, I'll do it now!

Author

I added a second line in my CSV for event.group_event_manager with the same permissions, and it's beeing ignored too. I'm going to edit my question to show my __openerp__.py and module folder structure.

Not quite sure if it makes a difference, but in my configurations the csv file is always the last file of the "update" column, not the "data" column. Also, as Aitor mentioned you should use commas, but my assumption is that you just used those here to clarify what was filled in?

Author

Ok, I've been said to remove the update_xml and use data instead (I'm working on v7). But I'm having the same problem. I'm not using slashes (I've only written them here to show my CSV content). I copied a CSV from other module, opened and modified it with LibreOffice.

Best Answer

Hi Juan,

Try to use ',' (commas) instead of '/' (slashes) in your .csv file.

Avatar
Discard
Author

Thank you @Aitor! I didn't use slashes, I've only written them to show here the content of the CSV. I copied the CSV from other module, and then opened and modified it with LibreOffice. Could be that a problem?

Hi @Juan, It shouldn't be the problem. Anyway check the file with a plain text editor like (Linux) vi, nano or (Windows) notepad++, notepad itself...

Author

Thank you very much @Aitor!!! Sorry for the delay, I was on a holiday, but I've started the day opening the csv with nano and there were semicolons instead of commas! I changed them and now it's working! :)

Best Answer

I would do @Ludo's advice to remove the parent tag first. That will inherently test whether your access rules and menu item access are in order. If you can't see the menu without parent, then you need to check the access rules, etc. If it appears, check on the groups of all the parent menus, starting from base.menu_event_main. The user need to have access to all parent menus (if there is no group, then it is accessible to all users).

Avatar
Discard
Author

Thank you @Ivan! I removed the parent tag, and the behaviour is exactly the same, except for my menu item is now on the top bar. I can only see it if I am logged as an admin. I've created the CSV with only one line (the one I posted earlier). And I guess I shouldn't create any XML files in security folders because I only want to use the ones declared in the security folder of the module which my module depends on. Am I right? Which could be the problem?

As @Aitor had mentioned, are you using '/' instead of ','? You need to use ',' as separator. You can group text that is to be read as one column with double quotes. Also, you are mixing the use of update_xml and data. Not sure how it would turn out, but the sequence of data loading is important. I would advise that you choose one between update_xml or data.

Author

Thank you @Ivan! Ok, I've removed the update_xml and use data instead, I've edited the code above. But I'm having the same problem. I'm not using slashes (I've only written them here to show my CSV content). I copied a CSV file from other module, opened and modified it with LibreOffice.

@Juan, if you can get hold of the log when you install or update the module, it would be helpful. It would be better if the log is set to the debug or greater level (debug_rpc, debug_rpc_answer, etc.)