Skip to Content
Menu
This question has been flagged
5 Replies
19527 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()


   
    

 

 

 

 

 

 

 

 

Avatar
Discard
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
Best Answer

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").

Avatar
Discard
Best Answer

__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>

Avatar
Discard
Author

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'

Author

How to change this code i get error from view

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'

Author

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

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

Best Answer

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.. ?
 

Avatar
Discard
Author

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

Best Answer

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

Avatar
Discard
Best Answer

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.

Avatar
Discard