Pular para o conteúdo
Menu
Esta pergunta foi sinalizada
3 Respostas
1123 Visualizações

Hi,

we are using doucments to control the invoice document flow while having our suppliers sending there invoices to a specific email address. As many suppliers have images (i.e. linkedin, marketing) in their mail signature, this ends to have a lot of trahs (jpegs, png's) in the list of incoming documents.
We are having google as mailer and the seeting " Ask before displaying external images " does not really help.

Do you have any suggestion how to filter this noise out?

Thanks for any ideas

 

Avatar
Cancelar

Did you (or anyone else) find a solution to this ?

I'd be very interested in any solution!

Autor Melhor resposta

Hi all, 
I implemented a scheduled action that is somehow similar to Patricks approach:

This actions triggers every 10 min and deletes the unwanted documents with the listed extensions.

Avatar
Cancelar
Melhor resposta

Hello Jürg Vogelsang,

In Odoo, when invoices are received by mail and processed into the Documents app, all attachments from the email (including small JPG/PNG images from signatures or marketing banners) are also created as ir.attachment records. This leads to unnecessary clutter in your incoming documents.

One way to solve this is by overriding the _message_post_process_attachments method to filter only the file types you want to keep (e.g., PDFs). Below is an example implementation:

  

def _message_post_process_attachments(self, attachments, attachment_ids, message_values):

    # Run Odoo’s default behavior

    attachment_data = super()._message_post_process_attachments(

        attachments, attachment_ids, message_values

    )

 

    # Collect attachment IDs linked by M2M (command 4)

    attachment_ids = [cmd[1] for cmd in attachment_data.get('attachment_ids', []) if cmd[0] == 4]

    attachments = self.env['ir.attachment'].browse(attachment_ids)

 

    # Keep only PDF files for documents

    if message_values.get('model') == 'documents.document':

        allowed_types = ['application/pdf']

        attachments = attachments.filtered(lambda att: att.mimetype in allowed_types)

 

    # Rebuild M2M list with filtered attachments

    attachment_data['attachment_ids'] = [(4, att.id) for att in attachments]

    return attachment_data 

 

With this customization, only PDF invoices will be kept, while signature images like JPG/PNG will be ignored and not appear in your Documents list.


If you have any questions, feel free to reach out to us.

Hope this helps!


Thanks & Regards,

Email : odoo@aktivsoftware.com

Avatar
Cancelar
Melhor resposta

Not a perfect solution but you could consider setting a studio automation that will archive any items that do not have the extension .pdf. 

First, set an domain on the automation

As you can see in the image, I'd also suggest a domain to specify the folder where the invoices are saved, that way you will be able to save jpegs and pngs in other folders if you want to.

For the action of the automation do the following. 

Not the most elegant solution, but it should keep your finance folder free from clutter. 

Avatar
Cancelar