Odoo Help

Welcome!

This community 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.

-1

Security Access Rights Error For a Custom Module

By
Odoo
on 1/13/15, 5:53 AM 4,283 views

I need to know how we can apply different access permission like

In Users->Access Rights-> Application (we can access different rights in modules like Sales,HR based on selection field(user,Manager) ) ,Same way I want to show my custom module under Application tab.

My module name = library_management_credatv (I want to set two level of access rights one is USer,admin How?)

Can you explain with a simple example

I tried from my side But I got this Error from my custom module ,

raise ValueError('No such external ID currently defined in the system: %s.%s' % (module, xml_id)) ValueError: No such external ID currently defined in the system: library_management_credatv.group_training_user

This is My code---------------------------------------------------------------------------------------------------------

library_management_credatv  =module name

menu apllied  view.xml file  --------------

<menuitem id="main_library_menu_id" name="Library Mangement" sequence="0" groups="library_management_credatv.group_training_user"/>
 

.csv file------------------------------------------

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

 

access_training_category_user    library_management_credatv.category user    model_library_form

 

    library_management_credatv.group_training_user    1    1    1    1

 


access_training_idea_user    library_management_credatv.idea user    model_product_product

 

    library_management_credatv.group_training_user    1    1    1    1

 

 

 

 

training_security.xml-------------------


<?xml version="1.0" encoding="utf-8" ?>
<openerp>
    <data noupdate="0">
        
      <record model="res.groups" id="library_management_credatv.group_tool_user">
      
     <field name="name">Training User</field>
   <field name="category_id" ref="library_management_credatv.module_category_tools"/>
    
    
    </record>
    </data>    
</openerp>

 

 

 


openerp.py==============================

 

{
    'name':'Library Management',
    'version':'7.0',
    'author':'Me',
    'website':'http://www.test.com',
    'depends':['base','sale'],
    'category':'General',
    'description':'Library management  module',
    'data':[
            'book_info_view.xml',
            #'bookid_sequence.xml',
            'student_id.xml',
            'security/training_security.xml',
            'security/ir.model.access.csv',
            ],
    'demo':[]
}

 


.py file=======================================

 


from osv import osv,fields
import time

 

 

 


class product_product(osv.osv):
    
    _inherit='product.product'
    
    
   
    _columns={
              'subject_id':fields.many2many('info.subject','subject_book_rel','book_id','sub_id','Subject'),
              
              'authors':fields.many2many('res.partner','book_author_rel','book_id','author_id','Author'),
              'publisher_name':fields.many2one('res.partner','Publisher'),
              'date_year':fields.date('Date'),
              'purchase_date':fields.date('Purchase Date'),
              'bill_date':fields.datetime('Bill Date'),
              'book_id':fields.char('ID',readonly=True),
              'book_instance_number':fields.char('Book Instance No'),
              'days_to_lend':fields.integer('Days To Lend',required=True)


              }
    _defaults={
              # 'book_id':lambda self, cr, uid, context:self.pool.get('ir.sequence').get(cr, uid, 'test.test.code'),
 
               }
    
    
  
product_product()
    

 

class library_form(osv.osv):
    
    _name='library.form'
    
    _columns={
              'name':fields.char('ID',required=True,readonly=True,select=True,states={'draft':[('readonly', False)]}),
          
              'student_id':fields.many2one('res.partner','Student',required=True,readonly=True,select=True,states={'draft':[('readonly', False)]}),
       
              
              }
    _defaults={
               'name':lambda self,cr,uid,context:self.pool.get('ir.sequence').get(cr,uid,'library.form'),
               'state':'draft'
              # 'state':'draft'
               }
    
library_form()


   
    

 

 

 

 

 

 

 

 

Hi Here I attached my module

On Wed, Jan 14, 2015 at 12:11 PM, atchuthan <atchuthantu@mail.odoo.com> wrote:

A new answer for Security Access Rights Error For a Custom Module has been posted. Click here to access the post.

--
atchuthan



--
Thanks&Regards
Libu Koshy
Odoo
on 1/14/15, 2:00 AM
0

Bole

--Bole--
2385
| 5 4 6
Zagreb | Karlovac, Croatia
--Bole--

there is only 10 kind of people the ones that understand binary ... and others

Bole
On 1/13/15, 6:53 AM

In your security xml file.. you declared id  id="library_management_credatv.group_tool_user">
In your ir.security.access you try to assign:  library_management_credatv.group_training_user 

maybe you want to re check those ids?

2.nd edit:
also i don't see :  <field name="category_id" ref="library_management_credatv.module_category_tools"/>
category defined anywhere.. ?
 

I got same error I changed the code as per your suggestion

Odoo
on 1/13/15, 7:05 AM
0

Med Said BARA

--Med Said BARA--
2664
| 5 5 7
Algeria
--Med Said BARA--
Med Said BARA
On 1/13/15, 11:52 AM

This can help you: http://stackoverflow.com/questions/16601836/error-occured-while-adding-security-to-a-module-in-openerp

Last, you Menu "Library Mangement" will not appear if there is no Sub-Menu under it (another menu in the view with: parent="main_library_menu_id").

0

Atchuthan - Technical Consultant, Sodexis Inc

--Atchuthan - Technical Consultant, Sodexis Inc--
3918
| 5 3 8
Puducherry, India
--Atchuthan - Technical Consultant, Sodexis Inc--
Passionate coder in Python/Odoo(formerly known as OpenERP).

Contact me via GMail: atchuthantu@gmail.com via Skype: atchuthan_skype
via Linkedin: http://in.linkedin.com/in/atchuthantu
Atchuthan - Technical Consultant, Sodexis Inc
On 1/14/15, 1:41 AM

__openerp__.py

{
    'name':'Library Management',
    'version':'7.0',
    'author':'Me',
    'website':'http://www.test.com',
    'depends':['base','sale'],
    'category':'General',
    'description':'Library management module',
    'data':[
            'security/training_security.xml',         #Add security, wizard and other data files first
            'security/ir.model.access.csv',

            'book_info_view.xml',
            #'bookid_sequence.xml',
            'student_id.xml',
            ],
    'demo':[]
}

In security.xml,
        <record model="ir.module.category" id="module_category_tools">
            <field name="name">Library mgt System</field>
            <field name="sequence">5</field>
        </record>
        <record id="group_user_lms" model="res.groups">    <!-- Group ID to be linked @ ir.model.access.csv -->
            <field name="name">User</field>
            <field name="category_id" ref="module_category_tools" />
        </record>
        <record id="group_admin_lms" model="res.groups">
            <field name="name">Admin</field>
            <field name="category_id" ref="module_category_tools" />
            <field name="implied_ids" eval="[(4, ref('group_user_lms'))]" />

            <field name="users" eval="[(4, ref('base.user_root'))]" />
        </record>

Hi atchuthan ...Thanks for replay... I changed code but got this error now.. Exception: Module loading library_management_credatv failed: file library_management_credatv/security/ir.model.access.csv could not be processed: Line 1 : No matching record found for external id 'library_management_credatv.group_training_user' in field 'Group'

Odoo
on 1/14/15, 1:54 AM

How to change this code i get error from view

Odoo
on 1/14/15, 1:58 AM

then modify the group linked at ir.model.access.csv with your group id i.e. 'library_management_credatv.group_training_user' ---> 'library_management_credatv.group_user_lms'

Atchuthan - Technical Consultant, Sodexis Inc
on 1/14/15, 4:27 AM

I changed in csv file ,and in view.xml file is ..... is this correct

Odoo
on 1/14/15, 4:38 AM

i didn't get your attachment... if possible send it via skype (username- 'atchuthan_skype')

Atchuthan - Technical Consultant, Sodexis Inc
on 1/14/15, 5:16 AM
0
Farid Ghanchi
On 1/13/15, 7:52 AM

Hello LIBU,

First you create one categoryrelated to library, EX:

record model="ir.module.category" id="module_lms">
            <field name="name">Library mgt System</field>
            <field name="sequence">2</field>
            <field name="visible" eval="0" />
        </record>

then assign it to that id

<field name="category_id" ref="module_lms"/>

Thanks

0

Ivan

--Ivan--
3210
| 5 3 6
Jakarta, Indonesia
--Ivan--
Ivan
On 1/13/15, 8:07 AM

I'm assuming that you have create module category with id "library_management_credatv.module_category_tools" as @farid has indicated.

I'm also assuming that you have synchronized the group name as @Bole has suggested.

The error may occur if you use the group within view XML because you order the view XML before the group and security XML.  I would suggest that you try to put 'security/training_security.xml' as the first item in 'data' and 'security/ir.model.access.csv' as the 2nd.  Followed by others.

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

2 follower(s)

Stats

Asked: 1/13/15, 5:53 AM
Seen: 4283 times
Last updated: 3/16/15, 8:10 AM