-
-
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][IMP] mail_activity_team: add team fields on mail.activity.sche…
…dule
- Loading branch information
ilo
committed
Oct 9, 2024
1 parent
54d7daa
commit 480e3d6
Showing
8 changed files
with
86 additions
and
17 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
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,28 @@ | ||
# Copyright 2024 Camptocamp | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
from odoo import fields, models | ||
|
||
|
||
class MailActivitySchedule(models.TransientModel): | ||
_inherit = "mail.activity.schedule" | ||
|
||
def _get_default_team_id(self, user_id=None): | ||
if not user_id: | ||
user_id = self.env.uid | ||
res_model = self.env.context.get("default_res_model") | ||
model = self.sudo().env["ir.model"].search([("model", "=", res_model)], limit=1) | ||
domain = [("member_ids", "in", [user_id])] | ||
if res_model: | ||
domain.extend( | ||
["|", ("res_model_ids", "=", False), ("res_model_ids", "in", model.ids)] | ||
) | ||
return self.env["mail.activity.team"].search(domain, limit=1) | ||
|
||
team_user_id = fields.Many2one( | ||
string="Team user", related="activity_user_id", readonly=False | ||
) | ||
|
||
team_id = fields.Many2one( | ||
comodel_name="mail.activity.team", default=lambda s: s._get_default_team_id() | ||
) |
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,28 @@ | ||
<?xml version="1.0" ?> | ||
<odoo> | ||
|
||
<record id="mail_activity_schedule_view_form" model="ir.ui.view"> | ||
<field name="name">mail.activity.view.form.popup</field> | ||
<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">team_id</attribute> | ||
</field> | ||
<field name="activity_user_id" position="after"> | ||
<field name="res_model_id" invisible="1" /> | ||
<field | ||
name="team_user_id" | ||
invisible="not team_id" | ||
domain="[('activity_team_ids', '=', team_id)]" | ||
/> | ||
<field | ||
name="team_id" | ||
options="{'no_create': True, 'no_open': True}" | ||
domain="['|', ('res_model_ids', '=', False), ('res_model_ids', '=', res_model_id)]" | ||
/> | ||
</field> | ||
</field> | ||
</record> | ||
|
||
</odoo> |