I have a task in odoo 8, i have to create a user group named ( picker ) which will be in inheritance to warehouse user group. as Warehouse Manager -> User --> test. so i created the user as follows :
<record id="warehouse_picker" model="res.groups">
<field name="name">picker </field>
<field name="category_id" ref="base.module_category_warehouse_management"/>
<field name="implied_ids" eval="[(4, ref('base.group_user'))]" />
</record>
also i have added this code to give access of menu warehouse to this user :
<record id="stock.group_stock_user" model="res.groups">
<field name="implied_ids" eval="[(4, ref('warehouse_picker')),(4, ref('stock.group_locations'))]"/>
</record>
Now, The Group Warehouse / User has access rule to an object (stock.picking) as 1,1,1,1. I need to restrict / Override this rule (stock.picking) to 1,0,0,0
I tried following code, but doesn't work :
<record id="warehouse_picker_rule" model="ir.rule">
<field name="name">Warehouse Picker Rule</field>
<field name="model_id" ref="stock.model_stock_picking"/>
<field name="domain_force">[(1, '=', 1)]</field>
<field name="groups" eval="[(4, ref('warehouse_picker'))]"/>
<field name="perm_read" eval="False"/>
<field name="perm_write" eval="False"/>
<field name="perm_create" eval="False"/>
<field name="perm_unlink" eval="True"/>
</record>
Can someone help me to solve / override the existing rule. i don't want to touch the core module rules.
Thanks,
Check out from which module this rule is coming from and then you can override like:
<record id="module.rule_id" model="ir.model.access">
<field name="perm_read" eval="True"/>
<field name="perm_write" eval="False"/>
<field name="perm_create" eval="False"/>
<field name="perm_unlink" eval="False"/>
</record>
For example, module is stock and rule_id (you can find this with debug mode in the GUI or look into the modules ir.model.access.csv first column) is move_read_all:
<record id="stock.move_read_all" model="ir.model.access">
<field name="perm_read" eval="True"/>
<field name="perm_write" eval="False"/>
<field name="perm_create" eval="False"/>
<field name="perm_unlink" eval="False"/>
</record>
If i understand your wish correct, then you have to override it the following way:
<record id="stock.access_stock_picking_user" model="ir.model.access">
<field name="perm_read" eval="True"/>
<field name="perm_write" eval="False"/>
<field name="perm_create" eval="False"/>
<field name="perm_unlink" eval="False"/>
</record>
You will need to put the dependency to stock into your manifest file of your custom module.
Do one thing, create one csv file named "ir.model.access.csv" and into that create one record.
This csv file must contain following columns.
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_id,access_name,model_stock_picking,group_name_external_id,1,0,0,0
And add this to the openerp.py file, so it will set this access rights for the particular model to particular group. And suppose you want to set this permissions for all then just leave blank "group_id" fields then it will set this default permission for all users.
Related
I am creating a custom module in Odoo for a faculty and y need to create 3 roles (groups): students, professors and admins. An user cannot have 2 roles at the same time, so it could only be either a teacher, a professor or an admin. I have defined the permisions in the following code. But for selecting those permissions, Odoo creates a view with checkboxes, where you can chose 2 or more roles at the same time, instead of a selection field (dropdown), I dont want that. How can I force Odoo to create a dropdown for the selection of those roles
]
<record model="ir.module.category" id="module_category_faculty">
<field name="name">Faculty</field>
<field name="description">Faculty Roles</field>
<field name="sequence">45</field>
</record>
<record id="group_faculty_student" model="res.groups">
<field name="name">Student</field>
<field name="category_id" ref="module_category_faculty"/>
</record>
<record id="group_faculty_professor" model="res.groups">
<field name="name">Professor</field>
<field name="category_id" ref="module_category_faculty"/>
</record>
<record id="group_faculty_admin" model="res.groups">
<field name="name">Admin</field>
<field name="category_id" ref="module_category_faculty"/>
</record>
<record id="group_faculty_student" model="res.groups">
<field name="name">Student</field>
<field name="category_id" ref="module_category_faculty"/>
<field name="implied_ids" eval="[(4, ref('base.group_user'))]"/>
</record>
<record id="group_faculty_professor" model="res.groups">
<field name="name">Professor</field>
<field name="category_id" ref="module_category_faculty"/>
<field name="implied_ids" eval="[(4, ref('group_faculty_student'))]"/>
</record>
<record id="group_faculty_admin" model="res.groups">
<field name="name">Administrator</field>
<field name="category_id" ref="module_category_faculty"/>
<field name="implied_ids" eval="[(4, ref('group_faculty_professor'))]"/>
<field name="users" eval="[(4, ref('base.user_root')), (4, ref('base.user_admin'))]"/>
</record>
But in that case all Professors also have Stundent group.
I want to hide the edit and create button on the form view for a specific user I use this code but the button not showing at all
i just want to hide buttons just for only group
<record model="ir.ui.view" id="edit_button_message_">
<field name="name">edit.button.message.1</field>
<field name="model">person.message</field>
<field name="inherit_id" ref="view_parent_message_form"/>
<field name="groups_id" eval="[(6,0,[ref('person_access')])]"/>
<field name="arch" type="xml">
<xpath expr="/form[#string='form_view_string']" position="attributes">
<attribute name="create">false</attribute>
<attribute name="edit">false</attribute>
</xpath>
</field>
</record>
and i use this
<form string="form_view_string" edit="false" create="false" >
nothing happened , I use odoo v8
You better create a security access for that group to allow just read to that model, preventing the create, write and unlink actions and those buttons should disappear.
You could create it in xml as it will be only one, like:
<record id="person_message_access" model="ir.model.access">
<field name="name">edit.button.message.access</field>
<field name="model_id" ref="person.message"/>
<field name="group_id" ref="person_access"/>
<field name="perm_read" eval="1"/>
<field name="perm_create" eval="0"/>
<field name="perm_write" eval="0"/>
<field name="perm_unlink" eval="0"/>
</record>
or you could set it into a field ir.model.access.csv with content like:
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
person_message_access,edit.button.message.access,model_person_message,person_access,1,0,0,0
I have made some groups A,B,C,D through GUI in Odoo v10. These groups are shown as check-boxes on the user page.
I want that instead of these check-boxes a dropdown must be shown so that user can be assigned to only a single group i.e. a user can only be in one of the A,B,C,D groups.
How can i do this??
I've found something that will clear how drop-downs are made and how check boxes are made. This is through code not from GUI as i am still finding a solution for it.
So, drop-downs are made when each group in a category inherits some other group in same category in hierarchical manner.
So, when i wrote the following code, check-boxes were made.
<record id='group_category' model='ir.module.category'>
<field name='name'>Category name</field>
</record>
<record id="group_a" model="res.groups">
<field name="name">A</field>
<field name="category_id" ref="group_category"/>
</record>
<record id="group_b" model="res.groups">
<field name="name">B</field>
<field name="category_id" ref="group_category"/>
</record>
<record id="group_c" model="res.groups">
<field name="name">C</field>
<field name="category_id" ref="group_category"/>
</record>
But when i wrote the following code in which one group inherits the other in a hierarchical way, drop-down was made
<record id='group_category' model='ir.module.category'>
<field name='name'>Category name</field>
</record>
<record id="group_a" model="res.groups">
<field name="name">A</field>
<field name="category_id" ref="group_category"/>
</record>
<record id="group_b" model="res.groups">
<field name="name">B</field>
<field name="category_id" ref="group_category"/>
<field name="implied_ids" eval="[(4, ref('module_name.group_a'))]"/>
</record>
<record id="group_c" model="res.groups">
<field name="name">C</field>
<field name="category_id" ref="group_category"/>
<field name="implied_ids" eval="[(4, ref('module_name.group_b'))]"/>
</record>
so, this was the case when i did it. Still finding a way to do it through GUI.
First Create this below record through xml.
<record model="ir.module.category" id="abcd_category">
<field name="name">ABCD</field>
</record>
Then Create your groups with category_id.
<record id="group_a" model="res.groups">
<field name="name">A</field>
<field name="category_id" ref="abcd_category"/>
</record>
<record id="group_b" model="res.groups">
<field name="name">B</field>
<field name="category_id" ref="abcd_category"/>
</record>
......
......
Thats it.
Updates :
Add category in manifest.py
....
....
'category':'ABCD',
....
....
and select it from view into the Application in group formview.
You can override the view and specify a widget. You could try:
<field name="field_name" widget="selection"/>
or
<field name="field_name" widget="many2one"/>
I hope this help you!
I extended "hr.employee" class. (Inherited and gave the same name to the new one).
I defined two views (tree and form) and a menu:
<record model="ir.ui.view" id="my_employee_tree">
<field name="name">hr.employee.tree</field>
<field name="model">hr.employee</field>
<field name="arch" type="xml">
...
</field>
</record>
<record id="view_my_hr_employee_form" model="ir.ui.view">
<field name="name">hr.employee.form</field>
<field name="model">hr.employee</field>
<field name="arch" type="xml">
...
</field>
</record>
<record model="ir.actions.act_window" id="action_my_hr_employee_seq">
<field name="name">Angajati</field>
<field name="res_model">hr.employee</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="view_my_hr_employee_form"/>
</record>
<menuitem id="menu_project_hr_base" parent="menu_project_utcn_project_base_main" name="HR"/>
<menuitem action="action_my_hr_employee_seq" id="menu_action_employee_form" name ="Angajati" parent="menu_project_hr_base"/>
What I want to do is to get the original views from hr.employee view when i use the original module, and to get my defined views when i use my module.
As you can see, I have specified "view_id" reference to my form view, but how can i define a reference also to my tree view? And I want the tree view to be shown first, and form view as alternative. How can i specify this?
<field name="view_mode">tree,form</field>
seems not to work if i add reference to form view
You have to map your action with particular tree,form view.
Try this:
<record model="ir.actions.act_window" id="action_my_hr_employee_seq">
<field name="name">Angajati</field>
<field name="res_model">hr.employee</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
</record>
<record model="ir.actions.act_window.view" id="act_hr_employee_tree_view">
<field eval="1" name="sequence"/>
<field name="view_mode">tree</field>
<field name="view_id" ref="your_tree_view_id"/>
<field name="act_window_id" ref="action_my_hr_employee_seq"/>
</record>
<record model="ir.actions.act_window.view" id="act_hr_employee_form_view">
<field eval="2" name="sequence"/>
<field name="view_mode">form</field>
<field name="view_id" ref="your_form_view_id"/>
<field name="act_window_id" ref="action_my_hr_employee_seq"/>
</record>
I have created a new module in openerp which contain consumption details related to each project.
I have created two user groups for my module (user,manager).User can create consumption details of project and he can see only consumption details which he has created.
I give the permission like this
<record id="property_rule_mat_mgmt_user" model="ir.rule">
<field name="name">Material Manage Rule</field>
<field model="ir.model" name="model_id" ref="model_mat_mgmt"/>
<field name="domain_force">[('create_uid','=',user.id)]</field>
</record>
It is working fine
Similarly if I assign a user as manager of my module he can see all consumption details of projects,in which he is member or manager.How to write the rule, I tried different ways but can't find a proper rule.
This is one of the rule I have tried
<record id="property_rule_mat_mgmt_manager" model="ir.rule">
<field name="name">Material Manage manager Rule</field>
<field model="ir.model" name="model_id" ref="project.model_project_project"/>
<field name="domain_force">['|',('user_id','=',False),('user_id','=',user.id)]</field>
</record>
For the record, it would have been be easier to answer if you could give the details of your model, specifically the mat.mgmt one. Perhaps that's why there was no answer yet.
Let's say you have a many2one relationship between mat.mgmt and project.project named project_id, you could then use something like this:
<record id="property_rule_mat_mgmt_manager" model="ir.rule">
<field name="name">Material Manage manager Rule</field>
<field model="ir.model" name="model_id" ref="model_mat_mgmt"/>
<field name="domain_force">['|',('project_id.user_id','=',False),('project_id.user_id','=',user.id)]</field>
</record>
Notice that the model is still model_mat_mgmt as this is the model on which the filtering is applied. You didn't want to filter projects but mat.mgmt if I understand correctly your question.
<record id="user_record_rule_id" model="ir.rule">
<field name="name">Record Rule Name</field>
<field model="ir.model" name="model_id" ref="model_my_model_name"/>
<field name="domain_force">[('create_uid', '=', user.id)]</field>
<field name="perm_read" eval="True"/>
<field name="perm_write" eval="True"/>
<field name="perm_create" eval="True"/>
<field name="perm_unlink" eval="True"/>
<field name="groups" eval="[(4,ref('group_user'))]"/>
</record>
<record id="manager_record_rule_id" model="ir.rule">
<field name="name">Record Rule Name</field>
<field model="ir.model" name="model_id" ref="model_my_model_name"/>
<field name="domain_force">[]</field>
<field name="perm_read" eval="True"/>
<field name="perm_write" eval="True"/>
<field name="perm_create" eval="True"/>
<field name="perm_unlink" eval="True"/>
<field name="groups" eval="[(4,ref('group_manager'))]"/>
</record>
Try above code:
manager group should be inherited from user group
example:
<record id="group_user" model="res.groups">
<field name="name">User</field>
<field name="category_id" ref="module_category_name"/>
</record>
<record id="group_manager" model="res.groups">
<field name="name">Manager</field>
<field name="implied_ids" eval="[(4, ref('group_user'))]"/>
<field name="category_id" ref="module_exit_category"/>
<field name="users" eval="[(4, ref('base.user_root'))]"/>
</record>
Explanation:
User can create the record(s) as well as can view his record(s) only
but manager can see all the user's record(s) as well as he can create & view his own record(s)