From 23a2bac3fa3aadc473e29adac376c614c983ec6b Mon Sep 17 00:00:00 2001 From: Nicolas Lempereur Date: Tue, 16 Jan 2018 14:14:54 +0100 Subject: [PATCH 01/11] [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 02/11] [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 c05c2cc03cfa45fccfab420908bf7dc0726a4b87 Mon Sep 17 00:00:00 2001 From: Goffin Simon Date: Wed, 17 Jan 2018 11:48:24 +0100 Subject: [PATCH 03/11] [FIX] hr_payroll: Unable to refund payslip The function action_payslip_done has been overwritten in module hr_payroll_account. Due to this overwrite, the function compute_sheet which creates the payslip lines was called after the creation of the entries. Then creating a refund payslip didn't create any entries. opw:785033 --- addons/hr_payroll/models/hr_payroll.py | 1 + 1 file changed, 1 insertion(+) diff --git a/addons/hr_payroll/models/hr_payroll.py b/addons/hr_payroll/models/hr_payroll.py index becb958c771..09719395543 100644 --- a/addons/hr_payroll/models/hr_payroll.py +++ b/addons/hr_payroll/models/hr_payroll.py @@ -244,6 +244,7 @@ class HrPayslip(models.Model): def refund_sheet(self): for payslip in self: copied_payslip = payslip.copy({'credit_note': True, 'name': _('Refund: ') + payslip.name}) + copied_payslip.compute_sheet() copied_payslip.action_payslip_done() formview_ref = self.env.ref('hr_payroll.view_hr_payslip_form', False) treeview_ref = self.env.ref('hr_payroll.view_hr_payslip_tree', False) From 0690911d7588f0f96e6df9b09346ae144b108b35 Mon Sep 17 00:00:00 2001 From: Swapnesh Date: Mon, 27 Nov 2017 19:19:42 +0530 Subject: [PATCH 04/11] [CLA] signature for sswapnesh Backport of 4e333607f1d37c7d76ac614647c064705ddf5752 CLA already signed in v11 --- doc/cla/individual/sswapnesh.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 doc/cla/individual/sswapnesh.md diff --git a/doc/cla/individual/sswapnesh.md b/doc/cla/individual/sswapnesh.md new file mode 100644 index 00000000000..97a61b8c83c --- /dev/null +++ b/doc/cla/individual/sswapnesh.md @@ -0,0 +1,12 @@ +India, 2017-11-24 + +I hereby agree to the terms of the Odoo Individual Contributor License +Agreement v1.0. + +I declare that I am authorized and able to make this agreement and sign this +declaration. + +Signed, + +Swapensh Shah swapneshshah111@gmail.com https://github.com/sswapnesh + From 57e37d6629b327a5c01470862e649bc21ecff557 Mon Sep 17 00:00:00 2001 From: Swapnesh Shah Date: Tue, 16 Jan 2018 22:50:04 +0530 Subject: [PATCH 05/11] [FIX] calendar: Made Start/End date required in meetings This commit closes #22279 and closes #21979 --- addons/calendar/views/calendar_views.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/calendar/views/calendar_views.xml b/addons/calendar/views/calendar_views.xml index 03432741965..6a5c11de816 100644 --- a/addons/calendar/views/calendar_views.xml +++ b/addons/calendar/views/calendar_views.xml @@ -116,10 +116,10 @@ - - + + - +