Reputation: 686
Goal : To add an option in the user form that has the label ‘Demo module access’ with a drop down menu to choose the security groups for a custom module.
Model name : simcard_simcard
Module name : simcard
my ir.model.access.csv :
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
demo_admin, Model admin access,model_simcard_simcard,simcard.group_manager,1,1,1,1
demo_user, Model user access,model_simcard_simcard,simcard.group_user,1,0,0,0
and my security>user_groups.xml :
<record model="ir.module.category" id="module_management">
<field name="name">Demo module access</field>
<field name="description">User access level for this module</field>
<field name="sequence">3</field>
</record>
<record id="group_user" model="res.groups">
<field name="name">User</field>
<field name="implied_ids" eval="[(4, ref('base.group_user'))]"/>
<field name="category_id" ref="simcard.module_management"/>
</record>
<record id="group_manager" model="res.groups">
<field name="name">Manager</field>
<field name="implied_ids" eval="[(4, ref('simcard.group_user'))]"/>
<field name="category_id" ref="simcard.module_management"/>
<field name="users" eval="[(4, ref('base.user_root'))]"/>
</record>
My manifest file :
# any module necessary for this one to work correctly
'depends': ['base'],
# always loaded
'data': [
'security/user_groups.xml',
'security/ir.model.access.csv',
'views/views.xml',
'views/templates.xml',
],
'qweb': ['static/xml/tree_view_button.xml'],
# only loaded in demonstration mode
'demo': [
'demo/demo.xml',
],
'installable': True,
'auto_install': False,
'application': True,
}
And i got this error :
018-10-10 11:00:32,234 8890 ERROR test werkzeug: Error on request:
Traceback (most recent call last):
File "/Users/anubhavjhalani/odoo-env10/lib/python2.7/site-packages/werkzeug/serving.py", line 193, in run_wsgi
execute(self.server.app)
File "/Users/anubhavjhalani/odoo-env10/lib/python2.7/site-packages/werkzeug/serving.py", line 181, in execute
application_iter = app(environ, start_response)
File "/Users/anubhavjhalani/odoo10/odoo/service/server.py", line 245, in app
return self.app(e, s)
File "/Users/anubhavjhalani/odoo10/odoo/service/wsgi_server.py", line 186, in application
return application_unproxied(environ, start_response)
File "/Users/anubhavjhalani/odoo10/odoo/service/wsgi_server.py", line 172, in application_unproxied
result = handler(environ, start_response)
File "/Users/anubhavjhalani/odoo10/odoo/http.py", line 1326, in __call__
return self.dispatch(environ, start_response)
File "/Users/anubhavjhalani/odoo10/odoo/http.py", line 1300, in __call__
return self.app(environ, start_wrapped)
File "/Users/anubhavjhalani/odoo-env10/lib/python2.7/site-packages/werkzeug/wsgi.py", line 599, in __call__
return self.app(environ, start_response)
File "/Users/anubhavjhalani/odoo10/odoo/http.py", line 1482, in dispatch
odoo.registry(db).check_signaling()
File "/Users/anubhavjhalani/odoo10/odoo/__init__.py", line 52, in registry
return modules.registry.Registry(database_name)
File "/Users/anubhavjhalani/odoo10/odoo/modules/registry.py", line 59, in __new__
return cls.new(db_name)
File "/Users/anubhavjhalani/odoo10/odoo/modules/registry.py", line 83, in new
odoo.modules.load_modules(registry._db, force_demo, status, update_module)
File "/Users/anubhavjhalani/odoo10/odoo/modules/loading.py", line 373, in load_modules
force, status, report, loaded_modules, update_module, models_to_check)
File "/Users/anubhavjhalani/odoo10/odoo/modules/loading.py", line 270, in load_marked_modules
perform_checks=perform_checks, models_to_check=models_to_check
File "/Users/anubhavjhalani/odoo10/odoo/modules/loading.py", line 182, in load_module_graph
_load_data(cr, module_name, idref, mode, kind='data')
File "/Users/anubhavjhalani/odoo10/odoo/modules/loading.py", line 96, in _load_data
tools.convert_file(cr, module_name, filename, idref, mode, noupdate, kind, report)
File "/Users/anubhavjhalani/odoo10/odoo/tools/convert.py", line 845, in convert_file
convert_xml_import(cr, module, fp, idref, mode, noupdate, report)
File "/Users/anubhavjhalani/odoo10/odoo/tools/convert.py", line 898, in convert_xml_import
doc = etree.parse(xmlfile)
File "src/lxml/lxml.etree.pyx", line 3427, in lxml.etree.parse (src/lxml/lxml.etree.c:85131)
File "src/lxml/parser.pxi", line 1803, in lxml.etree._parseDocument (src/lxml/lxml.etree.c:124287)
File "src/lxml/parser.pxi", line 1823, in lxml.etree._parseFilelikeDocument (src/lxml/lxml.etree.c:124599)
File "src/lxml/parser.pxi", line 1718, in lxml.etree._parseDocFromFilelike (src/lxml/lxml.etree.c:123258)
File "src/lxml/parser.pxi", line 1139, in lxml.etree._BaseParser._parseDocFromFilelike (src/lxml/lxml.etree.c:117808)
File "src/lxml/parser.pxi", line 573, in lxml.etree._ParserContext._handleParseResultDoc (src/lxml/lxml.etree.c:110510)
File "src/lxml/parser.pxi", line 683, in lxml.etree._handleParseResult (src/lxml/lxml.etree.c:112276)
File "src/lxml/parser.pxi", line 613, in lxml.etree._raiseParseError (src/lxml/lxml.etree.c:111124)
XMLSyntaxError: Extra content at the end of the document, line 7, column 1
Am i missing something ? this error is coming from user_groups.xml.
Upvotes: 4
Views: 1516
Reputation: 686
fixed my problem with this xml :
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<record model="ir.module.category" id="module_management">
<field name="name">Demo module access</field>
<field name="description">User access level for this module</field>
<field name="sequence">3</field>
</record>
<record id="group_user" model="res.groups">
<field name="name">User</field>
<field name="implied_ids" eval="[(4, ref('base.group_user'))]"/>
<field name="users" eval="[(4, ref('base.user_root'))]"/>
<field name="category_id" ref="simcard.module_management"/>
</record>
<record id="group_manager" model="res.groups">
<field name="name">Manager</field>
<field name="implied_ids" eval="[(4, ref('simcard.group_user'))]"/>
<field name="category_id" ref="simcard.module_management"/>
</record>
</data>
</odoo>
Upvotes: 0
Reputation: 11141
Generally, User has limited access right compare to Manager. So manger has more privilege of root access right.
I have updated it so try with following code:
<record model="ir.module.category" id="module_management">
<field name="name">Demo module access</field>
<field name="description">User access level for this module</field>
<field name="sequence">3</field>
</record>
<record id="group_user" model="res.groups">
<field name="name">User</field>
<field name="implied_ids" eval="[(4, ref('base.group_user'))]"/>
<field name="category_id" ref="user_access_rights_demo.module_management"/>
</record>
<record id="group_manager" model="res.groups">
<field name="name">Manager</field>
<field name="implied_ids" eval="[(4, ref('user_access_rights_demo.group_user'))]"/>
<field name="category_id" ref="user_access_rights_demo.module_management"/>
<field name="users" eval="[(4, ref('base.user_root'))]"/>
</record>
Other then your code is ok to me.
NOTE
These two files .xml and .csv
must be listed in __manifest__.py
as other view files are given. Something like,
'data': [
'security/user_groups.xml',
'security/ir.model.access.csv',
]
Afterwards, restart Odoo service and upgrade simcard_simcard module.
Upvotes: 1
Reputation: 1
You must add this parameter in the manifest.py or openerp.py file 'application': True,
Upvotes: 0