From 23a2bac3fa3aadc473e29adac376c614c983ec6b Mon Sep 17 00:00:00 2001 From: Nicolas Lempereur Date: Tue, 16 Jan 2018 14:14:54 +0100 Subject: [PATCH 1/4] [FIX] hr_equipment: no technician subscribe in 9.0 In 9.0, an "Human Resources / Employee" see only hr.equipment for which they are set as the "Employee". But the code automatically subscribed the "Technician" because the field name was named technically "user_id" which is automatically subscribed by the system. This led to a possible issue with read / unread message because of feature that just happen by coincidence. For 9.0 only (in 10.0 the field has been renamed technician_user_id and access rules have been changed). opw-805185 closes #22273 --- addons/hr_equipment/models/hr_equipment.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/addons/hr_equipment/models/hr_equipment.py b/addons/hr_equipment/models/hr_equipment.py index 0d48366224f..e542e4c50cd 100644 --- a/addons/hr_equipment/models/hr_equipment.py +++ b/addons/hr_equipment/models/hr_equipment.py @@ -182,6 +182,15 @@ class HrEquipment(models.Model): self.message_subscribe_users(user_ids=user_ids) return super(HrEquipment, self).write(vals) + @api.model + def _message_get_auto_subscribe_fields(self, updated_fields, auto_follow_fields=None): + """ mail.thread override so user_id which has no special access allowance is not + automatically subscribed. + """ + if auto_follow_fields is None: + auto_follow_fields = [] + return super(HrEquipment, self)._message_get_auto_subscribe_fields(updated_fields, auto_follow_fields) + @api.multi def _read_group_category_ids(self, domain, read_group_order=None, access_rights_uid=None): """ Read group customization in order to display all the category in the From 80f1d9ded6f88de509dc1ca80a5fd201281b0d1d Mon Sep 17 00:00:00 2001 From: Nicolas Lempereur Date: Tue, 16 Jan 2018 17:05:11 +0100 Subject: [PATCH 2/4] [FIX] mail: reduce no sudo effect mark_all_as_read The "Mark all read" button either set all messages as read, or if a domain is given, filter messages on it. But this filtering is also dependent on not doing sudo so odd notification to which we would somehow not have any access would never disappear in the unread number. Adding a sudo is risky, so this changeset just modify the test on domain since in most instance the domain is just an empty list (so: []). The added test before this change would fail at the last assert ("mark all read should conclude all needactions even inacessible ones"). opw-805185 closes #22277 --- addons/mail/models/mail_message.py | 2 +- addons/mail/tests/test_mail_features.py | 26 +++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/addons/mail/models/mail_message.py b/addons/mail/models/mail_message.py index 07079c57be0..f672e276adc 100644 --- a/addons/mail/models/mail_message.py +++ b/addons/mail/models/mail_message.py @@ -153,7 +153,7 @@ class Message(models.Model): """ Remove all needactions of the current partner. If channel_ids is given, restrict to messages written in one of those channels. """ partner_id = self.env.user.partner_id.id - if domain is None: + if not domain: query = "DELETE FROM mail_message_res_partner_needaction_rel WHERE res_partner_id IN %s" args = [(partner_id,)] if channel_ids: diff --git a/addons/mail/tests/test_mail_features.py b/addons/mail/tests/test_mail_features.py index 82dc2e05363..880c5f1ca47 100644 --- a/addons/mail/tests/test_mail_features.py +++ b/addons/mail/tests/test_mail_features.py @@ -48,6 +48,32 @@ class TestMailFeatures(TestMail): self.assertEqual(na_emp1_new, na_emp1_base + 1) self.assertEqual(na_emp2_new, na_emp2_base) + @mute_logger('openerp.addons.mail.models.mail_mail') + def test_mark_all_as_read(self): + portal_partner = self.user_portal.partner_id.sudo(self.user_portal.id) + + # mark all as read clear needactions + self.group_pigs.message_post(body='Test', message_type='comment', subtype='mail.mt_comment', partner_ids=[portal_partner.id]) + portal_partner.env['mail.message'].mark_all_as_read(channel_ids=[], domain=[]) + na_count = portal_partner.get_needaction_count() + self.assertEqual(na_count, 0, "mark all as read should conclude all needactions") + + # mark all as read also clear inaccessible needactions + new_msg = self.group_pigs.message_post(body='Zest', message_type='comment', subtype='mail.mt_comment', partner_ids=[portal_partner.id]) + needaction_accessible = len(portal_partner.env['mail.message'].search([['needaction', '=', True]])) + self.assertEqual(needaction_accessible, 1, "a new message to a partner is readable to that partner") + + new_msg.sudo().partner_ids = self.env['res.partner'] + needaction_length = len(portal_partner.env['mail.message'].search([['needaction', '=', True]])) + self.assertEqual(needaction_length, 0, "removing access of a message make it not readable") + + na_count = portal_partner.get_needaction_count() + self.assertEqual(na_count, 1, "message not accessible is currently still counted") + + portal_partner.env['mail.message'].mark_all_as_read(channel_ids=[], domain=[]) + na_count = portal_partner.get_needaction_count() + self.assertEqual(na_count, 0, "mark all read should conclude all needactions even inacessible ones") + class TestMessagePost(TestMail): From 128656f6ea56f200c7e7e0c8f80aa2bb11d7882c Mon Sep 17 00:00:00 2001 From: Christophe Matthieu Date: Wed, 17 Jan 2018 11:56:21 +0100 Subject: [PATCH 3/4] [FIX] website: space symbol is missing when compress html is enabled Issue: when the qWeb compress rendered HTML for a better Google PageSpeed result, some text fields are missing spacebar between fa icons and text, and between some fields. --- addons/website/models/ir_qweb.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/website/models/ir_qweb.py b/addons/website/models/ir_qweb.py index fcfb93b59c0..1ee0318624b 100644 --- a/addons/website/models/ir_qweb.py +++ b/addons/website/models/ir_qweb.py @@ -45,5 +45,5 @@ class QWeb(orm.AbstractModel): compress = request and not request.debug and getattr(request, 'website', None) and request.website.compress_html if compress and element.getparent().tag not in self.PRESERVE_WHITESPACE: # No need to recurse because those tags children are not html5 parser friendly - tail = self.re_remove_spaces.sub(' ', tail.rstrip()) + tail = self.re_remove_spaces.sub(' ', tail) return super(QWeb, self).render_tail(tail, element, qwebcontext) From 74b564cf8d1a192cee784997a6fb9da5b030c794 Mon Sep 17 00:00:00 2001 From: Jeremy Kersten Date: Fri, 12 Jan 2018 14:36:19 +0100 Subject: [PATCH 4/4] [FIX] website_slides: dont show upload button for public user This commit closes #15369 --- addons/website_slides/view/website_slides.xml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/addons/website_slides/view/website_slides.xml b/addons/website_slides/view/website_slides.xml index 6b21bba84c6..27c13cdf4df 100644 --- a/addons/website_slides/view/website_slides.xml +++ b/addons/website_slides/view/website_slides.xml @@ -112,11 +112,6 @@ Upload - - - Upload - -