Add filter no_attachment on sale.order (same as on account.invoice)

This commit is contained in:
Alexis de Lattre
2021-05-20 12:25:33 +02:00
parent d858634b91
commit 781e8989f5
3 changed files with 33 additions and 2 deletions

View File

@@ -57,11 +57,11 @@ class AccountInvoice(models.Model):
def _compute_has_attachment(self):
iao = self.env['ir.attachment']
for inv in self:
if iao.search([
if iao.search_count([
('res_model', '=', 'account.invoice'),
('res_id', '=', inv.id),
('type', '=', 'binary'),
('company_id', '=', inv.company_id.id)], limit=1):
('company_id', '=', inv.company_id.id)]):
inv.has_attachment = True
else:
inv.has_attachment = False