I’ve had the idea to copy custom field values when copying an Invoice. Tried to do it myself, but it failed.
Steps I did:
In application/modules/invoices/models/mdl_invoices.php (where public function copy_invoice begins) I added the following after the loop of $invoice_tax_rates:
This throws no errors but it doesn’t copy the value of the fields either + I can’t do it like the example snippet. There will be more custom fields which I won’t have the name of if this goes to a production system.
Now I’m asking for help. Hope you guys can come up with a great solution that would fit, maybe give tips whatsoever. Would appreciate it.
Pretty late reply, sorry - I hope you found a means to do this since you posted, anyway I’ll post a possible way to acheive the desired behaviour.
I’m new to InvoicePlane (1 day !) and I really appreciate it. As I was configuring/tweeking it to fit my needs, I bumped into a very similar question: I wanted to copy custom fields from a quote to an invoice when using the “quote to invoice” functionality. For instance, I have created for both quotes and invoices a custom field “project” that holds the project name (to be displayed in the quotes/invoices titles), and I don’t want to have to re-type it for each quote-to-invoice creation.
Here is what I did, and it works really well (latest version, 1.4.6) =>
I think that you can use the same basis for the invoice/quote copy method (just don’t use str_replace('quote', 'invoice', $key) => $val in the foreach section but just $key => $val)
This should work fine
As of the above example for the quote-to-invoice conversion, I have a perfect mapping (quote custom fields are all set up the same way for invoices), and I don’t think it would work properly if you have some quote custom fields that do not exist for invoices => in this case, a checking would be required before including the custom field into $db_array)