[IMP] mail_activity_team: black, isort
This commit is contained in:
parent
f2c27cdb33
commit
108a4e722f
@ -1,23 +1,21 @@
|
|||||||
# Copyright 2018 Eficent Business and IT Consulting Services, S.L.
|
# Copyright 2018 Eficent Business and IT Consulting Services, S.L.
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||||
{
|
{
|
||||||
'name': 'Mail Activity Team',
|
"name": "Mail Activity Team",
|
||||||
'summary': 'Add Teams to Activities',
|
"summary": "Add Teams to Activities",
|
||||||
'version': '12.0.1.0.0',
|
"version": "13.0.1.0.0",
|
||||||
'development_status': 'Beta',
|
"development_status": "Beta",
|
||||||
'category': 'Social Network',
|
"category": "Social Network",
|
||||||
'website': 'https://github.com/OCA/social',
|
"website": "https://github.com/OCA/social",
|
||||||
'author': 'Eficent, Odoo Community Association (OCA)',
|
"author": "Eficent, Odoo Community Association (OCA)",
|
||||||
'license': 'AGPL-3',
|
"license": "AGPL-3",
|
||||||
'installable': True,
|
"installable": True,
|
||||||
'depends': [
|
"depends": ["mail_activity_board"],
|
||||||
'mail_activity_board',
|
"data": [
|
||||||
],
|
"security/ir.model.access.csv",
|
||||||
'data': [
|
"security/mail_activity_team_security.xml",
|
||||||
'security/ir.model.access.csv',
|
"views/mail_activity_team_views.xml",
|
||||||
'security/mail_activity_team_security.xml',
|
"views/mail_activity_views.xml",
|
||||||
'views/mail_activity_team_views.xml',
|
"views/res_users_views.xml",
|
||||||
'views/mail_activity_views.xml',
|
|
||||||
'views/res_users_views.xml',
|
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
# Copyright 2018 Eficent Business and IT Consulting Services, S.L.
|
# Copyright 2018 Eficent Business and IT Consulting Services, S.L.
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||||
from odoo import api, models, fields, _, SUPERUSER_ID
|
from odoo import SUPERUSER_ID, _, api, fields, models
|
||||||
from odoo.exceptions import ValidationError
|
from odoo.exceptions import ValidationError
|
||||||
|
|
||||||
|
|
||||||
@ -10,53 +10,52 @@ class MailActivity(models.Model):
|
|||||||
def _get_default_team_id(self, user_id=None):
|
def _get_default_team_id(self, user_id=None):
|
||||||
if not user_id:
|
if not user_id:
|
||||||
user_id = self.env.uid
|
user_id = self.env.uid
|
||||||
res_model = self.env.context.get('default_res_model')
|
res_model = self.env.context.get("default_res_model")
|
||||||
model = self.env['ir.model'].search(
|
model = self.env["ir.model"].search([("model", "=", res_model)], limit=1)
|
||||||
[('model', '=', res_model)], limit=1)
|
domain = [("member_ids", "in", [user_id])]
|
||||||
domain = [('member_ids', 'in', [user_id])]
|
|
||||||
if res_model:
|
if res_model:
|
||||||
domain.extend(['|', ('res_model_ids', '=', False),
|
domain.extend(
|
||||||
('res_model_ids', 'in', model.ids)])
|
["|", ("res_model_ids", "=", False), ("res_model_ids", "in", model.ids)]
|
||||||
return self.env['mail.activity.team'].search(domain, limit=1)
|
)
|
||||||
|
return self.env["mail.activity.team"].search(domain, limit=1)
|
||||||
|
|
||||||
team_id = fields.Many2one(
|
team_id = fields.Many2one(
|
||||||
comodel_name='mail.activity.team',
|
comodel_name="mail.activity.team", default=lambda s: s._get_default_team_id()
|
||||||
default=lambda s: s._get_default_team_id(),
|
|
||||||
)
|
)
|
||||||
|
|
||||||
@api.onchange('user_id')
|
@api.onchange("user_id")
|
||||||
def _onchange_user_id(self):
|
def _onchange_user_id(self):
|
||||||
res = {'domain': {'team_id': []}}
|
res = {"domain": {"team_id": []}}
|
||||||
if not self.user_id:
|
if not self.user_id:
|
||||||
return res
|
return res
|
||||||
res['domain']['team_id'] = [
|
res["domain"]["team_id"] = [
|
||||||
'|',
|
"|",
|
||||||
('res_model_ids', '=', False),
|
("res_model_ids", "=", False),
|
||||||
('res_model_ids', 'in', self.res_model_id.ids)]
|
("res_model_ids", "in", self.res_model_id.ids),
|
||||||
|
]
|
||||||
if self.team_id and self.user_id in self.team_id.member_ids:
|
if self.team_id and self.user_id in self.team_id.member_ids:
|
||||||
return res
|
return res
|
||||||
self.team_id = self.with_context(
|
self.team_id = self.with_context(
|
||||||
default_res_model=self.res_model_id.id).\
|
default_res_model=self.res_model_id.id
|
||||||
_get_default_team_id(user_id=self.user_id.id)
|
)._get_default_team_id(user_id=self.user_id.id)
|
||||||
return res
|
return res
|
||||||
|
|
||||||
@api.onchange('team_id')
|
@api.onchange("team_id")
|
||||||
def _onchange_team_id(self):
|
def _onchange_team_id(self):
|
||||||
res = {'domain': {'user_id': []}}
|
res = {"domain": {"user_id": []}}
|
||||||
if not self.team_id:
|
if not self.team_id:
|
||||||
return res
|
return res
|
||||||
res['domain']['user_id'] = [('id', 'in', self.team_id.member_ids.ids)]
|
res["domain"]["user_id"] = [("id", "in", self.team_id.member_ids.ids)]
|
||||||
if self.user_id not in self.team_id.member_ids:
|
if self.user_id not in self.team_id.member_ids:
|
||||||
if self.team_id.user_id:
|
if self.team_id.user_id:
|
||||||
self.user_id = self.team_id.user_id
|
self.user_id = self.team_id.user_id
|
||||||
elif len(self.team_id.member_ids) == 1:
|
elif len(self.team_id.member_ids) == 1:
|
||||||
self.user_id = self.team_id.member_ids
|
self.user_id = self.team_id.member_ids
|
||||||
else:
|
else:
|
||||||
self.user_id = self.env['res.users']
|
self.user_id = self.env["res.users"]
|
||||||
return res
|
return res
|
||||||
|
|
||||||
@api.multi
|
@api.constrains("team_id", "user_id")
|
||||||
@api.constrains('team_id', 'user_id')
|
|
||||||
def _check_team_and_user(self):
|
def _check_team_and_user(self):
|
||||||
for activity in self:
|
for activity in self:
|
||||||
# SUPERUSER is used to put mail.activity on some objects
|
# SUPERUSER is used to put mail.activity on some objects
|
||||||
@ -65,8 +64,12 @@ class MailActivity(models.Model):
|
|||||||
# SUPERUSER is inactive and then even if you add it
|
# SUPERUSER is inactive and then even if you add it
|
||||||
# to member_ids it's not taken account
|
# to member_ids it's not taken account
|
||||||
# To not be blocked we must add it to constraint condition
|
# To not be blocked we must add it to constraint condition
|
||||||
if activity.user_id.id != SUPERUSER_ID and activity.team_id and \
|
if (
|
||||||
activity.user_id and \
|
activity.user_id.id != SUPERUSER_ID
|
||||||
activity.user_id not in self.team_id.member_ids:
|
and activity.team_id
|
||||||
|
and activity.user_id
|
||||||
|
and activity.user_id not in self.team_id.member_ids
|
||||||
|
):
|
||||||
raise ValidationError(
|
raise ValidationError(
|
||||||
_('The assigned user is not member of the team.'))
|
_("The assigned user is not member of " "the team.")
|
||||||
|
)
|
||||||
|
@ -5,60 +5,56 @@ from odoo import api, fields, models
|
|||||||
|
|
||||||
class MailActivityTeam(models.Model):
|
class MailActivityTeam(models.Model):
|
||||||
_name = "mail.activity.team"
|
_name = "mail.activity.team"
|
||||||
_description = 'Mail Activity Team'
|
_description = "Mail Activity Team"
|
||||||
|
|
||||||
@api.depends('res_model_ids', 'member_ids')
|
@api.depends("res_model_ids", "member_ids")
|
||||||
def _compute_missing_activities(self):
|
def _compute_missing_activities(self):
|
||||||
activity_model = self.env['mail.activity']
|
activity_model = self.env["mail.activity"]
|
||||||
for team in self:
|
for team in self:
|
||||||
domain = [('team_id', '=', False)]
|
domain = [("team_id", "=", False)]
|
||||||
if team.member_ids:
|
if team.member_ids:
|
||||||
domain.append(('user_id', 'in', team.member_ids.ids))
|
domain.append(("user_id", "in", team.member_ids.ids))
|
||||||
if team.res_model_ids:
|
if team.res_model_ids:
|
||||||
domain.append(('res_model_id', 'in', team.res_model_ids.ids))
|
domain.append(("res_model_id", "in", team.res_model_ids.ids))
|
||||||
team.count_missing_activities = activity_model.search(
|
team.count_missing_activities = activity_model.search(domain, count=True)
|
||||||
domain, count=True)
|
|
||||||
|
|
||||||
name = fields.Char(
|
name = fields.Char(string="Name", required=True, translate=True)
|
||||||
string='Name',
|
active = fields.Boolean(string="Active", default=True)
|
||||||
required=True,
|
|
||||||
translate=True,
|
|
||||||
)
|
|
||||||
active = fields.Boolean(
|
|
||||||
string='Active',
|
|
||||||
default=True,
|
|
||||||
)
|
|
||||||
res_model_ids = fields.Many2many(
|
res_model_ids = fields.Many2many(
|
||||||
comodel_name='ir.model',
|
comodel_name="ir.model",
|
||||||
string='Used models',
|
string="Used models",
|
||||||
domain=lambda self: [
|
domain=lambda self: [
|
||||||
('model', 'in',
|
(
|
||||||
[k for k in self.env.registry if issubclass(
|
"model",
|
||||||
type(self.env[k]), type(self.env['mail.activity.mixin']))
|
"in",
|
||||||
and self.env[k]._auto])
|
[
|
||||||
|
k
|
||||||
|
for k in self.env.registry
|
||||||
|
if issubclass(
|
||||||
|
type(self.env[k]), type(self.env["mail.activity.mixin"])
|
||||||
|
)
|
||||||
|
and self.env[k]._auto
|
||||||
|
],
|
||||||
|
)
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
member_ids = fields.Many2many(
|
member_ids = fields.Many2many(
|
||||||
comodel_name='res.users',
|
comodel_name="res.users",
|
||||||
relation='mail_activity_team_users_rel',
|
relation="mail_activity_team_users_rel",
|
||||||
string="Team Members",
|
string="Team Members",
|
||||||
)
|
)
|
||||||
user_id = fields.Many2one(
|
user_id = fields.Many2one(comodel_name="res.users", string="Team Leader")
|
||||||
comodel_name='res.users',
|
|
||||||
string='Team Leader',
|
|
||||||
)
|
|
||||||
count_missing_activities = fields.Integer(
|
count_missing_activities = fields.Integer(
|
||||||
string="Missing Activities",
|
string="Missing Activities", compute="_compute_missing_activities", default=0
|
||||||
compute='_compute_missing_activities',
|
|
||||||
default=0,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
@api.onchange('member_ids')
|
@api.onchange("member_ids")
|
||||||
def _onchange_member_ids(self):
|
def _onchange_member_ids(self):
|
||||||
|
"""Remove team leader in case is not a member anymore"""
|
||||||
if self.user_id and self.user_id not in self.member_ids:
|
if self.user_id and self.user_id not in self.member_ids:
|
||||||
self.user_id = False
|
self.user_id = False
|
||||||
|
|
||||||
@api.onchange('user_id')
|
@api.onchange("user_id")
|
||||||
def _onchange_user_id(self):
|
def _onchange_user_id(self):
|
||||||
if self.user_id and self.user_id not in self.member_ids:
|
if self.user_id and self.user_id not in self.member_ids:
|
||||||
members_ids = self.member_ids.ids
|
members_ids = self.member_ids.ids
|
||||||
@ -66,13 +62,13 @@ class MailActivityTeam(models.Model):
|
|||||||
self.member_ids = [(4, member) for member in members_ids]
|
self.member_ids = [(4, member) for member in members_ids]
|
||||||
|
|
||||||
def assign_team_to_unassigned_activities(self):
|
def assign_team_to_unassigned_activities(self):
|
||||||
activity_model = self.env['mail.activity']
|
activity_model = self.env["mail.activity"]
|
||||||
for team in self:
|
for team in self:
|
||||||
domain = [('team_id', '=', False)]
|
domain = [("team_id", "=", False)]
|
||||||
if team.member_ids:
|
if team.member_ids:
|
||||||
domain.append(('user_id', 'in', team.member_ids.ids))
|
domain.append(("user_id", "in", team.member_ids.ids))
|
||||||
if team.res_model_ids:
|
if team.res_model_ids:
|
||||||
domain.append(('res_model_id', 'in', team.res_model_ids.ids))
|
domain.append(("res_model_id", "in", team.res_model_ids.ids))
|
||||||
missing_activities = activity_model.search(domain)
|
missing_activities = activity_model.search(domain)
|
||||||
for missing_activity in missing_activities:
|
for missing_activity in missing_activities:
|
||||||
missing_activity.write({'team_id': team.id})
|
missing_activity.write({"team_id": team.id})
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
# Copyright 2018 Eficent Business and IT Consulting Services, S.L.
|
# Copyright 2018 Eficent Business and IT Consulting Services, S.L.
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||||
from odoo import models, fields
|
from odoo import fields, models
|
||||||
|
|
||||||
|
|
||||||
class ResUsers(models.Model):
|
class ResUsers(models.Model):
|
||||||
_inherit = "res.users"
|
_inherit = "res.users"
|
||||||
|
|
||||||
activity_team_ids = fields.Many2many(
|
activity_team_ids = fields.Many2many(
|
||||||
comodel_name='mail.activity.team',
|
comodel_name="mail.activity.team",
|
||||||
relation='mail_activity_team_users_rel',
|
relation="mail_activity_team_users_rel",
|
||||||
string="Activity Teams",
|
string="Activity Teams",
|
||||||
)
|
)
|
||||||
|
@ -2,3 +2,4 @@
|
|||||||
|
|
||||||
* Jordi Ballester Alomar (jordi.ballester@eficent.com)
|
* Jordi Ballester Alomar (jordi.ballester@eficent.com)
|
||||||
* Miquel Raïch (miquel.raich@eficent.com)
|
* Miquel Raïch (miquel.raich@eficent.com)
|
||||||
|
* Pedro Gonzalez (pedro.gonzalez@pesol.es)
|
||||||
|
@ -1,3 +1 @@
|
|||||||
This module adds the possibility to assign teams to activities.
|
This module adds the possibility to assign teams to activities.
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,94 +1,141 @@
|
|||||||
# Copyright 2018 Eficent Business and IT Consulting Services, S.L.
|
# Copyright 2018 Eficent Business and IT Consulting Services, S.L.
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||||
from odoo.tests.common import TransactionCase
|
|
||||||
from odoo.exceptions import ValidationError
|
from odoo.exceptions import ValidationError
|
||||||
|
from odoo.tests.common import TransactionCase
|
||||||
|
|
||||||
|
|
||||||
class TestMailActivityTeam(TransactionCase):
|
class TestMailActivityTeam(TransactionCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TestMailActivityTeam, self).setUp()
|
super(TestMailActivityTeam, self).setUp()
|
||||||
|
|
||||||
self.env["mail.activity.team"].search([]).unlink()
|
self.env["mail.activity.team"].search([]).unlink()
|
||||||
|
|
||||||
self.employee = self.env['res.users'].create({
|
self.employee = self.env["res.users"].create(
|
||||||
'company_id': self.env.ref("base.main_company").id,
|
{
|
||||||
'name': "Employee",
|
"company_id": self.env.ref("base.main_company").id,
|
||||||
'login': "csu",
|
"name": "Employee",
|
||||||
'email': "crmuser@yourcompany.com",
|
"login": "csu",
|
||||||
'groups_id': [(6, 0, [
|
"email": "crmuser@yourcompany.com",
|
||||||
self.env.ref('base.group_user').id,
|
"groups_id": [
|
||||||
self.env.ref('base.group_partner_manager').id])]
|
(
|
||||||
})
|
6,
|
||||||
|
0,
|
||||||
|
[
|
||||||
|
self.env.ref("base.group_user").id,
|
||||||
|
self.env.ref("base.group_partner_manager").id,
|
||||||
|
],
|
||||||
|
)
|
||||||
|
],
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
self.employee2 = self.env['res.users'].create({
|
self.employee2 = self.env["res.users"].create(
|
||||||
'company_id': self.env.ref("base.main_company").id,
|
{
|
||||||
'name': "Employee 2",
|
"company_id": self.env.ref("base.main_company").id,
|
||||||
'login': "csu2",
|
"name": "Employee 2",
|
||||||
'email': "crmuser2@yourcompany.com",
|
"login": "csu2",
|
||||||
'groups_id': [(6, 0, [self.env.ref('base.group_user').id])]
|
"email": "crmuser2@yourcompany.com",
|
||||||
})
|
"groups_id": [(6, 0, [self.env.ref("base.group_user").id])],
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
self.partner_ir_model = self.env['ir.model']._get('res.partner')
|
self.partner_ir_model = self.env["ir.model"]._get("res.partner")
|
||||||
|
|
||||||
activity_type_model = self.env['mail.activity.type']
|
activity_type_model = self.env["mail.activity.type"]
|
||||||
self.activity1 = activity_type_model.create({
|
self.activity1 = activity_type_model.create(
|
||||||
'name': 'Initial Contact',
|
{
|
||||||
'days': 5,
|
"name": "Initial Contact",
|
||||||
'summary': 'ACT 1 : Presentation, barbecue, ... ',
|
"delay_count": 5,
|
||||||
'res_model_id': self.partner_ir_model.id,
|
"delay_unit": "days",
|
||||||
})
|
"summary": "ACT 1 : Presentation, barbecue, ... ",
|
||||||
self.activity2 = activity_type_model.create({
|
"res_model_id": self.partner_ir_model.id,
|
||||||
'name': 'Call for Demo',
|
}
|
||||||
'days': 6,
|
)
|
||||||
'summary': 'ACT 2 : I want to show you my ERP !',
|
self.activity2 = activity_type_model.create(
|
||||||
'res_model_id': self.partner_ir_model.id,
|
{
|
||||||
})
|
"name": "Call for Demo",
|
||||||
|
"delay_count": 6,
|
||||||
|
"delay_unit": "days",
|
||||||
|
"summary": "ACT 2 : I want to show you my ERP !",
|
||||||
|
"res_model_id": self.partner_ir_model.id,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
self.partner_client = self.env.ref("base.res_partner_1")
|
self.partner_client = self.env.ref("base.res_partner_1")
|
||||||
|
|
||||||
self.act1 = self.env['mail.activity'].sudo(self.employee).create({
|
self.act1 = (
|
||||||
'activity_type_id': self.activity1.id,
|
self.env["mail.activity"]
|
||||||
'note': 'Partner activity 1.',
|
.with_user(self.employee)
|
||||||
'res_id': self.partner_client.id,
|
.create(
|
||||||
'res_model_id': self.partner_ir_model.id,
|
{
|
||||||
'user_id': self.employee.id,
|
"activity_type_id": self.activity1.id,
|
||||||
})
|
"note": "Partner activity 1.",
|
||||||
|
"res_id": self.partner_client.id,
|
||||||
|
"res_model_id": self.partner_ir_model.id,
|
||||||
|
"user_id": self.employee.id,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
self.team1 = self.env['mail.activity.team'].sudo().create({
|
self.team1 = (
|
||||||
'name': 'Team 1',
|
self.env["mail.activity.team"]
|
||||||
'res_model_ids': [(6, 0, [self.partner_ir_model.id])],
|
.sudo()
|
||||||
'member_ids': [(6, 0, [self.employee.id])],
|
.create(
|
||||||
})
|
{
|
||||||
|
"name": "Team 1",
|
||||||
|
"res_model_ids": [(6, 0, [self.partner_ir_model.id])],
|
||||||
|
"member_ids": [(6, 0, [self.employee.id])],
|
||||||
|
}
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
self.team2 = self.env['mail.activity.team'].sudo().create({
|
self.team2 = (
|
||||||
'name': 'Team 2',
|
self.env["mail.activity.team"]
|
||||||
'res_model_ids': [(6, 0, [self.partner_ir_model.id])],
|
.sudo()
|
||||||
'member_ids': [(6, 0, [self.employee.id, self.employee2.id])],
|
.create(
|
||||||
})
|
{
|
||||||
|
"name": "Team 2",
|
||||||
|
"res_model_ids": [(6, 0, [self.partner_ir_model.id])],
|
||||||
|
"member_ids": [(6, 0, [self.employee.id, self.employee2.id])],
|
||||||
|
}
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
self.act2 = self.env['mail.activity'].sudo(self.employee).create({
|
self.act2 = (
|
||||||
'activity_type_id': self.activity2.id,
|
self.env["mail.activity"]
|
||||||
'note': 'Partner activity 2.',
|
.with_user(self.employee)
|
||||||
'res_id': self.partner_client.id,
|
.create(
|
||||||
'res_model_id': self.partner_ir_model.id,
|
{
|
||||||
'user_id': self.employee.id,
|
"activity_type_id": self.activity2.id,
|
||||||
})
|
"note": "Partner activity 2.",
|
||||||
|
"res_id": self.partner_client.id,
|
||||||
|
"res_model_id": self.partner_ir_model.id,
|
||||||
|
"user_id": self.employee.id,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
def test_missing_activities(self):
|
def test_missing_activities(self):
|
||||||
self.assertFalse(
|
self.assertFalse(self.act1.team_id, "Error: Activity 1 should not have a team.")
|
||||||
self.act1.team_id, 'Error: Activity 1 should not have a team.')
|
|
||||||
self.assertEqual(self.team1.count_missing_activities, 1)
|
self.assertEqual(self.team1.count_missing_activities, 1)
|
||||||
self.team1.assign_team_to_unassigned_activities()
|
self.team1.assign_team_to_unassigned_activities()
|
||||||
self.team1._compute_missing_activities()
|
self.team1._compute_missing_activities()
|
||||||
self.assertEqual(self.team1.count_missing_activities, 0)
|
self.assertEqual(self.team1.count_missing_activities, 0)
|
||||||
self.assertEqual(self.act1.team_id, self.team1)
|
self.assertEqual(self.act1.team_id, self.team1)
|
||||||
|
|
||||||
|
def test_team_onchanges(self):
|
||||||
|
self.assertFalse(
|
||||||
|
self.team2.user_id, "Error: Team 2 should not have a Team Leader yet."
|
||||||
|
)
|
||||||
|
self.team2.user_id = self.employee
|
||||||
|
self.team2.member_ids = [(3, self.employee.id)]
|
||||||
|
self.team2._onchange_member_ids()
|
||||||
|
self.assertFalse(self.team2.user_id)
|
||||||
|
|
||||||
def test_activity_onchanges(self):
|
def test_activity_onchanges(self):
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
self.act2.team_id, self.team1,
|
self.act2.team_id, self.team1, "Error: Activity 2 should have Team 1."
|
||||||
'Error: Activity 2 should have Team 1.')
|
)
|
||||||
with self.env.do_in_onchange():
|
|
||||||
self.act2.team_id = False
|
self.act2.team_id = False
|
||||||
self.act2._onchange_team_id()
|
self.act2._onchange_team_id()
|
||||||
self.assertEqual(self.act2.user_id, self.employee)
|
self.assertEqual(self.act2.user_id, self.employee)
|
||||||
@ -98,21 +145,5 @@ class TestMailActivityTeam(TransactionCase):
|
|||||||
self.act2.user_id = self.employee2
|
self.act2.user_id = self.employee2
|
||||||
self.act2._onchange_user_id()
|
self.act2._onchange_user_id()
|
||||||
self.assertEqual(self.act2.team_id, self.team2)
|
self.assertEqual(self.act2.team_id, self.team2)
|
||||||
self.act2.team_id = self.team1
|
|
||||||
self.act2._onchange_team_id()
|
|
||||||
self.assertEqual(self.act2.user_id, self.team1.member_ids)
|
|
||||||
with self.assertRaises(ValidationError):
|
with self.assertRaises(ValidationError):
|
||||||
self.act2.write({
|
self.act2.write({"user_id": self.employee2.id, "team_id": self.team1.id})
|
||||||
'user_id': self.employee2.id,
|
|
||||||
'team_id': self.team1.id,
|
|
||||||
})
|
|
||||||
|
|
||||||
def test_team_onchanges(self):
|
|
||||||
self.assertFalse(
|
|
||||||
self.team2.user_id,
|
|
||||||
'Error: Team 2 should not have a Team Leader yet.')
|
|
||||||
with self.env.do_in_onchange():
|
|
||||||
self.team2.user_id = self.employee
|
|
||||||
self.team2.member_ids = [(3, self.employee.id)]
|
|
||||||
self.team2._onchange_member_ids()
|
|
||||||
self.assertFalse(self.team2.user_id)
|
|
||||||
|
@ -78,7 +78,6 @@
|
|||||||
<record model="ir.actions.act_window" id="mail_activity_team_action">
|
<record model="ir.actions.act_window" id="mail_activity_team_action">
|
||||||
<field name="name">Activity Teams</field>
|
<field name="name">Activity Teams</field>
|
||||||
<field name="res_model">mail.activity.team</field>
|
<field name="res_model">mail.activity.team</field>
|
||||||
<field name="view_type">form</field>
|
|
||||||
<field name="view_mode">tree,form</field>
|
<field name="view_mode">tree,form</field>
|
||||||
<field name="domain">[]</field>
|
<field name="domain">[]</field>
|
||||||
<field name="context">{}</field>
|
<field name="context">{}</field>
|
||||||
|
@ -61,7 +61,7 @@
|
|||||||
<xpath expr='//field[@name="user_id"]' position='before'>
|
<xpath expr='//field[@name="user_id"]' position='before'>
|
||||||
<field name="team_id"/>
|
<field name="team_id"/>
|
||||||
</xpath>
|
</xpath>
|
||||||
<xpath expr='//filter[@name="activities_my"]' position='after'>
|
<xpath expr='//filter[@name="activities_6_month"]' position='after'>
|
||||||
<filter name="my_team_activities" string="My Team Activities" domain="[('team_id.member_ids', '=', uid)]"/>
|
<filter name="my_team_activities" string="My Team Activities" domain="[('team_id.member_ids', '=', uid)]"/>
|
||||||
</xpath>
|
</xpath>
|
||||||
<group position='inside'>
|
<group position='inside'>
|
||||||
|
Loading…
Reference in New Issue
Block a user