Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda
2 Replies
9993 Tampilan

Is it possible to set up something to have an attachment stored to the Sales Order, accesible from the attachments from the generated invoice (from this SO)?

So if I were to add a PDF with delivery dates to the sales order; I would like to automatically have this attachment linked to the invoice once the invoice is created.

Alternatively, in case this isn't feasible - is there a way to force the name a file gets when stored? For instance if I add the attachment "Receipt.pdf" to SO010, can I force it to be saved as "ReceiptSO010.pdf"?

Avatar
Buang
Jawaban Terbai

Yes, I wrote a module for this precise concept. FOREWARNING: This was written for 6.1 and has not been tested on 7.0. It also only modifies behavior in the web client, but that's also all we use.

https://code.launchpad.net/~brett-lehrer/+junk/attachment_nested_read

Essentially you are inheriting the original attachment reading function and looking for a many2one 'sale_id' field within that model. If it's set, find all of the relevant attachments from that record and display them in the list of attachments along with everything from the invoice itself. This module was configured for our heavy manufacturing use, but could easily be adapted to search from other models.

I tried to be careful in adding this new function so that the extra overhead is as minimal as possible when not needed (it gets called a lot), but I'm sure it could be written better than it is.

Avatar
Buang
Penulis

Thanks for this, Brett! It's not working straight away in v7, but I'll see what I can change to make it work for me tomorrow morning. I'm sure I can learn a great deal from your code to aid me in what I'm trying to do. :)

Note: To make this work in 7.0, just comment out the line containing "res['ids'] += extra_ids". I've updated the module to reflect that.

Jawaban Terbai

If you want this you can create a module that follow this steps:

  1. Inherit sale order confirmation function
  2. When the order is confermed, get the invoice id
  3. Search in ir.attachment (attachments class) the document with res_model = 'sale.order' and res_id = confirmed order
  4. Duplicate this attachment record and change res_model to 'account.invoice' and res_id to new invoice id

In this way you have the some attachment in two different classes and records.

Avatar
Buang

This was what my initial approach was, but there were two big problems: attachments added after the invoice is generated aren't pushed over, and this explodes the database/filesystem size with duplicates.

Post Terkait Replies Tampilan Aktivitas
1
Mar 15
6506
3
Mar 15
9167
1
Mar 15
8937
27
Agu 24
40201
2
Mar 15
6891