Hi,
I have to assign schedule activity to multiple users. Do anyone have a better solution by adding a new field inside the schedule activity screen and so the rest work as like the default functioning of odoo.
Thank you.
Odoo is the world's easiest all-in-one management software.
 It includes hundreds of business apps:
Hi,
I have to assign schedule activity to multiple users. Do anyone have a better solution by adding a new field inside the schedule activity screen and so the rest work as like the default functioning of odoo.
Thank you.
Hi, 
We can add a many2many field inside mail.activity 
class MailActivity(models.Model):
_inherit = 'mail.activity'
multiple_users = fields.Many2many('res.users', store=True)
#Add this function inside
@api.model
def create(self, vals):
assigned_user_id = vals['user_id']
assigned_user_name = self.env['res.users'].browse(vals['user_id']).name
vals['display_names'] = assigned_user_name
res = super(MailActivity, self).create(vals)
if 'multiple_users' in vals and vals['multiple_users']:
related_user_ids = self.env['res.users'].search([('id', 'in', vals['multiple_users'][0][2])], order='id')
for each in related_user_ids:
if each.name != assigned_user_name:
vals['user_id'] = each.id
vals['display_names'] = each.name
res = super(MailActivity, self).create(vals)
return res
And add that to the view.
<record id="mail_activity_view_form_popup_inherit" model="ir.ui.view">
<field name="name">mail.activity.form.inherit.calendar</field>
<field name="model">mail.activity</field>
<field name="inherit_id" ref="mail.mail_activity_view_form_popup"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='user_id']" position="after">
<field name="multiple_users" widget="many2many_tags" string="Additional Assignees"/>
</xpath>
</field>
</record>
So here we can add separate activity for each users we select in the multiple_users field.
Regards
Stwórz konto dzisiaj, aby cieszyć się ekskluzywnymi funkcjami i wchodzić w interakcje z naszą wspaniałą społecznością!
Zarejestruj się| Powiązane posty | Odpowiedzi | Widoki | Czynność | |
|---|---|---|---|---|
|  | 0 sty 21  | 3061 | ||
|  | 2 mar 24  | 8493 | ||
|  | 0 lip 21  | 2778 | ||
| 
            
                Many2one field update based on condition
            
            
                    Rozwiązane
            
         |  | 3 paź 20  | 5981 | |
|  | 3 sie 20  | 5366 |