From 2d8e6ff05e93fc095960341515e01102a1aa2982 Mon Sep 17 00:00:00 2001 From: Christophe Simonis Date: Mon, 9 Oct 2017 11:36:59 +0200 Subject: [PATCH 1/2] [FIX] mail: handle empty recordset when computing unread message count --- addons/mail/models/mail_thread.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/mail/models/mail_thread.py b/addons/mail/models/mail_thread.py index bb1b91c5ed0..63cf9641597 100644 --- a/addons/mail/models/mail_thread.py +++ b/addons/mail/models/mail_thread.py @@ -181,10 +181,10 @@ class MailThread(models.AbstractModel): RIGHT JOIN mail_channel_partner cp ON (cp.channel_id = rel.mail_channel_id AND cp.partner_id = %s AND (cp.seen_message_id IS NULL OR cp.seen_message_id < msg.id)) - WHERE msg.model = %s AND msg.res_id in %s AND + WHERE msg.model = %s AND msg.res_id = ANY(%s) AND (msg.author_id IS NULL OR msg.author_id != %s) AND (msg.message_type != 'notification' OR msg.model != 'mail.channel')""", - (partner_id, self._name, tuple(self.ids), partner_id,)) + (partner_id, self._name, list(self.ids), partner_id,)) for result in self._cr.fetchall(): res[result[0]] += 1 From 99703583d4818dd5ec91386d3ed561ca9c1ebd52 Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Tue, 10 Oct 2017 10:24:31 +0200 Subject: [PATCH 2/2] [FIX] account: invoiced amount - Create 2 companies: A is parent of B. - Demo is in Company A - Create 2 invoices for a partner: one in A, one in B (100 each) - Validate the invoices Connected as Demo, the 'Invoiced' amount on the partner form view (stat button) is 100, while clicking on it shows both invoices (total of 200). There is no need to manually add the company in the `where` clause since the `_apply_ir_rules` will take care of adding the appropriate multi-company rules. opw-772479 --- addons/account/models/partner.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/account/models/partner.py b/addons/account/models/partner.py index 8e18962ab00..eb423456436 100644 --- a/addons/account/models/partner.py +++ b/addons/account/models/partner.py @@ -306,7 +306,7 @@ class ResPartner(models.Model): # generate where clause to include multicompany rules where_query = account_invoice_report._where_calc([ - ('partner_id', 'in', all_partner_ids), ('state', 'not in', ['draft', 'cancel']), ('company_id', '=', self.env.user.company_id.id), + ('partner_id', 'in', all_partner_ids), ('state', 'not in', ['draft', 'cancel']), ('type', 'in', ('out_invoice', 'out_refund')) ]) account_invoice_report._apply_ir_rules(where_query, 'read')