diff --git a/core/trunk/structure.sql b/core/trunk/structure.sql
index a74df21f77e1197344f6c85279757bd5ebb39dd4..5afccffdabc015bdd645f79680bfb719e7308344 100644
--- a/core/trunk/structure.sql
+++ b/core/trunk/structure.sql
@@ -3639,7 +3639,7 @@ CREATE VIEW res_view_letterbox AS
     FROM doctypes d, doctypes_first_level dfl, doctypes_second_level dsl,
     (((((((((((ar_batch a RIGHT JOIN res_letterbox r ON ((r.arbatch_id = a.arbatch_id)))
     LEFT JOIN (SELECT res_attachments.res_id_master, count(res_attachments.res_id_master) AS count_attachment
-        FROM res_attachments GROUP BY res_attachments.res_id_master) att ON (r.res_id = att.res_id_master))
+        FROM res_attachments WHERE res_attachments.status <> 'DEL' GROUP BY res_attachments.res_id_master) att ON (r.res_id = att.res_id_master))
     LEFT JOIN entities en ON (((r.destination)::text = (en.entity_id)::text)))
     LEFT JOIN folders f ON ((r.folders_system_id = f.folders_system_id)))
     LEFT JOIN cases_res cr ON ((r.res_id = cr.res_id)))
@@ -3745,4 +3745,4 @@ CREATE VIEW view_contacts AS
   ca.website, ca.salutation_header, ca.salutation_footer, ca.other_data, ca.user_id, ca.entity_id, ca.is_private
   FROM contacts_v2 c
   RIGHT JOIN contact_addresses ca
-  ON c.contact_id = ca.contact_id;
\ No newline at end of file
+  ON c.contact_id = ca.contact_id;