From 2f7c03d9ca5809b65dc6eaa778064668d34fcd2e Mon Sep 17 00:00:00 2001 From: Raphael Collet Date: Mon, 23 Jul 2018 10:47:19 +0200 Subject: [PATCH] [IMP] base: add regular user admin as uid 2 User 1 simply becomes a technical user (inactive, no password). --- addons/account/security/account_security.xml | 5 +- .../security/account_budget_security.xml | 4 + addons/crm/security/crm_security.xml | 4 + addons/event/security/event_security.xml | 2 +- addons/fleet/security/fleet_security.xml | 2 +- addons/hr/data/hr_data.xml | 12 +- addons/hr/data/hr_demo.xml | 10 +- addons/hr/security/hr_security.xml | 2 +- .../hr_attendance/data/hr_attendance_demo.xml | 6 +- .../security/hr_attendance_security.xml | 2 +- addons/hr_contract/security/security.xml | 2 +- addons/hr_contract/tests/test_auto_status.py | 2 +- addons/hr_expense/data/hr_expense_demo.xml | 4 +- .../security/hr_expense_security.xml | 2 +- addons/hr_holidays/data/hr_holidays_demo.xml | 12 +- .../security/hr_holidays_security.xml | 2 +- .../hr_holidays/tests/test_holidays_flow.py | 10 +- .../security/hr_payroll_security.xml | 2 +- .../security/hr_recruitment_security.xml | 2 +- .../hr_timesheet/data/hr_timesheet_data.xml | 2 +- .../security/hr_timesheet_security.xml | 4 +- .../security/im_livechat_channel_security.xml | 2 +- addons/l10n_in_hr_payroll/tests/common.py | 2 +- addons/lunch/security/lunch_security.xml | 2 +- addons/mail/data/mail_data.xml | 2 +- addons/mail/models/mail_mail.py | 6 +- addons/mail/models/mail_message.py | 9 +- addons/mail_bot/data/mailbot_demo.xml | 2 +- .../security/mass_mailing_security.xml | 2 +- addons/mrp/security/mrp_security.xml | 2 +- .../security/point_of_sale_security.xml | 2 +- addons/point_of_sale/tests/test_frontend.py | 2 +- addons/project/security/project_security.xml | 2 +- .../purchase/security/purchase_security.xml | 2 +- addons/sale/security/sale_security.xml | 4 + .../sale_timesheet/data/sale_service_demo.xml | 34 ++--- addons/sales_team/data/sales_team_data.xml | 2 +- .../security/sales_team_security.xml | 2 +- addons/stock/security/stock_security.xml | 2 +- addons/survey/security/survey_security.xml | 2 +- addons/test_mail/tests/common.py | 4 +- addons/test_mail/tests/test_discuss.py | 2 +- addons/test_mail/tests/test_ir_actions.py | 4 +- addons/test_mail/tests/test_mail_followers.py | 1 - addons/test_mail/tests/test_mail_resend.py | 8 +- addons/test_mail/tests/test_performance.py | 129 +++++++++--------- addons/website/security/website_security.xml | 6 +- addons/website_forum/data/forum_data.xml | 3 + addons/website_hr/data/hr_employee_demo.xml | 2 +- .../static/src/js/website_sale.test.js | 34 +---- .../tests/test_customize.py | 4 + odoo/addons/base/data/base_data.sql | 12 +- odoo/addons/base/data/res_partner_data.xml | 7 + odoo/addons/base/data/res_users_data.xml | 13 ++ odoo/addons/base/data/res_users_demo.xml | 5 + odoo/addons/base/models/res_partner.py | 11 +- odoo/addons/base/security/base_groups.xml | 7 +- odoo/addons/base/tests/test_xmlrpc.py | 10 +- odoo/addons/test_new_api/models.py | 2 +- .../test_new_api/tests/test_onchange.py | 2 +- .../tests/test_performance.py | 40 +++--- odoo/tests/common.py | 3 +- 62 files changed, 254 insertions(+), 231 deletions(-) diff --git a/addons/account/security/account_security.xml b/addons/account/security/account_security.xml index c63b1c81f6d..3512781d919 100644 --- a/addons/account/security/account_security.xml +++ b/addons/account/security/account_security.xml @@ -40,8 +40,9 @@ - - + + + diff --git a/addons/account_budget/security/account_budget_security.xml b/addons/account_budget/security/account_budget_security.xml index edd9638188a..b2d12e37113 100644 --- a/addons/account_budget/security/account_budget_security.xml +++ b/addons/account_budget/security/account_budget_security.xml @@ -27,5 +27,9 @@ + + + + diff --git a/addons/crm/security/crm_security.xml b/addons/crm/security/crm_security.xml index 13f854c9be6..fd080b8e2a8 100644 --- a/addons/crm/security/crm_security.xml +++ b/addons/crm/security/crm_security.xml @@ -11,6 +11,10 @@ + + + + Configuration diff --git a/addons/event/security/event_security.xml b/addons/event/security/event_security.xml index 7664085fc0e..6694b0ff6b7 100644 --- a/addons/event/security/event_security.xml +++ b/addons/event/security/event_security.xml @@ -11,7 +11,7 @@ Manager - + diff --git a/addons/fleet/security/fleet_security.xml b/addons/fleet/security/fleet_security.xml index 3b9d5f85a9f..29777a1ab47 100644 --- a/addons/fleet/security/fleet_security.xml +++ b/addons/fleet/security/fleet_security.xml @@ -13,7 +13,7 @@ Manager - + diff --git a/addons/hr/data/hr_data.xml b/addons/hr/data/hr_data.xml index 5416e7ecd06..53fac18b8c6 100644 --- a/addons/hr/data/hr_data.xml +++ b/addons/hr/data/hr_data.xml @@ -10,12 +10,12 @@ Sales - - - - - - + + + + + + diff --git a/addons/hr/data/hr_demo.xml b/addons/hr/data/hr_demo.xml index cfcf3c3e34c..853ce9f2c72 100644 --- a/addons/hr/data/hr_demo.xml +++ b/addons/hr/data/hr_demo.xml @@ -135,7 +135,7 @@ If you have development competencies, we can propose you specific traineeships - + Building 1, Second Floor (237)-125-2389 aiden.hughes71@example.com @@ -232,7 +232,7 @@ If you have development competencies, we can propose you specific traineeships Audrey Peterson - + Building 1, Second Floor @@ -244,7 +244,7 @@ If you have development competencies, we can propose you specific traineeships Toni Jimenez - + Building 1, Second Floor @@ -256,7 +256,7 @@ If you have development competencies, we can propose you specific traineeships Jeffrey Kelly - + Building 1, Second Floor @@ -268,7 +268,7 @@ If you have development competencies, we can propose you specific traineeships Tina Williamson - + Building 1, Second Floor diff --git a/addons/hr/security/hr_security.xml b/addons/hr/security/hr_security.xml index a93fbb035fe..ddb4f9c5cbe 100644 --- a/addons/hr/security/hr_security.xml +++ b/addons/hr/security/hr_security.xml @@ -13,7 +13,7 @@ The user will have an access to the human resources configuration as well as statistic reports. - + diff --git a/addons/hr_attendance/data/hr_attendance_demo.xml b/addons/hr_attendance/data/hr_attendance_demo.xml index e1f444dfa62..f0b81a893f8 100644 --- a/addons/hr_attendance/data/hr_attendance_demo.xml +++ b/addons/hr_attendance/data/hr_attendance_demo.xml @@ -6,7 +6,7 @@ 123 - + 0000 456 @@ -14,13 +14,13 @@ - + - + diff --git a/addons/hr_attendance/security/hr_attendance_security.xml b/addons/hr_attendance/security/hr_attendance_security.xml index 6b903e890f9..8c3bc9482fb 100644 --- a/addons/hr_attendance/security/hr_attendance_security.xml +++ b/addons/hr_attendance/security/hr_attendance_security.xml @@ -11,7 +11,7 @@ Manager - + diff --git a/addons/hr_contract/security/security.xml b/addons/hr_contract/security/security.xml index 1efe5cf4de8..6a922ba15b2 100644 --- a/addons/hr_contract/security/security.xml +++ b/addons/hr_contract/security/security.xml @@ -4,7 +4,7 @@ Manager - + diff --git a/addons/hr_contract/tests/test_auto_status.py b/addons/hr_contract/tests/test_auto_status.py index efb7de51f9a..580a6d17423 100644 --- a/addons/hr_contract/tests/test_auto_status.py +++ b/addons/hr_contract/tests/test_auto_status.py @@ -10,7 +10,7 @@ class TestHrContracts(TransactionCase): def setUp(self): super(TestHrContracts, self).setUp() self.contracts = self.env['hr.contract'].with_context(tracking_disable=True) - self.employee = self.env.ref('hr.employee_root') + self.employee = self.env.ref('hr.employee_admin') self.test_contract = dict(name='Test', wage=1, employee_id=self.employee.id, state='open') def apply_cron(self): diff --git a/addons/hr_expense/data/hr_expense_demo.xml b/addons/hr_expense/data/hr_expense_demo.xml index 9f4dfb84587..3411073ab0f 100644 --- a/addons/hr_expense/data/hr_expense_demo.xml +++ b/addons/hr_expense/data/hr_expense_demo.xml @@ -17,7 +17,7 @@ private - + @@ -51,6 +51,7 @@ Travel by Air + @@ -60,6 +61,7 @@ Hotel Expenses + diff --git a/addons/hr_expense/security/hr_expense_security.xml b/addons/hr_expense/security/hr_expense_security.xml index d09bf4b5311..31809dbf201 100644 --- a/addons/hr_expense/security/hr_expense_security.xml +++ b/addons/hr_expense/security/hr_expense_security.xml @@ -10,7 +10,7 @@ Manager - + diff --git a/addons/hr_holidays/data/hr_holidays_demo.xml b/addons/hr_holidays/data/hr_holidays_demo.xml index ae743c74f0d..72adb03ea37 100644 --- a/addons/hr_holidays/data/hr_holidays_demo.xml +++ b/addons/hr_holidays/data/hr_holidays_demo.xml @@ -31,7 +31,7 @@ Legal Leaves for Peter Parker 20 - + confirm @@ -39,7 +39,7 @@ International Tour 7 - + confirm @@ -48,14 +48,14 @@ 160 20 - + Summer Vacation 7 - + @@ -67,7 +67,7 @@ 3 - + @@ -76,7 +76,7 @@ 3 - + confirm diff --git a/addons/hr_holidays/security/hr_holidays_security.xml b/addons/hr_holidays/security/hr_holidays_security.xml index 5b5c4eeb8da..f03fb388f72 100644 --- a/addons/hr_holidays/security/hr_holidays_security.xml +++ b/addons/hr_holidays/security/hr_holidays_security.xml @@ -10,7 +10,7 @@ Manager - + diff --git a/addons/hr_holidays/tests/test_holidays_flow.py b/addons/hr_holidays/tests/test_holidays_flow.py index 6bbb81d57c0..44013d63710 100644 --- a/addons/hr_holidays/tests/test_holidays_flow.py +++ b/addons/hr_holidays/tests/test_holidays_flow.py @@ -235,8 +235,8 @@ class TestHolidaysFlow(TestHrHolidaysBase): with self.assertRaises(ValidationError): hol2_manager_group.action_confirm() - employee_id = self.ref('hr.employee_root') - # cl can be of maximum 20 days for employee_root + employee_id = self.ref('hr.employee_admin') + # cl can be of maximum 20 days for employee_admin hol3_status = self.env.ref('hr_holidays.holiday_status_cl').with_context(employee_id=employee_id) # I assign the dates in the holiday request for 1 day hol3 = Requests.create({ @@ -355,7 +355,7 @@ class TestHolidaysFlow(TestHrHolidaysBase): # Print the HR Holidays(Summary Department) Report through the wizard ctx = { 'model': 'hr.department', - 'active_ids': [self.ref('hr.employee_root'), self.ref('hr.employee_qdp'), self.ref('hr.employee_al')] + 'active_ids': [self.ref('hr.employee_admin'), self.ref('hr.employee_qdp'), self.ref('hr.employee_al')] } data_dict = { 'date_from': datetime.today().strftime('%Y-%m-01'), @@ -367,11 +367,11 @@ class TestHolidaysFlow(TestHrHolidaysBase): # Print the HR Holidays(Summary Employee) Report through the wizard ctx = { 'model': 'hr.employee', - 'active_ids': [self.ref('hr.employee_root'), self.ref('hr.employee_qdp'), self.ref('hr.employee_al')] + 'active_ids': [self.ref('hr.employee_admin'), self.ref('hr.employee_qdp'), self.ref('hr.employee_al')] } data_dict = { 'date_from': datetime.today().strftime('%Y-%m-01'), - 'emp': [(6, 0, [self.ref('hr.employee_root'), self.ref('hr.employee_qdp'), self.ref('hr.employee_al')])], + 'emp': [(6, 0, [self.ref('hr.employee_admin'), self.ref('hr.employee_qdp'), self.ref('hr.employee_al')])], 'holiday_type': 'Approved' } test_reports.try_report_action(self.env.cr, self.env.uid, 'action_hr_holidays_summary_employee', wiz_data=data_dict, context=ctx, our_module='hr_holidays') diff --git a/addons/hr_payroll/security/hr_payroll_security.xml b/addons/hr_payroll/security/hr_payroll_security.xml index a6bdba56b1c..93bc89ead02 100644 --- a/addons/hr_payroll/security/hr_payroll_security.xml +++ b/addons/hr_payroll/security/hr_payroll_security.xml @@ -12,7 +12,7 @@ Manager - + diff --git a/addons/hr_recruitment/security/hr_recruitment_security.xml b/addons/hr_recruitment/security/hr_recruitment_security.xml index b88aafe09fd..5544210128e 100644 --- a/addons/hr_recruitment/security/hr_recruitment_security.xml +++ b/addons/hr_recruitment/security/hr_recruitment_security.xml @@ -19,7 +19,7 @@ Manager - + diff --git a/addons/hr_timesheet/data/hr_timesheet_data.xml b/addons/hr_timesheet/data/hr_timesheet_data.xml index 594c0ca9745..5bbea815d2c 100644 --- a/addons/hr_timesheet/data/hr_timesheet_data.xml +++ b/addons/hr_timesheet/data/hr_timesheet_data.xml @@ -5,7 +5,7 @@ only by admin when installing hr_timesheet, to avoid confusing --> project_tour - + diff --git a/addons/hr_timesheet/security/hr_timesheet_security.xml b/addons/hr_timesheet/security/hr_timesheet_security.xml index 332d4ec08e1..b4d089c54a4 100644 --- a/addons/hr_timesheet/security/hr_timesheet_security.xml +++ b/addons/hr_timesheet/security/hr_timesheet_security.xml @@ -7,14 +7,14 @@ User - + Manager - + diff --git a/addons/im_livechat/security/im_livechat_channel_security.xml b/addons/im_livechat/security/im_livechat_channel_security.xml index cab82a18e4d..2dcc85ec157 100644 --- a/addons/im_livechat/security/im_livechat_channel_security.xml +++ b/addons/im_livechat/security/im_livechat_channel_security.xml @@ -17,7 +17,7 @@ The user will be able to delete support channels. - + diff --git a/addons/l10n_in_hr_payroll/tests/common.py b/addons/l10n_in_hr_payroll/tests/common.py index 3ab9379597c..951cd7d1321 100644 --- a/addons/l10n_in_hr_payroll/tests/common.py +++ b/addons/l10n_in_hr_payroll/tests/common.py @@ -19,7 +19,7 @@ class TestPaymentAdviceBase(TransactionCase): self.bank_1 = self.env.ref('base.res_bank_1') self.in_country = self.env.ref('base.in') self.rd_dept = self.env.ref('hr.dep_rd') - self.employee_fp = self.env.ref('hr.employee_root') + self.employee_fp = self.env.ref('hr.employee_admin') self.employee_al = self.env.ref('hr.employee_al') # I create a new bank record diff --git a/addons/lunch/security/lunch_security.xml b/addons/lunch/security/lunch_security.xml index f42b9333f79..a32a9f2c6af 100644 --- a/addons/lunch/security/lunch_security.xml +++ b/addons/lunch/security/lunch_security.xml @@ -13,7 +13,7 @@ Manager - + diff --git a/addons/mail/data/mail_data.xml b/addons/mail/data/mail_data.xml index f26beef2a71..d34c233c8c7 100644 --- a/addons/mail/data/mail_data.xml +++ b/addons/mail/data/mail_data.xml @@ -1,7 +1,7 @@ - + inbox diff --git a/addons/mail/models/mail_mail.py b/addons/mail/models/mail_mail.py index f7731538310..6e5a3697cd8 100644 --- a/addons/mail/models/mail_mail.py +++ b/addons/mail/models/mail_mail.py @@ -36,10 +36,12 @@ class MailMail(models.Model): # Auto-detected based on create() - if 'mail_message_id' was passed then this mail is a notification # and during unlink() we will not cascade delete the parent and its attachments notification = fields.Boolean('Is Notification', help='Mail has been created to notify people of an existing mail.message') - # recipients + # recipients: include inactive partners (they may have been archived after + # the message was sent, but they should remain visible in the relation) email_to = fields.Text('To', help='Message recipients (emails)') email_cc = fields.Char('Cc', help='Carbon copy message recipients') - recipient_ids = fields.Many2many('res.partner', string='To (Partners)') + recipient_ids = fields.Many2many('res.partner', string='To (Partners)', + context={'active_test': False}) # process state = fields.Selection([ ('outgoing', 'Outgoing'), diff --git a/addons/mail/models/mail_message.py b/addons/mail/models/mail_message.py index e7d67a8c098..45bcb9498c5 100644 --- a/addons/mail/models/mail_message.py +++ b/addons/mail/models/mail_message.py @@ -77,10 +77,13 @@ class Message(models.Model): ondelete='set null', default=_get_default_author, help="Author of the message. If not set, email_from may hold an email address that did not match any partner.") author_avatar = fields.Binary("Author's avatar", related='author_id.image_small') - # recipients - partner_ids = fields.Many2many('res.partner', string='Recipients') + # recipients: include inactive partners (they may have been archived after + # the message was sent, but they should remain visible in the relation) + partner_ids = fields.Many2many('res.partner', string='Recipients', + context={'active_test': False}) needaction_partner_ids = fields.Many2many( - 'res.partner', 'mail_message_res_partner_needaction_rel', string='Partners with Need Action') + 'res.partner', 'mail_message_res_partner_needaction_rel', string='Partners with Need Action', + context={'active_test': False}) needaction = fields.Boolean( 'Need Action', compute='_get_needaction', search='_search_needaction', help='Need Action') diff --git a/addons/mail_bot/data/mailbot_demo.xml b/addons/mail_bot/data/mailbot_demo.xml index c5d68ad7a60..cbc11715265 100644 --- a/addons/mail_bot/data/mailbot_demo.xml +++ b/addons/mail_bot/data/mailbot_demo.xml @@ -2,7 +2,7 @@ - + disabled diff --git a/addons/mass_mailing/security/mass_mailing_security.xml b/addons/mass_mailing/security/mass_mailing_security.xml index 308e02956ef..64b28137d2b 100644 --- a/addons/mass_mailing/security/mass_mailing_security.xml +++ b/addons/mass_mailing/security/mass_mailing_security.xml @@ -3,7 +3,7 @@ User - + diff --git a/addons/mrp/security/mrp_security.xml b/addons/mrp/security/mrp_security.xml index d203cfc73c1..a71565130a7 100644 --- a/addons/mrp/security/mrp_security.xml +++ b/addons/mrp/security/mrp_security.xml @@ -11,7 +11,7 @@ Manager - + diff --git a/addons/point_of_sale/security/point_of_sale_security.xml b/addons/point_of_sale/security/point_of_sale_security.xml index f29a37cfcfd..308a885c3a9 100644 --- a/addons/point_of_sale/security/point_of_sale_security.xml +++ b/addons/point_of_sale/security/point_of_sale_security.xml @@ -8,7 +8,7 @@ Manager - + diff --git a/addons/point_of_sale/tests/test_frontend.py b/addons/point_of_sale/tests/test_frontend.py index d9c0584ca59..6f604e13451 100644 --- a/addons/point_of_sale/tests/test_frontend.py +++ b/addons/point_of_sale/tests/test_frontend.py @@ -10,7 +10,7 @@ import odoo.tests class TestUi(odoo.tests.HttpCase): def test_01_pos_basic_order(self): - env = self.env + env = self.env(user=self.env.ref('base.user_admin')) journal_obj = env['account.journal'] account_obj = env['account.account'] diff --git a/addons/project/security/project_security.xml b/addons/project/security/project_security.xml index a34f32e7393..f064bd6ba86 100644 --- a/addons/project/security/project_security.xml +++ b/addons/project/security/project_security.xml @@ -11,7 +11,7 @@ Manager - + diff --git a/addons/purchase/security/purchase_security.xml b/addons/purchase/security/purchase_security.xml index c8565685486..26fbbf5d8c9 100644 --- a/addons/purchase/security/purchase_security.xml +++ b/addons/purchase/security/purchase_security.xml @@ -12,7 +12,7 @@ Manager - + diff --git a/addons/sale/security/sale_security.xml b/addons/sale/security/sale_security.xml index 9d62a1a2b2a..6c5134c0b9f 100644 --- a/addons/sale/security/sale_security.xml +++ b/addons/sale/security/sale_security.xml @@ -26,6 +26,10 @@ + + + + diff --git a/addons/sale_timesheet/data/sale_service_demo.xml b/addons/sale_timesheet/data/sale_service_demo.xml index 65d34a59f48..0f4fa2dcf9b 100644 --- a/addons/sale_timesheet/data/sale_service_demo.xml +++ b/addons/sale_timesheet/data/sale_service_demo.xml @@ -104,13 +104,13 @@ - + 100 75 - + @@ -186,7 +186,7 @@ Design - + 5.00 @@ -194,7 +194,7 @@ Fine tuning - + 5.00 @@ -202,7 +202,7 @@ Assembling - + 5.00 @@ -210,7 +210,7 @@ Delivery - + 5.00 @@ -219,7 +219,7 @@ Requirements analysis - + 1.00 @@ -227,7 +227,7 @@ Client meeting - + 1.00 @@ -251,7 +251,7 @@ Building - + 1.00 @@ -259,7 +259,7 @@ Research - + 1.00 @@ -267,7 +267,7 @@ Assembling - + 1.00 @@ -291,7 +291,7 @@ Wood chopping - + 1.00 @@ -342,7 +342,7 @@ Document analysis - + 4.00 @@ -350,7 +350,7 @@ Design analysis - + 4.00 @@ -368,7 +368,7 @@ Technical training - + 8.00 @@ -376,7 +376,7 @@ Internal training - + 8.00 @@ -384,7 +384,7 @@ Internal discussion - + 8.00 diff --git a/addons/sales_team/data/sales_team_data.xml b/addons/sales_team/data/sales_team_data.xml index 2af8a2f7992..133233e2963 100644 --- a/addons/sales_team/data/sales_team_data.xml +++ b/addons/sales_team/data/sales_team_data.xml @@ -3,7 +3,7 @@ Sales - + diff --git a/addons/sales_team/security/sales_team_security.xml b/addons/sales_team/security/sales_team_security.xml index 43571985b26..0633f75c0c0 100644 --- a/addons/sales_team/security/sales_team_security.xml +++ b/addons/sales_team/security/sales_team_security.xml @@ -19,7 +19,7 @@ the user will have an access to the sales configuration as well as statistic reports. - + diff --git a/addons/stock/security/stock_security.xml b/addons/stock/security/stock_security.xml index 30ac02a45fc..f1ea0759215 100644 --- a/addons/stock/security/stock_security.xml +++ b/addons/stock/security/stock_security.xml @@ -19,7 +19,7 @@ Manager - + diff --git a/addons/survey/security/survey_security.xml b/addons/survey/security/survey_security.xml index 13412fd37a5..5d79c515d26 100644 --- a/addons/survey/security/survey_security.xml +++ b/addons/survey/security/survey_security.xml @@ -12,7 +12,7 @@ Manager - + diff --git a/addons/test_mail/tests/common.py b/addons/test_mail/tests/common.py index c7b2e4af8e3..09f81fda7d7 100644 --- a/addons/test_mail/tests/common.py +++ b/addons/test_mail/tests/common.py @@ -31,8 +31,8 @@ class BaseFunctionalTest(common.SavepointCase): 'notification_type': 'email', 'groups_id': [(6, 0, [user_group_employee.id])]}) cls.partner_employee = cls.user_employee.partner_id - cls.user_admin = cls.env.user - cls.partner_admin = cls.user_admin.partner_id + cls.user_admin = cls.env.ref('base.user_admin') + cls.partner_admin = cls.env.ref('base.partner_admin') cls.channel_listen = cls.env['mail.channel'].with_context(cls._quick_create_ctx).create({'name': 'Listener'}) diff --git a/addons/test_mail/tests/test_discuss.py b/addons/test_mail/tests/test_discuss.py index 3a3cb21d043..907f95be0e7 100644 --- a/addons/test_mail/tests/test_discuss.py +++ b/addons/test_mail/tests/test_discuss.py @@ -119,7 +119,7 @@ class TestNotifications(BaseFunctionalTest, MockEmails): message.sudo(user_portal).set_message_done() def test_set_star(self): - msg = self.test_record.message_post(body='My Body', subject='1') + msg = self.test_record.sudo(self.user_admin).message_post(body='My Body', subject='1') msg_emp = self.env['mail.message'].sudo(self.user_employee).browse(msg.id) # Admin set as starred diff --git a/addons/test_mail/tests/test_ir_actions.py b/addons/test_mail/tests/test_ir_actions.py index f54b07b18e0..36ff2a5094e 100644 --- a/addons/test_mail/tests/test_ir_actions.py +++ b/addons/test_mail/tests/test_ir_actions.py @@ -28,11 +28,11 @@ class TestServerActionsEmail(TestServerActionsBase): self.test_partner.message_unsubscribe(self.test_partner.message_partner_ids.ids) self.action.write({ 'state': 'followers', - 'partner_ids': [(4, self.env.ref('base.partner_root').id), (4, self.env.ref('base.partner_demo').id)], + 'partner_ids': [(4, self.env.ref('base.partner_admin').id), (4, self.env.ref('base.partner_demo').id)], 'channel_ids': [(4, self.env.ref('mail.channel_all_employees').id)] }) self.action.with_context(self.context).run() - self.assertEqual(self.test_partner.message_partner_ids, self.env.ref('base.partner_root') | self.env.ref('base.partner_demo')) + self.assertEqual(self.test_partner.message_partner_ids, self.env.ref('base.partner_admin') | self.env.ref('base.partner_demo')) self.assertEqual(self.test_partner.message_channel_ids, self.env.ref('mail.channel_all_employees')) def test_action_next_activity(self): diff --git a/addons/test_mail/tests/test_mail_followers.py b/addons/test_mail/tests/test_mail_followers.py index 20e94c288fd..06b0b183197 100644 --- a/addons/test_mail/tests/test_mail_followers.py +++ b/addons/test_mail/tests/test_mail_followers.py @@ -178,7 +178,6 @@ class AdvancedFollowersTest(common.BaseFunctionalTest): 'name': 'Test', 'user_id': self.user_admin.id, }) - self.assertEqual(sub.message_partner_ids, (self.user_employee.partner_id | self.user_admin.partner_id)) def test_auto_subscribe_defaults(self): diff --git a/addons/test_mail/tests/test_mail_resend.py b/addons/test_mail/tests/test_mail_resend.py index 21790062488..973212b8611 100644 --- a/addons/test_mail/tests/test_mail_resend.py +++ b/addons/test_mail/tests/test_mail_resend.py @@ -88,7 +88,7 @@ class TestMailResend(common.BaseFunctionalTest, common.MockEmails): def connect_failure(**kwargs): raise Exception with patch.object(IrMailServer, 'connect', side_effect=connect_failure): - message = self.test_record.sudo().message_post(partner_ids=self.partners.ids, subtype='mail.mt_comment', message_type='notification') + message = self.test_record.sudo(self.user_admin).message_post(partner_ids=self.partners.ids, subtype='mail.mt_comment', message_type='notification') self.assertBusMessage([self.partner_admin]) self.assertEmails(self.partner_admin, []) self.assertNotifStates(('exception', 'exception', 'exception', 'exception'), message) @@ -113,12 +113,12 @@ class TestMailResend(common.BaseFunctionalTest, common.MockEmails): def test_mail_send_no_failure(self): self.user1.write({"email": 'u1@example.com'}) self.partner1.write({"email": 'p1@example.com'}) - message = self.test_record.sudo().message_post(partner_ids=self.partners.ids, subtype='mail.mt_comment', message_type='notification') + message = self.test_record.sudo(self.user_admin).message_post(partner_ids=self.partners.ids, subtype='mail.mt_comment', message_type='notification') self.assertBusMessage([]) # one update for cancell @mute_logger('odoo.addons.mail.models.mail_mail') def test_remove_mail_become_canceled(self): - message = self.test_record.sudo().message_post(partner_ids=self.partners.ids, subtype='mail.mt_comment', message_type='notification') + message = self.test_record.sudo(self.user_admin).message_post(partner_ids=self.partners.ids, subtype='mail.mt_comment', message_type='notification') self.assertEmails(self.partner_admin, self.partners) self.assertBusMessage([self.partner_admin] * 2) # two failure sent on bus, one for each mail wizard = self.env['mail.resend.message'].with_context({'mail_message_to_resend': message.id}).create({}) @@ -132,7 +132,7 @@ class TestMailResend(common.BaseFunctionalTest, common.MockEmails): @mute_logger('odoo.addons.mail.models.mail_mail') def test_cancel_all(self): - message = self.test_record.sudo().message_post(partner_ids=self.partners.ids, subtype='mail.mt_comment', message_type='notification') + message = self.test_record.sudo(self.user_admin).message_post(partner_ids=self.partners.ids, subtype='mail.mt_comment', message_type='notification') self.assertNotifStates(('exception', 'sent', 'exception', 'sent'), message) self.assertBusMessage([self.partner_admin] * 2) wizard = self.env['mail.resend.message'].with_context({'mail_message_to_resend': message.id}).create({}) diff --git a/addons/test_mail/tests/test_performance.py b/addons/test_mail/tests/test_performance.py index 4320f89eaab..7b170ef2c31 100644 --- a/addons/test_mail/tests/test_performance.py +++ b/addons/test_mail/tests/test_performance.py @@ -26,14 +26,14 @@ class TestMailPerformance(TransactionCase): 'groups_id': [(6, 0, [self.env.ref('base.group_user').id])], }) - @users('admin', 'demo') + @users('__system__', 'demo') @warmup def test_read_mail(self): """ Read records inheriting from 'mail.thread'. """ records = self.env['test_performance.mail'].search([]) self.assertEqual(len(records), 5) - with self.assertQueryCount(admin=3, demo=3): + with self.assertQueryCount(__system__=3, demo=3): # without cache for record in records: record.partner_id.country_id.name @@ -48,27 +48,27 @@ class TestMailPerformance(TransactionCase): for record in records: record.value_pc - @users('admin', 'demo') + @users('__system__', 'demo') @warmup def test_write_mail(self): """ Write records inheriting from 'mail.thread' (no recomputation). """ records = self.env['test_performance.mail'].search([]) self.assertEqual(len(records), 5) - with self.assertQueryCount(admin=3, demo=3): # test_mail only: 3 - 3 + with self.assertQueryCount(__system__=3, demo=3): # test_mail only: 3 - 3 records.write({'name': 'X'}) - @users('admin', 'demo') + @users('__system__', 'demo') @warmup def test_write_mail_with_recomputation(self): """ Write records inheriting from 'mail.thread' (with recomputation). """ records = self.env['test_performance.mail'].search([]) self.assertEqual(len(records), 5) - with self.assertQueryCount(admin=5, demo=5): # test_mail only: 5 - 5 + with self.assertQueryCount(__system__=5, demo=5): # test_mail only: 5 - 5 records.write({'value': 42}) - @users('admin', 'demo') + @users('__system__', 'demo') @warmup def test_write_mail_with_tracking(self): """ Write records inheriting from 'mail.thread' (with field tracking). """ @@ -79,36 +79,36 @@ class TestMailPerformance(TransactionCase): 'partner_id': self.env.ref('base.res_partner_12').id, }) - with self.assertQueryCount(admin=5, demo=5): # test_mail only: 5 - 5 + with self.assertQueryCount(__system__=5, demo=5): # test_mail only: 5 - 5 record.track = 'X' - @users('admin', 'demo') + @users('__system__', 'demo') @warmup def test_create_mail(self): """ Create records inheriting from 'mail.thread' (without field tracking). """ model = self.env['test_performance.mail'] - with self.assertQueryCount(admin=3, demo=3): # test_mail only: 3 - 3 + with self.assertQueryCount(__system__=3, demo=3): # test_mail only: 3 - 3 model.with_context(tracking_disable=True).create({'name': 'X'}) - @users('admin', 'demo') + @users('__system__', 'demo') @warmup def test_create_mail_with_tracking(self): """ Create records inheriting from 'mail.thread' (with field tracking). """ - with self.assertQueryCount(admin=13, demo=13): # test_mail only: 13 - 13 + with self.assertQueryCount(__system__=13, demo=13): # test_mail only: 13 - 13 self.env['test_performance.mail'].create({'name': 'X'}) - @users('admin', 'emp') + @users('__system__', 'emp') @warmup def test_create_mail_simple(self): - with self.assertQueryCount(admin=8, emp=8): # test_mail only: 8 - 8 + with self.assertQueryCount(__system__=8, emp=8): # test_mail only: 8 - 8 self.env['mail.test.simple'].create({'name': 'Test'}) - @users('admin', 'emp') + @users('__system__', 'emp') @warmup def test_write_mail_simple(self): rec = self.env['mail.test.simple'].create({'name': 'Test'}) - with self.assertQueryCount(admin=1, emp=1): # test_mail only: 1 - 1 + with self.assertQueryCount(__system__=1, emp=1): # test_mail only: 1 - 1 rec.write({ 'name': 'Test2', 'email_from': 'test@test.com', @@ -149,15 +149,15 @@ class TestAdvMailPerformance(TransactionCase): # automatically follow activities, for backward compatibility concerning query count self.env.ref('mail.mt_activities').write({'default': True}) - @users('admin', 'emp') + @users('__system__', 'emp') @warmup def test_adv_activity(self): model = self.env['mail.test.activity'] - with self.assertQueryCount(admin=9, emp=8): # test_mail only: 8 - 8 + with self.assertQueryCount(__system__=9, emp=8): # test_mail only: 8 - 8 model.create({'name': 'Test'}) - @users('admin', 'emp') + @users('__system__', 'emp') @warmup @mute_logger('odoo.models.unlink') def test_adv_activity_full(self): @@ -166,7 +166,7 @@ class TestAdvMailPerformance(TransactionCase): 'default_res_model': 'mail.test.activity', }) - with self.assertQueryCount(admin=10, emp=15): # test_mail only: 9 - 13 + with self.assertQueryCount(__system__=10, emp=15): # test_mail only: 9 - 13 activity = MailActivity.create({ 'summary': 'Test Activity', 'res_id': record.id, @@ -176,16 +176,16 @@ class TestAdvMailPerformance(TransactionCase): #voip module read activity_type during create leading to one less query in enterprise on action_feedback category = activity.activity_type_id.category - with self.assertQueryCount(admin=26, emp=46): # test_mail only: 27 - 47 + with self.assertQueryCount(__system__=26, emp=46): # test_mail only: 27 - 47 activity.action_feedback(feedback='Zizisse Done !') - @users('admin', 'emp') + @users('__system__', 'emp') @warmup @mute_logger('odoo.models.unlink') def test_adv_activity_mixin(self): record = self.env['mail.test.activity'].create({'name': 'Test'}) - with self.assertQueryCount(admin=10, emp=15): # test_mail only: 9 - 13 + with self.assertQueryCount(__system__=10, emp=15): # test_mail only: 9 - 13 activity = record.action_start('Test Start') #read activity_type to normalize cache between enterprise and community #voip module read activity_type during create leading to one less query in enterprise on action_close @@ -193,60 +193,60 @@ class TestAdvMailPerformance(TransactionCase): record.write({'name': 'Dupe write'}) - with self.assertQueryCount(admin=28, emp=48): # test_mail only: 29 - 49 + with self.assertQueryCount(__system__=28, emp=48): # test_mail only: 29 - 49 record.action_close('Dupe feedback') self.assertEqual(record.activity_ids, self.env['mail.activity']) @mute_logger('odoo.addons.mail.models.mail_mail', 'odoo.models.unlink') - @users('admin', 'emp') + @users('__system__', 'emp') @warmup def test_message_assignation_email(self): self.user_test.write({'notification_type': 'email'}) record = self.env['mail.test.track'].create({'name': 'Test'}) - with self.assertQueryCount(admin=56, emp=75): # com runbot: 56 - 75 // test_mail only: 56 - 75 + with self.assertQueryCount(__system__=56, emp=75): # com runbot: 56 - 75 // test_mail only: 56 - 75 record.write({ 'user_id': self.user_test.id, }) - @users('admin', 'emp') + @users('__system__', 'emp') @warmup def test_message_assignation_inbox(self): record = self.env['mail.test.track'].create({'name': 'Test'}) - with self.assertQueryCount(admin=36, emp=47): # test_mail only: 43 - 54 + with self.assertQueryCount(__system__=36, emp=47): # test_mail only: 43 - 54 record.write({ 'user_id': self.user_test.id, }) - @users('admin', 'emp') + @users('__system__', 'emp') @warmup def test_message_log(self): record = self.env['mail.test.simple'].create({'name': 'Test'}) - with self.assertQueryCount(admin=2, emp=2): # test_mail only: 2 - 2 + with self.assertQueryCount(__system__=2, emp=2): # test_mail only: 2 - 2 record._message_log( body='

Test _message_log

', message_type='comment') - @users('admin', 'emp') + @users('__system__', 'emp') @warmup def test_message_log_with_post(self): record = self.env['mail.test.simple'].create({'name': 'Test'}) - with self.assertQueryCount(admin=7, emp=13): # test_mail only: 7 - 13 + with self.assertQueryCount(__system__=7, emp=13): # test_mail only: 7 - 13 record.message_post( body='

Test message_post as log

', subtype='mail.mt_note', message_type='comment') - @users('admin', 'emp') + @users('__system__', 'emp') @warmup def test_message_post_no_notification(self): record = self.env['mail.test.simple'].create({'name': 'Test'}) - with self.assertQueryCount(admin=7, emp=13): # test_mail only: 7 - 13 + with self.assertQueryCount(__system__=7, emp=13): # test_mail only: 7 - 13 record.message_post( body='

Test Post Performances basic

', partner_ids=[], @@ -254,24 +254,24 @@ class TestAdvMailPerformance(TransactionCase): subtype='mail.mt_comment') @mute_logger('odoo.addons.mail.models.mail_mail', 'odoo.models.unlink') - @users('admin', 'emp') + @users('__system__', 'emp') @warmup def test_message_post_one_email_notification(self): record = self.env['mail.test.simple'].create({'name': 'Test'}) - with self.assertQueryCount(admin=48, emp=68): # com runbot: 45 - 65 // test_mail only: 48 - 68 + with self.assertQueryCount(__system__=48, emp=68): # com runbot: 45 - 65 // test_mail only: 48 - 68 record.message_post( body='

Test Post Performances with an email ping

', partner_ids=self.customer.ids, message_type='comment', subtype='mail.mt_comment') - @users('admin', 'emp') + @users('__system__', 'emp') @warmup def test_message_post_one_inbox_notification(self): record = self.env['mail.test.simple'].create({'name': 'Test'}) - with self.assertQueryCount(admin=31, emp=42): # com runbot 30 - 41 // test_mail only: 31 - 42 + with self.assertQueryCount(__system__=31, emp=42): # com runbot 30 - 41 // test_mail only: 31 - 42 record.message_post( body='

Test Post Performances with an inbox ping

', partner_ids=self.user_test.partner_id.ids, @@ -279,28 +279,28 @@ class TestAdvMailPerformance(TransactionCase): subtype='mail.mt_comment') @mute_logger('odoo.models.unlink') - @users('admin', 'emp') + @users('__system__', 'emp') @warmup def test_message_subscribe_default(self): record = self.env['mail.test.simple'].create({'name': 'Test'}) - with self.assertQueryCount(admin=7, emp=7): # test_mail only: 6 - 6 + with self.assertQueryCount(__system__=7, emp=7): # test_mail only: 6 - 6 record.message_subscribe(partner_ids=self.user_test.partner_id.ids) - with self.assertQueryCount(admin=3, emp=3): # test_mail only: 2 - 2 + with self.assertQueryCount(__system__=3, emp=3): # test_mail only: 2 - 2 record.message_subscribe(partner_ids=self.user_test.partner_id.ids) @mute_logger('odoo.models.unlink') - @users('admin', 'emp') + @users('__system__', 'emp') @warmup def test_message_subscribe_subtypes(self): record = self.env['mail.test.simple'].create({'name': 'Test'}) subtype_ids = (self.env.ref('test_mail.st_mail_test_simple_external') | self.env.ref('mail.mt_comment')).ids - with self.assertQueryCount(admin=6, emp=6): # test_mail only: 5 - 5 + with self.assertQueryCount(__system__=6, emp=6): # test_mail only: 5 - 5 record.message_subscribe(partner_ids=self.user_test.partner_id.ids, subtype_ids=subtype_ids) - with self.assertQueryCount(admin=2, emp=2): # test_mail only: 1 - 1 + with self.assertQueryCount(__system__=2, emp=2): # test_mail only: 1 - 1 record.message_subscribe(partner_ids=self.user_test.partner_id.ids, subtype_ids=subtype_ids) @@ -333,7 +333,6 @@ class TestHeavyMailPerformance(TransactionCase): }) self.admin = self.env.user - self.admin.login = 'admin' # setup mail gateway self.env['ir.config_parameter'].sudo().set_param('mail.catchall.domain', 'example.com') @@ -364,7 +363,7 @@ class TestHeavyMailPerformance(TransactionCase): ) @mute_logger('odoo.tests', 'odoo.addons.mail.models.mail_mail', 'odoo.models.unlink') - @users('admin', 'emp') + @users('__system__', 'emp') @warmup def test_complex_mail_mail_send(self): message = self.env['mail.message'].sudo().create({ @@ -382,20 +381,20 @@ class TestHeavyMailPerformance(TransactionCase): }) mail_ids = mail.ids - with self.assertQueryCount(admin=13, emp=20): # test_mail only: 13 - 20 + with self.assertQueryCount(__system__=13, emp=20): # test_mail only: 13 - 20 self.env['mail.mail'].browse(mail_ids).send() self.assertEqual(mail.body_html, '

Test

') self.assertEqual(mail.reply_to, formataddr(('%s %s' % (self.env.user.company_id.name, self.umbrella.name), 'test-alias@example.com'))) @mute_logger('odoo.tests', 'odoo.addons.mail.models.mail_mail', 'odoo.models.unlink') - @users('admin', 'emp') + @users('__system__', 'emp') @warmup def test_complex_message_post(self): self.umbrella.message_subscribe(self.user_portal.partner_id.ids) record = self.umbrella.sudo(self.env.user) - with self.assertQueryCount(admin=80, emp=103): # com runbot 90 - 113 // test_mail only: 97 - 120 + with self.assertQueryCount(__system__=80, emp=103): # com runbot 90 - 113 // test_mail only: 97 - 120 record.message_post( body='

Test Post Performances

', message_type='comment', @@ -405,21 +404,21 @@ class TestHeavyMailPerformance(TransactionCase): self.assertEqual(record.message_ids[0].needaction_partner_ids, self.partners | self.user_portal.partner_id) @mute_logger('odoo.tests', 'odoo.addons.mail.models.mail_mail', 'odoo.models.unlink') - @users('admin', 'emp') + @users('__system__', 'emp') @warmup def test_complex_message_post_template(self): self.umbrella.message_subscribe(self.user_portal.partner_id.ids) record = self.umbrella.sudo(self.env.user) template_id = self.env.ref('test_mail.mail_test_tpl').id - with self.assertQueryCount(admin=99, emp=134): # com runbot 109 - 144 // test_mail only: 116 - 151 + with self.assertQueryCount(__system__=99, emp=134): # com runbot 109 - 144 // test_mail only: 116 - 151 record.message_post_with_template(template_id, message_type='comment', composition_mode='comment') self.assertEqual(record.message_ids[0].body, '

Adding stuff on %s

' % record.name) self.assertEqual(record.message_ids[0].needaction_partner_ids, self.partners | self.user_portal.partner_id | self.customer) @mute_logger('odoo.tests', 'odoo.addons.mail.models.mail_mail', 'odoo.models.unlink') - @users('admin', 'emp') + @users('__system__', 'emp') @warmup def test_complex_message_subscribe(self): pids = self.partners.ids @@ -437,7 +436,7 @@ class TestHeavyMailPerformance(TransactionCase): self.assertEqual(rec.message_channel_ids, self.env['mail.channel']) # subscribe new followers with forced given subtypes - with self.assertQueryCount(admin=9, emp=9): # test_mail only: 8 - 8 + with self.assertQueryCount(__system__=9, emp=9): # test_mail only: 8 - 8 rec.message_subscribe( partner_ids=pids[:4], channel_ids=cids, @@ -448,7 +447,7 @@ class TestHeavyMailPerformance(TransactionCase): self.assertEqual(rec.message_channel_ids, self.channel) # subscribe existing and new followers with force=False, meaning only some new followers will be added - with self.assertQueryCount(admin=7, emp=7): # test_mail only: 6 - 6 + with self.assertQueryCount(__system__=7, emp=7): # test_mail only: 6 - 6 rec.message_subscribe( partner_ids=pids[:6], channel_ids=cids, @@ -459,7 +458,7 @@ class TestHeavyMailPerformance(TransactionCase): self.assertEqual(rec.message_channel_ids, self.channel) # subscribe existing and new followers with force=True, meaning all will have the same subtypes - with self.assertQueryCount(admin=8, emp=8): # test_mail only: 7 - 7 + with self.assertQueryCount(__system__=8, emp=8): # test_mail only: 7 - 7 rec.message_subscribe( partner_ids=pids, channel_ids=cids, @@ -470,7 +469,7 @@ class TestHeavyMailPerformance(TransactionCase): self.assertEqual(rec.message_channel_ids, self.channel) @mute_logger('odoo.tests', 'odoo.addons.mail.models.mail_mail', 'odoo.models.unlink') - @users('admin', 'emp') + @users('__system__', 'emp') @warmup def test_complex_tracking_assignation(self): """ Assignation performance test on already-created record """ @@ -482,7 +481,7 @@ class TestHeavyMailPerformance(TransactionCase): }) self.assertEqual(rec.message_partner_ids, self.partners | self.env.user.partner_id) - with self.assertQueryCount(admin=58, emp=77): # com runbot: 65 - 83 // test_mail only: 66 - 84 + with self.assertQueryCount(__system__=58, emp=77): # com runbot: 65 - 83 // test_mail only: 66 - 84 rec.write({'user_id': self.user_portal.id}) self.assertEqual(rec.message_partner_ids, self.partners | self.env.user.partner_id | self.user_portal.partner_id) @@ -497,7 +496,7 @@ class TestHeavyMailPerformance(TransactionCase): self.assertEqual(rec.message_ids[2].needaction_partner_ids, self.env['res.partner']) @mute_logger('odoo.tests', 'odoo.addons.mail.models.mail_mail', 'odoo.models.unlink') - @users('admin', 'emp') + @users('__system__', 'emp') @warmup def test_complex_tracking_subscription_create(self): """ Creation performance test involving auto subscription, assignation, tracking with subtype and template send. """ @@ -505,7 +504,7 @@ class TestHeavyMailPerformance(TransactionCase): customer_id = self.customer.id user_id = self.user_portal.id - with self.assertQueryCount(admin=155, emp=190): # com runbot: 155 - 190 // test_mail only: 155 - 190 + with self.assertQueryCount(__system__=155, emp=190): # com runbot: 155 - 190 // test_mail only: 155 - 190 rec = self.env['mail.test.full'].create({ 'name': 'Test', 'umbrella_id': umbrella_id, @@ -522,7 +521,7 @@ class TestHeavyMailPerformance(TransactionCase): self.assertEqual(rec.message_ids[1].needaction_partner_ids, self.env['res.partner']) @mute_logger('odoo.tests', 'odoo.addons.mail.models.mail_mail', 'odoo.models.unlink') - @users('admin', 'emp') + @users('__system__', 'emp') @warmup def test_complex_tracking_subscription_subtype(self): """ Write performance test involving auto subscription, tracking with subtype """ @@ -534,7 +533,7 @@ class TestHeavyMailPerformance(TransactionCase): }) self.assertEqual(rec.message_partner_ids, self.user_portal.partner_id | self.env.user.partner_id) - with self.assertQueryCount(admin=94, emp=111): # com runbot: 104 - 123 // test_mail only: 105 - 124 + with self.assertQueryCount(__system__=94, emp=111): # com runbot: 104 - 123 // test_mail only: 105 - 124 rec.write({ 'name': 'Test2', 'umbrella_id': self.umbrella.id, @@ -552,7 +551,7 @@ class TestHeavyMailPerformance(TransactionCase): self.assertEqual(rec.message_ids[2].needaction_partner_ids, self.env['res.partner']) @mute_logger('odoo.tests', 'odoo.addons.mail.models.mail_mail', 'odoo.models.unlink') - @users('admin', 'emp') + @users('__system__', 'emp') @warmup def test_complex_tracking_subscription_write(self): """ Write performance test involving auto subscription, tracking with subtype and template send """ @@ -572,7 +571,7 @@ class TestHeavyMailPerformance(TransactionCase): }) self.assertEqual(rec.message_partner_ids, self.user_portal.partner_id | self.env.user.partner_id) - with self.assertQueryCount(admin=100, emp=122): # test_mail only: 111 - 134 + with self.assertQueryCount(__system__=100, emp=122): # test_mail only: 111 - 134 rec.write({ 'name': 'Test2', 'umbrella_id': umbrella_id, @@ -591,7 +590,7 @@ class TestHeavyMailPerformance(TransactionCase): self.assertEqual(rec.message_ids[2].needaction_partner_ids, self.env['res.partner']) @mute_logger('odoo.tests', 'odoo.addons.mail.models.mail_mail', 'odoo.models.unlink') - @users('admin', 'emp') + @users('__system__', 'emp') @warmup def test_complex_tracking_template(self): """ Write performance test involving assignation, tracking with template """ @@ -606,7 +605,7 @@ class TestHeavyMailPerformance(TransactionCase): }) self.assertEqual(rec.message_partner_ids, self.partners | self.env.user.partner_id | self.user_portal.partner_id) - with self.assertQueryCount(admin=54, emp=76): # test_mail only: 54 - 75 + with self.assertQueryCount(__system__=54, emp=76): # test_mail only: 54 - 75 rec.write({ 'name': 'Test2', 'customer_id': customer_id, diff --git a/addons/website/security/website_security.xml b/addons/website/security/website_security.xml index 6702d0878f1..3be09426270 100644 --- a/addons/website/security/website_security.xml +++ b/addons/website/security/website_security.xml @@ -6,7 +6,7 @@
Editor and Designer - + @@ -14,6 +14,10 @@ + + + + diff --git a/addons/website_forum/data/forum_data.xml b/addons/website_forum/data/forum_data.xml index f4073cd71ab..60928475354 100644 --- a/addons/website_forum/data/forum_data.xml +++ b/addons/website_forum/data/forum_data.xml @@ -26,6 +26,9 @@ 2500 + + 2500 + diff --git a/addons/website_hr/data/hr_employee_demo.xml b/addons/website_hr/data/hr_employee_demo.xml index 5546a47dfe4..5ed2473dd3a 100644 --- a/addons/website_hr/data/hr_employee_demo.xml +++ b/addons/website_hr/data/hr_employee_demo.xml @@ -6,7 +6,7 @@ Designer, UI Expert - + Lean Management Expert diff --git a/addons/website_sale_options/static/src/js/website_sale.test.js b/addons/website_sale_options/static/src/js/website_sale.test.js index ae6e4108647..b982178afc3 100644 --- a/addons/website_sale_options/static/src/js/website_sale.test.js +++ b/addons/website_sale_options/static/src/js/website_sale.test.js @@ -4,6 +4,7 @@ odoo.define('website_sale.test', function (require) { require("website_sale.tour"); var tour = require("web_tour.tour"); var base = require("web_editor.base"); +var ajax = require('web.ajax'); var steps = tour.tours.shop_buy_product.steps; for (var k=0; k a', - extra_trigger: 'body:not(.notReady)', - }, - { - content: "check page loaded after enable variant group", - trigger: '#customize-menu a:contains(List View of Variants)', - run: function () {}, // it's a check + extra_trigger: "#product_detail", }, { content: "click on 'List View of Variants'", diff --git a/addons/website_sale_options/tests/test_customize.py b/addons/website_sale_options/tests/test_customize.py index e387c068a0b..5a397dbba54 100644 --- a/addons/website_sale_options/tests/test_customize.py +++ b/addons/website_sale_options/tests/test_customize.py @@ -6,4 +6,8 @@ import odoo.tests class TestUi(odoo.tests.HttpCase): def test_01_admin_shop_customize_tour(self): + self.env.ref('product.group_product_variant').write({ + 'users': [(4, self.env.ref('base.user_admin').id)] + }) + self.phantom_js("/", "odoo.__DEBUG__.services['web_tour.tour'].run('shop_customize')", "odoo.__DEBUG__.services['web_tour.tour'].tours.shop_customize.ready", login="admin") diff --git a/odoo/addons/base/data/base_data.sql b/odoo/addons/base/data/base_data.sql index 760205e3a89..58bdd7d3062 100644 --- a/odoo/addons/base/data/base_data.sql +++ b/odoo/addons/base/data/base_data.sql @@ -126,20 +126,20 @@ CREATE TABLE res_partner ( --------------------------------- insert into res_currency (id, name, symbol) VALUES (1, 'EUR', '€'); insert into ir_model_data (name, module, model, noupdate, res_id) VALUES ('EUR', 'base', 'res.currency', true, 1); -select setval('res_currency_id_seq', 2); +select setval('res_currency_id_seq', 1); insert into res_company (id, name, partner_id, currency_id, create_date) VALUES (1, 'My Company', 1, 1, now() at time zone 'UTC'); insert into ir_model_data (name, module, model, noupdate, res_id) VALUES ('main_company', 'base', 'res.company', true, 1); -select setval('res_company_id_seq', 2); +select setval('res_company_id_seq', 1); insert into res_partner (id, name, company_id, create_date) VALUES (1, 'My Company', 1, now() at time zone 'UTC'); insert into ir_model_data (name, module, model, noupdate, res_id) VALUES ('main_partner', 'base', 'res.partner', true, 1); -select setval('res_partner_id_seq', 2); +select setval('res_partner_id_seq', 1); -insert into res_users (id, login, password, active, partner_id, company_id, create_date) VALUES (1, 'admin', 'admin', true, 1, 1, now() at time zone 'UTC'); +insert into res_users (id, login, password, active, partner_id, company_id, create_date) VALUES (1, '__system__', NULL, false, 1, 1, now() at time zone 'UTC'); insert into ir_model_data (name, module, model, noupdate, res_id) VALUES ('user_root', 'base', 'res.users', true, 1); -select setval('res_users_id_seq', 2); +select setval('res_users_id_seq', 1); insert into res_groups (id, name) VALUES (1, 'Employee'); insert into ir_model_data (name, module, model, noupdate, res_id) VALUES ('group_user', 'base', 'res.groups', true, 1); -select setval('res_groups_id_seq', 2); +select setval('res_groups_id_seq', 1); diff --git a/odoo/addons/base/data/res_partner_data.xml b/odoo/addons/base/data/res_partner_data.xml index f83a9dceab4..41872a10fa0 100644 --- a/odoo/addons/base/data/res_partner_data.xml +++ b/odoo/addons/base/data/res_partner_data.xml @@ -16,6 +16,13 @@ + System + + + + + + Administrator diff --git a/odoo/addons/base/data/res_users_data.xml b/odoo/addons/base/data/res_users_data.xml index 70482bf1893..b28572009ce 100644 --- a/odoo/addons/base/data/res_users_data.xml +++ b/odoo/addons/base/data/res_users_data.xml @@ -1,11 +1,24 @@ + --
+System]]>
+
+ + + + admin + admin + + + + + --
Administrator]]>
diff --git a/odoo/addons/base/data/res_users_demo.xml b/odoo/addons/base/data/res_users_demo.xml index faee5b8f40b..38d6323ee28 100644 --- a/odoo/addons/base/data/res_users_demo.xml +++ b/odoo/addons/base/data/res_users_demo.xml @@ -40,6 +40,11 @@
+ root@yourcompany.example.com + Europe/Brussels + + + Mitchell Stephens YourCompany 215 Vine St diff --git a/odoo/addons/base/models/res_partner.py b/odoo/addons/base/models/res_partner.py index a423af7835d..932c6d49167 100644 --- a/odoo/addons/base/models/res_partner.py +++ b/odoo/addons/base/models/res_partner.py @@ -208,7 +208,7 @@ class Partner(models.Model): compute='_compute_company_type', inverse='_write_company_type') company_id = fields.Many2one('res.company', 'Company', index=True, default=_default_company) color = fields.Integer(string='Color Index', default=0) - user_ids = fields.One2many('res.users', 'partner_id', string='Users', auto_join=True) + user_ids = fields.One2many('res.users', 'partner_id', string='Users', auto_join=True, context={'active_test': False}) partner_share = fields.Boolean( 'Share Partner', compute='_compute_partner_share', store=True, help="Either customer (not a user), either shared user. Indicated the current partner is a customer without " @@ -240,13 +240,6 @@ class Partner(models.Model): ('check_name', "CHECK( (type='contact' AND name IS NOT NULL) or (type!='contact') )", 'Contacts require a name.'), ] - @api.multi - def toggle_active(self): - for partner in self: - if partner.active and partner.user_ids: - raise ValidationError(_('You cannot archive a contact linked to an internal user.')) - super(Partner, self).toggle_active() - @api.depends('is_company', 'name', 'parent_id.name', 'type', 'company_name') def _compute_display_name(self): diff = dict(show_address=None, show_address_only=None, show_email=None) @@ -506,7 +499,7 @@ class Partner(models.Model): def write(self, vals): if vals.get('active') is False: for partner in self: - if partner.active and partner.user_ids: + if partner.active and any(partner.user_ids.mapped('active')): raise ValidationError(_('You cannot archive a contact linked to an internal user.')) # res.partner must only allow to set the company_id of a partner if it # is the same as the company of all users that inherit from this partner diff --git a/odoo/addons/base/security/base_groups.xml b/odoo/addons/base/security/base_groups.xml index a7e32bb1065..62889e5cbc9 100644 --- a/odoo/addons/base/security/base_groups.xml +++ b/odoo/addons/base/security/base_groups.xml @@ -14,7 +14,7 @@ Settings - + @@ -38,11 +38,12 @@ - + Contact Creation + @@ -89,4 +90,4 @@
- \ No newline at end of file + diff --git a/odoo/addons/base/tests/test_xmlrpc.py b/odoo/addons/base/tests/test_xmlrpc.py index 98ad2a473c1..09ec01adfbb 100644 --- a/odoo/addons/base/tests/test_xmlrpc.py +++ b/odoo/addons/base/tests/test_xmlrpc.py @@ -7,17 +7,21 @@ from odoo.tests import common @common.tagged('post_install', '-at_install') class TestXMLRPC(common.HttpCase): + def setUp(self): + super(TestXMLRPC, self).setUp() + self.admin_uid = self.env.ref('base.user_admin').id + def test_01_xmlrpc_login(self): """ Try to login on the common service. """ db_name = common.get_db_name() uid = self.xmlrpc_common.login(db_name, 'admin', 'admin') - self.assertEqual(uid, 1) + self.assertEqual(uid, self.admin_uid) def test_xmlrpc_ir_model_search(self): """ Try a search on the object service. """ o = self.xmlrpc_object db_name = common.get_db_name() - ids = o.execute(db_name, 1, 'admin', 'ir.model', 'search', []) + ids = o.execute(db_name, self.admin_uid, 'admin', 'ir.model', 'search', []) self.assertIsInstance(ids, list) - ids = o.execute(db_name, 1, 'admin', 'ir.model', 'search', [], {}) + ids = o.execute(db_name, self.admin_uid, 'admin', 'ir.model', 'search', [], {}) self.assertIsInstance(ids, list) diff --git a/odoo/addons/test_new_api/models.py b/odoo/addons/test_new_api/models.py index eb1c6532814..39467d102e8 100644 --- a/odoo/addons/test_new_api/models.py +++ b/odoo/addons/test_new_api/models.py @@ -71,7 +71,7 @@ class Discussion(models.Model): moderator = fields.Many2one('res.users') categories = fields.Many2many('test_new_api.category', 'test_new_api_discussion_category', 'discussion', 'category') - participants = fields.Many2many('res.users') + participants = fields.Many2many('res.users', context={'active_test': False}) messages = fields.One2many('test_new_api.message', 'discussion') message_concat = fields.Text(string='Message concatenate') important_messages = fields.One2many('test_new_api.message', 'discussion', diff --git a/odoo/addons/test_new_api/tests/test_onchange.py b/odoo/addons/test_new_api/tests/test_onchange.py index f1d39aa53be..fb97f8b8e41 100644 --- a/odoo/addons/test_new_api/tests/test_onchange.py +++ b/odoo/addons/test_new_api/tests/test_onchange.py @@ -451,7 +451,7 @@ class TestOnChange(common.TransactionCase): onchange_result = { 'message_name': 'Hey dude!', - 'message_currency': (1, 'Mitchell Stephens') + 'message_currency': self.env.user.name_get()[0], } self.env.cache.invalidate() diff --git a/odoo/addons/test_performance/tests/test_performance.py b/odoo/addons/test_performance/tests/test_performance.py index a4e7b0481c2..f77aa05004c 100644 --- a/odoo/addons/test_performance/tests/test_performance.py +++ b/odoo/addons/test_performance/tests/test_performance.py @@ -10,14 +10,14 @@ from odoo.tools import pycompat class TestPerformance(TransactionCase): - @users('admin', 'demo') + @users('__system__', 'demo') @warmup def test_read_base(self): """ Read records. """ records = self.env['test_performance.base'].search([]) self.assertEqual(len(records), 5) - with self.assertQueryCount(admin=3, demo=3): + with self.assertQueryCount(__system__=3, demo=3): # without cache for record in records: record.partner_id.country_id.name @@ -32,54 +32,54 @@ class TestPerformance(TransactionCase): for record in records: record.value_pc - @users('admin', 'demo') + @users('__system__', 'demo') @warmup def test_write_base(self): """ Write records (no recomputation). """ records = self.env['test_performance.base'].search([]) self.assertEqual(len(records), 5) - with self.assertQueryCount(admin=1, demo=1): + with self.assertQueryCount(__system__=1, demo=1): records.write({'name': 'X'}) - @users('admin', 'demo') + @users('__system__', 'demo') @warmup def test_write_base_with_recomputation(self): """ Write records (with recomputation). """ records = self.env['test_performance.base'].search([]) self.assertEqual(len(records), 5) - with self.assertQueryCount(admin=3, demo=3): + with self.assertQueryCount(__system__=3, demo=3): records.write({'value': 42}) - @users('admin', 'demo') + @users('__system__', 'demo') @warmup def test_create_base(self): """ Create records. """ - with self.assertQueryCount(admin=6, demo=6): + with self.assertQueryCount(__system__=6, demo=6): self.env['test_performance.base'].create({'name': 'X'}) - @users('admin', 'demo') + @users('__system__', 'demo') @warmup def test_create_base_with_lines(self): """ Create records with one2many lines. """ - with self.assertQueryCount(admin=20, demo=20): + with self.assertQueryCount(__system__=20, demo=20): self.env['test_performance.base'].create({ 'name': 'X', 'line_ids': [(0, 0, {'value': val}) for val in range(10)], }) - @users('admin', 'demo') + @users('__system__', 'demo') @warmup def test_create_base_with_tags(self): """ Create records with many2many tags. """ - with self.assertQueryCount(admin=17, demo=17): + with self.assertQueryCount(__system__=17, demo=17): self.env['test_performance.base'].create({ 'name': 'X', 'tag_ids': [(0, 0, {'name': val}) for val in range(10)], }) - @users('admin', 'demo') + @users('__system__', 'demo') @warmup def test_several_prefetch(self): initial_records = self.env['test_performance.base'].search([]) @@ -91,11 +91,11 @@ class TestPerformance(TransactionCase): records = self.env['test_performance.base'].search([]) self.assertEqual(len(records), 1280) # should only cause 2 queries thanks to prefetching - with self.assertQueryCount(admin=2, demo=2): + with self.assertQueryCount(__system__=2, demo=2): records.mapped('value') records.invalidate_cache(['value']) - with self.assertQueryCount(admin=2, demo=2): + with self.assertQueryCount(__system__=2, demo=2): with self.env.do_in_onchange(): records.mapped('value') self.env.cr.execute( @@ -115,22 +115,22 @@ class TestPerformance(TransactionCase): 'value': sum(groups[partner.id]), } for partner in partners] - @users('admin', 'demo') + @users('__system__', 'demo') def test_read_group_with_name_get(self): model = self.env['test_performance.base'] expected = self.expected_read_group() # use read_group and check the expected result - with self.assertQueryCount(admin=2, demo=2): + with self.assertQueryCount(__system__=2, demo=2): model.invalidate_cache() result = model.read_group([], ['partner_id', 'value'], ['partner_id']) self.assertEqual(result, expected) - @users('admin', 'demo') + @users('__system__', 'demo') def test_read_group_without_name_get(self): model = self.env['test_performance.base'] expected = self.expected_read_group() # use read_group and check the expected result - with self.assertQueryCount(admin=1, demo=1): + with self.assertQueryCount(__system__=1, demo=1): model.invalidate_cache() result = model.read_group([], ['partner_id', 'value'], ['partner_id']) self.assertEqual(len(result), len(expected)) @@ -140,5 +140,5 @@ class TestPerformance(TransactionCase): self.assertEqual(res['partner_id_count'], exp['partner_id_count']) self.assertEqual(res['value'], exp['value']) # now serialize to json, which should force evaluation - with self.assertQueryCount(admin=1, demo=1): + with self.assertQueryCount(__system__=1, demo=1): json.dumps(result) diff --git a/odoo/tests/common.py b/odoo/tests/common.py index 770e2e9c0d1..bb52cec0368 100644 --- a/odoo/tests/common.py +++ b/odoo/tests/common.py @@ -856,9 +856,10 @@ def users(*logins): old_uid = self.uid try: # retrieve users + Users = self.env['res.users'].with_context(active_test=False) user_id = { user.login: user.id - for user in self.env['res.users'].search([('login', 'in', list(logins))]) + for user in Users.search([('login', 'in', list(logins))]) } for login in logins: with self.subTest(login=login):