[FIX] base,mail: do not include field attachments in attachment_count
The _search was already excluding these attachments but not the read_group Avoid the read_group from mail to search on all existing attachments Fixes odoo/odoo#27673 closes odoo/odoo#27698
This commit is contained in:
committed by
Martin Trigaux
parent
c41b469cb1
commit
e6e0d7ae78
@@ -239,7 +239,7 @@ class MailThread(models.AbstractModel):
|
||||
|
||||
@api.multi
|
||||
def _compute_message_attachment_count(self):
|
||||
read_group_var = self.env['ir.attachment'].read_group([('res_model', '=', self._name)],
|
||||
read_group_var = self.env['ir.attachment'].read_group([('res_id', 'in', self.ids), ('res_model', '=', self._name)],
|
||||
fields=['res_id'],
|
||||
groupby=['res_id'])
|
||||
|
||||
|
||||
@@ -381,6 +381,15 @@ class IrAttachment(models.Model):
|
||||
if not (self.env.user._is_admin() or self.env.user.has_group('base.group_user')):
|
||||
raise AccessError(_("Sorry, you are not allowed to access this document."))
|
||||
|
||||
@api.model
|
||||
def read_group(self, domain, fields, groupby, offset=0, limit=None, orderby=False, lazy=True):
|
||||
"""Override read_group to add res_field=False in domain if not present."""
|
||||
if not any(item[0] in ('id', 'res_field') for item in domain):
|
||||
domain.insert(0, ('res_field', '=', False))
|
||||
return super(IrAttachment, self).read_group(domain, fields, groupby,
|
||||
offset=offset, limit=limit,
|
||||
orderby=orderby, lazy=lazy)
|
||||
|
||||
@api.model
|
||||
def _search(self, args, offset=0, limit=None, order=None, count=False, access_rights_uid=None):
|
||||
# add res_field=False in domain if not present; the arg[0] trick below
|
||||
|
||||
Reference in New Issue
Block a user