[REM] crm: ACL which hasn't been useful in a while
Only the group_salesman can see the opportunities statbuttons Fix a few not-smart mass_mailing tests: - running the mass mailing queue processes the messages as the user running the queue, and will try to send the demo messages, depending on demo data (when re-running the tests) the test user may not have the accesses required; sending just the one test email avoids that issue - the leads kpi assumes the user has access to leads, that ain't necessarily the case For the second issue, when sending statistics if the mailing has a user `_prepare_statistics_email_values` should be called with that user as "current" (cf `_action_send_statistics`), so we can just work off of the current env, though it might be a good idea to eventually check that. closes odoo/odoo#89774 X-original-commit: 39af865800c6752b60171f16d6056ceb3c5a1636 Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
This commit is contained in:
@@ -7,7 +7,6 @@ access_res_partner_manager,res.partner.crm.manager,base.model_res_partner,sales_
|
||||
access_res_partner_category_manager,res.partner.category.crm.manager,base.model_res_partner_category,sales_team.group_sale_manager,1,0,0,0
|
||||
access_res_partner,res.partner.crm.user,base.model_res_partner,sales_team.group_sale_salesman,1,1,1,0
|
||||
access_res_partner_category,res.partner.category.crm.user,base.model_res_partner_category,sales_team.group_sale_salesman,1,1,1,0
|
||||
access_crm_lead_partner_manager,crm.lead.partner.manager,model_crm_lead,base.group_partner_manager,1,0,0,0
|
||||
access_crm_lost_reason_manager,crm.lost.reason.manager,model_crm_lost_reason,sales_team.group_sale_manager,1,1,1,1
|
||||
access_crm_lost_reason_salesman,crm.lost.reason.salesman,model_crm_lost_reason,sales_team.group_sale_salesman,1,0,0,0
|
||||
access_crm_lost_reason_user,crm.lost.reason.user,model_crm_lost_reason,base.group_user,1,0,0,0
|
||||
|
||||
|
@@ -50,6 +50,8 @@ class MassMailing(models.Model):
|
||||
values = super(MassMailing, self)._prepare_statistics_email_values()
|
||||
if not self.user_id:
|
||||
return values
|
||||
if not self.env['crm.lead'].check_access_rights('read', raise_exception=False):
|
||||
return values
|
||||
values['kpi_data'][1]['kpi_col1'] = {
|
||||
'value': tools.format_decimalized_number(self.crm_lead_count, decimal=0),
|
||||
'col_subtitle': _('LEADS'),
|
||||
|
||||
@@ -51,8 +51,8 @@ class TestAutoBlacklist(common.TestMassMailCommon):
|
||||
|
||||
@mute_logger('odoo.addons.mail.models.mail_thread')
|
||||
def _test_mailing_bounce_w_auto_bl(self, bounce_base_values):
|
||||
mailing = self.env['mailing.mailing'].browse(self.mailing_bl.ids)
|
||||
target = self.env['mailing.test.blacklist'].browse(self.target_rec.ids)
|
||||
mailing = self.mailing_bl.with_env(self.env)
|
||||
target = self.target_rec.with_env(self.env)
|
||||
|
||||
# create bounced history of 4 statistics
|
||||
traces = self.env['mailing.trace']
|
||||
@@ -66,9 +66,8 @@ class TestAutoBlacklist(common.TestMassMailCommon):
|
||||
self.gateway_mail_bounce(new_mailing, target, bounce_base_values)
|
||||
|
||||
# mass mail record: ok, not blacklisted yet
|
||||
mailing.action_put_in_queue()
|
||||
with self.mock_mail_gateway(mail_unlink_sent=False):
|
||||
mailing._process_mass_mailing_queue()
|
||||
mailing.action_send_mail()
|
||||
|
||||
self.assertMailTraces(
|
||||
[{'email': 'test.record.00@test.example.com'}],
|
||||
@@ -85,11 +84,9 @@ class TestAutoBlacklist(common.TestMassMailCommon):
|
||||
self.assertTrue(target.is_blacklisted)
|
||||
|
||||
# mass mail record: ko, blacklisted
|
||||
new_mailing = mailing.copy()
|
||||
new_mailing.write({'mailing_domain': [('id', 'in', target.ids)]})
|
||||
new_mailing.action_put_in_queue()
|
||||
new_mailing = mailing.copy({'mailing_domain': [('id', 'in', target.ids)]})
|
||||
with self.mock_mail_gateway(mail_unlink_sent=False):
|
||||
new_mailing._process_mass_mailing_queue()
|
||||
new_mailing.action_send_mail()
|
||||
self.assertMailTraces(
|
||||
[{'email': 'test.record.00@test.example.com', 'trace_status': 'cancel', 'failure_type': 'mail_bl'}],
|
||||
new_mailing, target, check_mail=True
|
||||
|
||||
@@ -82,9 +82,8 @@ class TestMassMailing(TestMassMailCommon):
|
||||
'mailing_model_id': self.env['ir.model']._get('mailing.test.optout'),
|
||||
'mailing_domain': [('id', 'in', recipients.ids)]
|
||||
})
|
||||
mailing.action_put_in_queue()
|
||||
with self.mock_mail_gateway(mail_unlink_sent=False):
|
||||
mailing._process_mass_mailing_queue()
|
||||
mailing.action_send_mail()
|
||||
|
||||
self.assertMailTraces(
|
||||
[{'email': record.email_normalized}
|
||||
@@ -201,9 +200,8 @@ class TestMassMailing(TestMassMailCommon):
|
||||
'campaign_id': campaign.id
|
||||
})
|
||||
|
||||
mailing.action_put_in_queue()
|
||||
with self.mock_mail_gateway(mail_unlink_sent=False):
|
||||
mailing._process_mass_mailing_queue()
|
||||
mailing.action_send_mail()
|
||||
|
||||
traces = self.env['mailing.trace'].search([('model', '=', self.mailing_list_1.contact_ids._name), ('res_id', 'in', self.mailing_list_1.contact_ids.ids)])
|
||||
self.assertEqual(len(traces), 3)
|
||||
@@ -237,9 +235,8 @@ class TestMassMailing(TestMassMailCommon):
|
||||
self.env['mail.blacklist'].flush(['active'])
|
||||
|
||||
mailing.write({'mailing_domain': [('id', 'in', recipients.ids)]})
|
||||
mailing.action_put_in_queue()
|
||||
with self.mock_mail_gateway(mail_unlink_sent=False):
|
||||
mailing._process_mass_mailing_queue()
|
||||
mailing.action_send_mail()
|
||||
|
||||
self.assertMailTraces(
|
||||
[{'email': 'test.record.00@test.example.com'},
|
||||
@@ -266,9 +263,8 @@ class TestMassMailing(TestMassMailCommon):
|
||||
'mailing_model_id': self.env['ir.model']._get('mailing.test.optout'),
|
||||
'mailing_domain': [('id', 'in', recipients.ids)]
|
||||
})
|
||||
mailing.action_put_in_queue()
|
||||
with self.mock_mail_gateway(mail_unlink_sent=False):
|
||||
mailing._process_mass_mailing_queue()
|
||||
mailing.action_send_mail()
|
||||
|
||||
self.assertMailTraces(
|
||||
[{'email': 'test.record.00@test.example.com', 'trace_status': 'cancel', 'failure_type': 'mail_optout'},
|
||||
@@ -326,9 +322,8 @@ class TestMassMailing(TestMassMailCommon):
|
||||
'mailing_model_id': self.env['ir.model']._get('mailing.list').id,
|
||||
'contact_list_ids': [(4, ml.id) for ml in mailing_list_1 | mailing_list_2],
|
||||
})
|
||||
mailing.action_put_in_queue()
|
||||
with self.mock_mail_gateway(mail_unlink_sent=False):
|
||||
mailing._process_mass_mailing_queue()
|
||||
mailing.action_send_mail()
|
||||
|
||||
self.assertMailTraces(
|
||||
[{'email': 'test@test.example.com', 'trace_status': 'sent'},
|
||||
|
||||
Reference in New Issue
Block a user