Good morning, sir,
I've been on the odoo adventure for a few months now and I'm facing my first problem for which I can't find any documentation on the internet. Maybe I didn't look hard enough?
Let me explain... I created a custom module for the management of intervention in my company. I'm doing quite well and I can do almost anything I want. Now I would like to be able to display interventions on a "calendar view". It also works for my views, but when I assign it to another user (like res.partner or res.user) I don't know how to assign it on his calendar. I tried to change the create_uid variable (I figured the user information was here) but it's read-only.
I'm going to have the same problem for a "todo_task" module that I'd like to create as a memo that I have to do and be able to assign it to another user if I don't have time to do it.
It's not a problem for me if I lose the information of the person who created the event.
A savior among you?
Thank you in advance
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Accounting
- Inventory
- PoS
- Project management
- MRP
This question has been flagged
Dear Damien,
I will try to explain several points at once hopefully that will be helpful for you.
1- The filed create_uid contains the user that has created the record (Intervention in your case). In a normal workflow, this can be different from the assigned user. The field create_uid is a read-only field because its always filled automatically by the odoo environment by getting the actual user who is creating the record (Intervention in your case). This field is on any model (table) of odoo.
2- To achieve your need you have to create a new field on your model "Intervention".
a- Field type: Many2one
b- co-model: res.users
Example:
assigned_user_id = fields.Many2one('res.users', 'Assigned User')
# You may want to add the current user as a default value of this field.
# To do that: fields.Many2one('res.users', 'Assigned User', default=lambda: self.env.user)
- Then create two security groups: Intervention Manager & Intervention User
Example:
<record id="group_intervention_user" model="res.groups">
<field name="name">Intervention user.</field>
<field name="category_id" ref="module_intervention"/>
<field name="implied_ids" eval="[(4, ref('base.group_user'))]"/>
</record>
<record id="group_intervention_manager" model="res.groups">
<field name="name">Intervention manager.</field>
<field name="category_id" ref="module_intervention"/>
<field name="implied_ids" eval="[(4, ref('group_intervention_user'))]"/>
</record>
<!--You may also need to define the CSV access rights for each group on another file '.csv'-->
- Create a security rule on the Intervention User group that allows each user of this group to see only his assigned Intervention. The Manager can always see all the interventions.
Example:
<record model="ir.rule" id="intervention_assign_rule">
<field name="name">Intervention Assign Rule</field>
<field name="model_id" ref="model_<The name of your model by replacing each '.' By '_'>"/>
<field name="groups" eval="[(4, ref('group_intervention_user'))]"/>
<field name="domain_force">[('assigned_user_id', '=', user.id])]</field>
</record>
I hope that's will be helpful for you.
Good luck.
Enjoying the discussion? Don't just read, join in!
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign up