2013-07-10 10:15:08 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
##############################################################################
|
|
|
|
#
|
|
|
|
# OpenERP, Open Source Business Applications
|
|
|
|
# Copyright (c) 2013-TODAY OpenERP S.A. <http://www.openerp.com>
|
|
|
|
#
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU Affero General Public License as
|
|
|
|
# published by the Free Software Foundation, either version 3 of the
|
|
|
|
# License, or (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU Affero General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU Affero General Public License
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
#
|
|
|
|
##############################################################################
|
|
|
|
|
2013-08-27 13:30:58 +00:00
|
|
|
from openerp.addons.mail.tests.common import TestMail
|
2013-07-10 10:15:08 +00:00
|
|
|
|
|
|
|
|
2013-08-27 13:30:58 +00:00
|
|
|
class TestProjectBase(TestMail):
|
2013-07-10 10:15:08 +00:00
|
|
|
|
2015-06-23 11:14:07 +00:00
|
|
|
@classmethod
|
|
|
|
def setUpClass(cls):
|
|
|
|
super(TestProjectBase, cls).setUpClass()
|
|
|
|
cr, uid = cls.cr, cls.uid
|
2013-07-10 10:15:08 +00:00
|
|
|
|
|
|
|
# Usefull models
|
2015-06-23 11:14:07 +00:00
|
|
|
cls.project_project = cls.registry('project.project')
|
|
|
|
cls.project_task = cls.registry('project.task')
|
|
|
|
cls.project_task_delegate = cls.registry('project.task.delegate')
|
2013-07-10 10:15:08 +00:00
|
|
|
|
|
|
|
# Find Project User group
|
2015-06-23 11:14:07 +00:00
|
|
|
cls.group_project_user_id = cls.env.ref('project.group_project_user').id or False
|
2013-07-10 10:15:08 +00:00
|
|
|
|
|
|
|
# Find Project Manager group
|
2015-06-23 11:14:07 +00:00
|
|
|
cls.group_project_manager_id = cls.env.ref('project.group_project_manager').id or False
|
2013-07-10 10:15:08 +00:00
|
|
|
|
|
|
|
# Test partners to use through the various tests
|
2015-06-23 11:14:07 +00:00
|
|
|
cls.project_partner_id = cls.res_partner.create(cr, uid, {
|
2013-07-10 10:15:08 +00:00
|
|
|
'name': 'Gertrude AgrolaitPartner',
|
|
|
|
'email': 'gertrude.partner@agrolait.com',
|
|
|
|
})
|
2015-06-23 11:14:07 +00:00
|
|
|
cls.email_partner_id = cls.res_partner.create(cr, uid, {
|
2013-07-10 10:15:08 +00:00
|
|
|
'name': 'Patrick Ratatouille',
|
|
|
|
'email': 'patrick.ratatouille@agrolait.com',
|
|
|
|
})
|
|
|
|
|
|
|
|
# Test users to use through the various tests
|
2015-06-23 11:14:07 +00:00
|
|
|
cls.user_projectuser_id = cls.res_users.create(cr, uid, {
|
2013-07-10 10:15:08 +00:00
|
|
|
'name': 'Armande ProjectUser',
|
|
|
|
'login': 'Armande',
|
|
|
|
'alias_name': 'armande',
|
|
|
|
'email': 'armande.projectuser@example.com',
|
2015-06-23 11:14:07 +00:00
|
|
|
'groups_id': [(6, 0, [cls.group_employee_id, cls.group_project_user_id])]
|
2015-06-26 10:44:03 +00:00
|
|
|
}, {'no_reset_password': True})
|
2015-06-23 11:14:07 +00:00
|
|
|
cls.user_projectmanager_id = cls.res_users.create(cr, uid, {
|
2013-07-10 10:15:08 +00:00
|
|
|
'name': 'Bastien ProjectManager',
|
|
|
|
'login': 'bastien',
|
|
|
|
'alias_name': 'bastien',
|
|
|
|
'email': 'bastien.projectmanager@example.com',
|
2015-06-23 11:14:07 +00:00
|
|
|
'groups_id': [(6, 0, [cls.group_employee_id, cls.group_project_manager_id])]
|
2015-06-26 10:44:03 +00:00
|
|
|
}, {'no_reset_password': True})
|
2015-06-23 11:14:07 +00:00
|
|
|
cls.user_none_id = cls.res_users.create(cr, uid, {
|
2013-07-10 12:25:26 +00:00
|
|
|
'name': 'Charlie Avotbonkeur',
|
|
|
|
'login': 'charlie',
|
|
|
|
'alias_name': 'charlie',
|
|
|
|
'email': 'charlie.noone@example.com',
|
|
|
|
'groups_id': [(6, 0, [])]
|
2015-06-26 10:44:03 +00:00
|
|
|
}, {'no_reset_password': True})
|
2015-06-23 11:14:07 +00:00
|
|
|
cls.user_projectuser = cls.res_users.browse(cr, uid, cls.user_projectuser_id)
|
|
|
|
cls.user_projectmanager = cls.res_users.browse(cr, uid, cls.user_projectmanager_id)
|
|
|
|
cls.partner_projectuser_id = cls.user_projectuser.partner_id.id
|
|
|
|
cls.partner_projectmanager_id = cls.user_projectmanager.partner_id.id
|
2013-07-10 10:15:08 +00:00
|
|
|
|
|
|
|
# Test 'Pigs' project
|
2015-06-23 11:14:07 +00:00
|
|
|
cls.project_pigs_id = cls.project_project.create(cr, uid, {
|
2013-07-10 10:15:08 +00:00
|
|
|
'name': 'Pigs',
|
|
|
|
'privacy_visibility': 'public',
|
|
|
|
'alias_name': 'project+pigs',
|
2015-06-23 11:14:07 +00:00
|
|
|
'partner_id': cls.partner_raoul_id,
|
2013-07-10 10:15:08 +00:00
|
|
|
}, {'mail_create_nolog': True})
|
|
|
|
|
|
|
|
# Already-existing tasks in Pigs
|
2015-06-23 11:14:07 +00:00
|
|
|
cls.task_1_id = cls.project_task.create(cr, uid, {
|
2013-07-10 10:15:08 +00:00
|
|
|
'name': 'Pigs UserTask',
|
2015-06-23 11:14:07 +00:00
|
|
|
'user_id': cls.user_projectuser_id,
|
|
|
|
'project_id': cls.project_pigs_id,
|
2013-07-10 10:15:08 +00:00
|
|
|
}, {'mail_create_nolog': True})
|
2015-06-23 11:14:07 +00:00
|
|
|
cls.task_2_id = cls.project_task.create(cr, uid, {
|
2013-07-10 10:15:08 +00:00
|
|
|
'name': 'Pigs ManagerTask',
|
2015-06-23 11:14:07 +00:00
|
|
|
'user_id': cls.user_projectmanager_id,
|
|
|
|
'project_id': cls.project_pigs_id,
|
2013-07-10 10:15:08 +00:00
|
|
|
}, {'mail_create_nolog': True})
|