Hi,
I need to acess different task stages for different users group.
I need to hide some task stages for some groups.
Thank you.
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
Hi,
I need to acess different task stages for different users group.
I need to hide some task stages for some groups.
Thank you.
Yes, it is possible using groups and rules.
To prove that I applied the following code on my budget module 'budget_expense' . I needed some users to see only the 'draft' budget, others to see the 'confirm' ones, I wrote the following groups and rules.
this is the category:
<record model="ir.module.category" id="module_category_special">
<field name="name">Budget Miscelenious</field>
<field name="description">Budget Miscelenious</field>
<field name="sequence">26</field>
</record>
following are two groups
<record id="group_test01" model="res.groups">
<field name="name">Show only 'Draft'</field>
<field name="category_id" ref="budget_expense.module_category_special"/>
field name="users" eval="[(4, ref('base.user_root'))]"/>
</record>
<record id="group_test02" model="res.groups">
<field name="name">Show only 'confirmed'</field>
<field name="category_id" ref="budget_expense.module_category_special"/>
<field name="users" eval="[(4, ref('base.user_root'))]"/>
</record>
following are two rules, a rule for each group
<record model="ir.rule" id="apply_rule_on_draft">
<field name="name">test01</field>
<field name="model_id" ref="budget_expense.model_budget_expense"/>
<field name="domain_force">
[('state','=','draft')]
</field>
<field name="groups" eval="[(4, ref('budget_expense.group_test01'))]"/> <field name="perm_read" eval="True"/>
<field name="perm_write" eval="True"/>
<field name="perm_unlink" eval="True"/>
<field name="perm_create" eval="True"/>
</record>
<record model="ir.rule" id="apply_rule_on_confirm">
<field name="name">test02</field>
<field name="model_id" ref="budget_expense.model_budget_expense"/>
<field name="domain_force">
[('state','=','confirm')]
</field>
<field name="groups" eval="[(4, ref('budget_expense.group_test02'))]"/> <field name="perm_read" eval="True"/>
<field name="perm_write" eval="True"/>
<field name="perm_unlink" eval="True"/>
<field name="perm_create" eval="True"/>
</record>
If you need a user to see only the 'draft' status, assign him to the group 'group_test01'
If you need a user to see only the 'confirm' status, assign him to the group 'group_test02'
if you need him to see both states, assign him to both groups
I explained the idea on my code that I tested it and already got result from it, you can imitate exactly the same idea on your case
# use this def in project.task.type
# Be sure that stage name must be = 'Done'
def search(self, args, offset=0, limit=None, order=None, count=False):
# Define the domain to filter task stages based on user groups
domain = []
domain_c = []
# Example: If the user is in 'Group A', show 'Stage 1'
if not self.env.user.has_group('module name.group name'):
domain_c = [('field name', '!=', stage name)]
args = args + domain + domain_c
return super(your class name, self).search(args, offset, limit, order, count=count)
this will hide the record from tree and form
Maak vandaag nog een account aan om te profiteren van exclusieve functies en deel uit te maken van onze geweldige community!
Aanmelden