No matching record found for external id 'groups_group1' in field 'Group' - odoo

Please i want to establish access rights for my module, so I modify the file csv I try to install the module, but this error appears at the time of installation of the module:
File "/home/omar/odoo/odoo11/odoo/modules/loading.py", line 95, in _load_data
tools.convert_file(cr, module_name, filename, idref, mode, noupdate, kind, report)
File "/home/omar/odoo/odoo11/odoo/tools/convert.py", line 785, in convert_file
convert_csv_import(cr, module, pathname, fp.read(), idref, mode, noupdate)
File "/home/omar/odoo/odoo11/odoo/tools/convert.py", line 832, in convert_csv_import
raise Exception(_('Module loading %s failed: file %s could not be processed:\n %s') % (module, fname, warning_msg))
Exception: Module loading moduletest failed: file moduletest/security/ir.model.access.csv could not be processed:
No matching record found for external id 'groups_group1' in field 'Group'
No matching record found for external id 'groups_group2' in field 'Group'

One of the things that make this error occur is when you don't respect the order of security files, you have to put your .xml file that is related to security before the .csv file in your __ manifest __.py
Here's a simple example:
'data': [
'views/security.xml',
'security/ir.model.access.csv',
# ... other includes ...
]

this is a sample code for category and group
<record model="ir.module.category" id="module_category_stock_quotation_request"> -->
<!-- <field name="parent_id" ref="module_category_localization" /> -->
<!-- <field name="name">Stock Transfert Request</field>
<field name="visible" eval="0" />
</record>
<record id="group_stock_quotation_request_user" model="res.groups">
<field name="name">User</field>
<field name="implied_ids" eval="[(4, ref('base.group_user'))]"/>
<field name="category_id" ref="module_category_stock_quotation_request"/>
</record>
<record id="group_stock_quotation_request_manager" model="res.groups">
<field name="name">Manager</field>
<field name="implied_ids" eval="[(4, ref('transfert_request.group_stock_quotation_request_user'))]"/>
<field name="category_id" ref="module_category_stock_quotation_request"/>
</record>

Related

Module loading failed while updating acl for newly created model(Model) in odoo

below i have mentioned the grievance.redressal(model), view and access control list. i have tried to added acl for grievance.redressal(model) in ir.model.access.csv. but module is failed when server updation
class file:
class grievance_redressal(models.Model):
_name = 'grievance.redressal'
name = fields.Char('Name with Initial', size=64)
View:
<record id="view_grievance_redressal_form" model="ir.ui.view" >
<field name="name">grievance.redressal.form</field>
<field name="model">grievance.redressal</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Grievance Redressal" version="7.0">
<sheet>
<group>
<field name="name"/>
</group>
</sheet>
</form>
</field>
</record>
<record id="view_grievance_redressal_tree" model="ir.ui.view">
<field name="name">grievance.redressal.tree</field>
<field name="model">grievance.redressal</field>
<field name="arch" type="xml">
<tree string="Grievance Redressal">
<field name="name"/>
</tree>
</field>
</record>
<record id="action_grievance_redressal" model="ir.actions.act_window">
<field name="name">Grievance Redressal</field>
<field name="res_model">grievance.redressal</field>
<field name="view_mode">tree,form</field>
<field name="view_type">form</field>
</record>
<menuitem action="action_grievance_redressal" id="grievance_redressal_menu" parent="operations" sequence="30"/>
ACL:
access_grievance_redressal_group_officer, access.grievance.redressal.group.officer, model_grievance.redressal, group_officer 1,0,0,0
if i've tried to add ACL for newly created model(grievance.redressal) in odoo. but is throws following error
File "/home/user/Projects/test/test-server/openerp/service/server.py", line 885, in preload_registries
registry = RegistryManager.new(dbname, update_module=update_module)
File "/home/user/Projects/test/test-server/openerp/modules/registry.py", line 385, in new
openerp.modules.load_modules(registry._db, force_demo, status, update_module)
File "/home/user/Projects/test/test-server/openerp/modules/loading.py", line 333, in load_modules
force, status, report, loaded_modules, update_module)
File "/home/user/Projects/test/test-server/openerp/modules/loading.py", line 237, in load_marked_modules
loaded, processed = load_module_graph(cr, graph, progressdict, report=report, skip_modules=loaded_modules, perform_checks=perform_checks)
File "/home/user/Projects/test/test-server/openerp/modules/loading.py", line 156, in load_module_graph
_load_data(cr, module_name, idref, mode, kind='data')
File "/home/user/Projects/test/test-server/openerp/modules/loading.py", line 98, in _load_data
tools.convert_file(cr, module_name, filename, idref, mode, noupdate, kind, report)
File "/home/user/Projects/test/test-server/openerp/tools/convert.py", line 846, in convert_file
convert_csv_import(cr, module, pathname, fp.read(), idref, mode, noupdate)
File "/home/user/Projects/test/test-server/openerp/tools/convert.py", line 914, in convert_csv_import
raise Exception(_('Module loading %s failed: file %s could not be processed:\n %s') % (module, fname, warning_msg))
Exception: Module loading test failed: file test/security/ir.model.access.csv could not be processed:
Line 1 : model+AF8-id
csv file:
Seems to be an encoding problem with OpenOffice and csv files. You should save your file as UTF-8. For more information look here.
I have solved the issue. the problem is editing CSV in libreoffice is some time failed. when i edited CSV file in text editor is works fine. thanks
ACL i have added in csv using text editor as a editing tool:
access_grievance_redressal_group_student,access.grievance.redressal.group.student,model_grievance_redressal,group_student,1,0,0,0

Odoo security guides and tutorials [duplicate]

I have developed a custom Module in OpenERP 7, My administrator user can only see this module.
1-How can I give access to normal users to my custom modules?
2-What are the steps to solve this problem.
Please give a detailed example.
Create a one Security folder which has below two files. For example,
test_security.xml and
ir.model.access.csv
security/test_security.xml file
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data noupdate="0">
<record model="ir.module.category" id="module_category_name_test">
<field name="name">Management</field>
<field name="sequence">7</field>
</record>
<record id="group_name_test_user" model="res.groups">
<field name="name">User</field>
<field name="category_id" ref="module_category_name_test"/>
<field name="implied_ids" eval="[(4, ref('base.group_user'))]"/>
</record>
<record id="group_name_test_manager" model="res.groups">
<field name="name">Manager</field>
<field name="category_id" ref="module_category_name_test"/>
<field name="implied_ids" eval="[(4, ref('group_name_test_user'))]"/>
<field name="users" eval="[(4, ref('base.user_root'))]"/>
</record>
</data>
</openerp>
After do this Management Option show with two selection value like User and Manager in setting => Users => Access Rights => Application
Now turn for security/ir.model.access.csv
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
unique_id, test.name, model_test_name, group_name_test_user, 1,1,0,0
unique_id, test.name, model_test_name, group_name_test_manager, 1,1,1,1
test.name is a table name.
Example of csv file, how to create? Where
Fields => Value => Description
id => access_testing_for_user => id must be unique.
name => testing.for.user => name is given as we want.
model_id:id => model_test_name => model_id:id is given like model_our_class_name.
group_id:id => group_name_test_user => group_id:id is xml id of above we create like for User and Manager.
perm_read => 1 for True and 0 for False for read record.
perm_write => 1 for True and 0 for False for write record.
perm_create => 1 for True and 0 for False for create record.
perm_unlink => 1 for True and 0 for False for delete record.
NOTE
These two files .xml and .csv must be listed in __openerp__.py as other view files are given.

Can not customize hr module in openerp by adding additional fields

I was trying to add a extra field in hr module i.e in hr.employee object by inheritance but when I'm adding that field ,in Hr module employee form my given field is not displayed .So pls help. All I want to do is create another seperate module so whenever that module is installed then that column should appear.(my field jdate should appear after coach_id field)
class joining_date(osv.osv):
_name="joining.date"
_inherit = "hr.employee"
_columns={
'jdate':fields.date('Joining date'),
}
joining_date()
xml part:
<?xml version="1.0" encoding="UTF-8"?>
<openerp>
<data>
<record id="view_join_date" model="ir.ui.view">
<field name="name">Join_date</field>
<field name="model">joining.date</field>
<field name="inherit_id" ref="hr.view_employee_form"/>
<field name="arch" type="xml">
<data>
<xpath expr="//form/sheet/notebook/page/group[1]/group[2][#name='coach_id']" position="after">
<field name="jdate"/>
</xpath>
</data>
</field>
</record>
openerp file:
{
'name': 'HR join date',
'version': '1.0',
'category': 'Tools',
'description': """ To add extra join date field""",
'author': 'Greywind',
'website': 'http://www.greywind.com',
'depends': ['hr','base', 'account_accountant'],
'data': [
'joindate_view.xml'],
'demo': [],
'installable': True,
'auto_install': False,
}
I think your XML should look like this:
<record id="view_join_date" model="ir.ui.view">
<field name="name">Join_date</field>
<field name="model">joining.date</field>
<field name="inherit_id" ref="hr.view_employee_form"/>
<field name="arch" type="xml">
<field name="coach_id" position="after">
<field name="jdate"/>
</field>
</field>
</record>
Try to -name and -inherits field as the same id. if its so you can add your field in to the inherited module.
Then ref=base module view idand also if you want all the fields of your base module to your new module then you just change ref = **base module view id . new module view id you should create the view for the new module with all the fields you needed from base & new field.
You should refer MrEthan Furman xml code.

OpenERP 7 How to give users access to custom module in OpenERP 7?

I have developed a custom Module in OpenERP 7, My administrator user can only see this module.
1-How can I give access to normal users to my custom modules?
2-What are the steps to solve this problem.
Please give a detailed example.
Create a one Security folder which has below two files. For example,
test_security.xml and
ir.model.access.csv
security/test_security.xml file
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data noupdate="0">
<record model="ir.module.category" id="module_category_name_test">
<field name="name">Management</field>
<field name="sequence">7</field>
</record>
<record id="group_name_test_user" model="res.groups">
<field name="name">User</field>
<field name="category_id" ref="module_category_name_test"/>
<field name="implied_ids" eval="[(4, ref('base.group_user'))]"/>
</record>
<record id="group_name_test_manager" model="res.groups">
<field name="name">Manager</field>
<field name="category_id" ref="module_category_name_test"/>
<field name="implied_ids" eval="[(4, ref('group_name_test_user'))]"/>
<field name="users" eval="[(4, ref('base.user_root'))]"/>
</record>
</data>
</openerp>
After do this Management Option show with two selection value like User and Manager in setting => Users => Access Rights => Application
Now turn for security/ir.model.access.csv
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
unique_id, test.name, model_test_name, group_name_test_user, 1,1,0,0
unique_id, test.name, model_test_name, group_name_test_manager, 1,1,1,1
test.name is a table name.
Example of csv file, how to create? Where
Fields => Value => Description
id => access_testing_for_user => id must be unique.
name => testing.for.user => name is given as we want.
model_id:id => model_test_name => model_id:id is given like model_our_class_name.
group_id:id => group_name_test_user => group_id:id is xml id of above we create like for User and Manager.
perm_read => 1 for True and 0 for False for read record.
perm_write => 1 for True and 0 for False for write record.
perm_create => 1 for True and 0 for False for create record.
perm_unlink => 1 for True and 0 for False for delete record.
NOTE
These two files .xml and .csv must be listed in __openerp__.py as other view files are given.

Python Debugger out of sync with code

I am in the process of debugging something in OpenERP using Python 2.7.3. The debugger seems to get out of sync with the code when stepping through with the Next (n) command. See Code and output below. I have the same problem with Python 2.6.5. I have never experienced this before using Python pdb.
I believe the problem may be related to the way OpenERP calls my method through a Python exec() statement by reading the code field in the OpenERP XML below. Is possible that calling Python code constructed dynamically and called via exec() is confusing the pdb debugger?
If this is the case is there a work around?
CODE called via this OpenERP action below:
<record id="action_wash_st_method1" model="ir.actions.server">
<field name="type">ir.actions.server</field>
<field name="condition">True</field>
<field name="state">code</field>
<field name="model_id" ref="model_view_tree_display_address_list"/>
<field eval="5" name="sequence"/>
<field name="code">
action = self.view_calc_sales_tax(cr, uid, context)
</field>
<field name="name">wash state action request</field>
</record>
<record model="ir.values" id="action_wash_st_tax_trigger_method1" >
<field name="key2" eval="'tree_but_open'" />
<field name="model" eval="'view.tree.display.address.list'" />
<field name="name">Method1 Wash State</field>
<field name="value" eval="'ir.actions.server,%d'%action_wash_st_method1"/>
<field name="object" eval="True" />
</record>