-
-
Notifications
You must be signed in to change notification settings - Fork 612
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[17.0][REF] mail_activity_team: use mail.activity.schedule wizard
- Loading branch information
Showing
11 changed files
with
174 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
from . import models | ||
from . import wizard |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<templates xml:space="preserve"> | ||
|
||
<t | ||
t-name="mail_activity_team.Activity" | ||
t-inherit="mail.Activity" | ||
t-inherit-mode="extension" | ||
> | ||
<xpath | ||
expr="//div/div[hasclass('o-mail-Activity-sidebar')]/img" | ||
position="attributes" | ||
> | ||
<attribute name="t-if">activity.user_id</attribute> | ||
</xpath> | ||
<xpath | ||
expr="//div/div/div[hasclass('o-mail-Activity-info')]/span[hasclass('o-mail-Activity-user')]" | ||
position="attributes" | ||
> | ||
<attribute name="t-if">activity.user_id</attribute> | ||
</xpath> | ||
|
||
</t> | ||
|
||
</templates> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import mail_activity_schedule |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
# Copyright 2024 Camptocamp SA | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
from odoo import api, fields, models | ||
|
||
|
||
class MailActivitySchedule(models.TransientModel): | ||
_inherit = "mail.activity.schedule" | ||
|
||
activity_team_user_id = fields.Many2one( | ||
string="Team user", related="activity_user_id", store=True, readonly=False | ||
) | ||
activity_team_id = fields.Many2one( | ||
"mail.activity.team", | ||
"Team assigned to", | ||
compute="_compute_activity_team_id", | ||
store=True, | ||
readonly=False, | ||
) | ||
|
||
@api.depends("activity_type_id") | ||
def _compute_activity_team_id(self): | ||
for scheduler in self: | ||
if scheduler.activity_type_id.default_team_id: | ||
scheduler.activity_team_id = scheduler.activity_type_id.default_team_id | ||
elif not scheduler.activity_team_id: | ||
scheduler.activity_team_id = ( | ||
self.env["mail.activity"] | ||
.with_context(default_res_model=self.sudo().res_model_id.model) | ||
._get_default_team_id(user_id=scheduler.activity_team_user_id.id) | ||
) | ||
|
||
@api.onchange("activity_team_id") | ||
def _onchange_activity_team_id(self): | ||
if ( | ||
self.activity_team_id | ||
and self.activity_team_user_id not in self.activity_team_id.member_ids | ||
): | ||
if self.activity_team_id.user_id: | ||
new_user_id = self.activity_team_id.user_id | ||
elif len(self.activity_team_id.member_ids) == 1: | ||
new_user_id = self.activity_team_id.member_ids | ||
else: | ||
new_user_id = self.env["res.users"] | ||
self.activity_team_user_id = new_user_id | ||
self.activity_user_id = new_user_id | ||
|
||
@api.onchange("activity_team_user_id") | ||
def _onchange_activity_team_user_id(self): | ||
if not self.activity_team_user_id or ( | ||
self.activity_team_user_id | ||
and self.activity_team_user_id in self.activity_team_id.member_ids | ||
): | ||
return | ||
self.activity_team_id = ( | ||
self.env["mail.activity"] | ||
.with_context(default_res_model=self.sudo().res_model_id.model) | ||
._get_default_team_id(user_id=self.activity_team_user_id.id) | ||
) | ||
|
||
def _action_schedule_activities(self): | ||
return self._get_applied_on_records().activity_schedule( | ||
activity_type_id=self.activity_type_id.id, | ||
automated=False, | ||
summary=self.summary, | ||
note=self.note, | ||
user_id=self.activity_team_user_id.id, | ||
team_user_id=self.activity_team_user_id.id, | ||
team_id=self.activity_team_id.id, | ||
date_deadline=self.date_deadline, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<odoo> | ||
|
||
<record id="mail_activity_schedule_view_form" model="ir.ui.view"> | ||
<field name="model">mail.activity.schedule</field> | ||
<field name="inherit_id" ref="mail.mail_activity_schedule_view_form" /> | ||
<field name="arch" type="xml"> | ||
<field name="activity_user_id" position="attributes"> | ||
<attribute name="invisible">activity_team_id</attribute> | ||
<attribute | ||
name="required" | ||
add="and not activity_team_id" | ||
separator=" " | ||
/> | ||
</field> | ||
<field name="activity_user_id" position="after"> | ||
<field name="res_model_id" invisible="1" /> | ||
<field | ||
name="activity_team_user_id" | ||
invisible="not activity_team_id" | ||
domain="[('activity_team_ids', '=', activity_team_id)]" | ||
/> | ||
<field | ||
name="activity_team_id" | ||
options="{'no_create': True, 'no_open': True}" | ||
domain="['|', ('res_model_ids', '=', False), ('res_model_ids', '=', res_model_id)]" | ||
/> | ||
</field> | ||
</field> | ||
</record> | ||
|
||
</odoo> |