Create Bulk Invoices from custom Doctype

I need to create bulk entities (Sales Invoices) from entities with a custom Doctype (Camp Participant).
How to get there?
I tried to make an client script on the listview of my custom doctypes and tried to call “erpnext.bulk_transaction_processing.create” (like: but I get errors like

ModuleNotFoundError: No module named 'erpnext.bulk_transaction_processing'

My client script for listview looks like:

frappe.listview_settings['Camp Participant'] = {
 onload: function(listview) { 
    const generate_invoices = () => {
        const docnames = listview.get_checked_items(true);
        if (docnames && docnames.length) {
                    method: 'erpnext.bulk_transaction_processing.create',
                    args: { 'listview': docnames, 'from_doctype': "Camp Participant", 'to_doctype': "Sales Invoice" },
                    freeze: true,
                    freeze_message: __('Generating Invoices...'),
        } else {
				message:  __('Please select at least one entry in the list'),
				title: __('No Camp selected'),
				indicator: 'red',
		};"Create Invoice"), generate_invoices);

Can anyone give me a hint?
Thanks in advance.

Just kind for information.

Please check your method path is right or not.

Thank You!

Hm. Probably I’m wrong in my assumption that this method is global available? Or am I?

is create method?
is bulk_transaction_processing file or folder?

if create is method and bulk_transaction_processing is file then your path is proper.

again check your path, method calling and file/folder.

Have you seen the sourcecode link above? There it is used the same way and it works.
Here is an other one: erpnext/bulk_transaction_processing.js at develop · frappe/erpnext · GitHub
bulk_transaction_processing is not a custom script, its default. Where else should I check?

Or is there an other better or easier solution for creating invoices from a list of custom docs?
I linked a Invoice Template to the custom doctype from which I would like to fetch the items and an address is linked to the “Camp Participant” which I’d use for the Invoice billing address.

Anyone? Any Idea?

Hi there,

I haven’t tested this, but at first glance it looks like you might be mixing up python and javascript.

The method is for invoking whitelisted python functions. For that, you can look to the same script you linked in your second example:

Note that the method is erpnext.utilities.bulk_transaction.transaction_processing, not erpnext.bulk_transaction_processing.create.

Conversely, erpnext.bulk_transaction_processing.create seems to be a javascript method, which you would want to call directly (without

1 Like

Thanks Peter!
Your right I mixed them up.
BUT, its still not working. The erpnext.bulk_transaction_processing.create throws an Uncaught TypeError: erpnext.bulk_transaction_processing.create is not a function
and the{method: "erpnext.utilities.bulk_transaction.transaction_processing",[...] ends up in an frappe.exceptions.ValidationError: Failed to get method for command erpnext.utilities.bulk_transaction.transaction_processing with No module named 'erpnext.utilities.bulk_transaction'

Do I have to import any module? Aren’t these methods globaly available?

Hmm…they both work for me on v14. What version are you on?

erpnext.bulki_transaction_processing.create (javascript):

erpnext.utilities.bulk_transaction.transaction_processing (python, via

Thanks for testing. I’m on v13.36.3. Is this a v14 thing?
The commits looked like this is older and how was this solved on v13?

It appears to be a new feature contributed in v14:

If you’re using v13, I’m not sure what if anything exists. What kind of document are you trying to generate the invoices from? In most cases, you could probably do what you’re trying to do with a server script.

1 Like

Aaaaah okay! I see. Thanks a lot. I will test this in v14.
I try to generate them from a custom DocType which is linked to a Invoice Template.
Is there a documentation for getting this done as server script?

I’m not familiar with Invoice Templates. Is this a standard feature or something you’ve built?

The term is something I came up with. I thought of having a entity like “sales order” (which can be fetched in the invoice) which holds the items, taxes etc. for the invoice.
We need to create a huge amount of similar invoices (same items, taxes, payment terms, terms and conditions, accounting details etc.) for a lot of people which have all booked our camp.
I would like to fetch the customer and this invoice template and generate a few houndred invoices (as draft) from that.
Does that sound reasonable?

I see, bulk transaction processing needs existing docs which I haven’t.
So probably “frappe.new_doc” is the function to go with? And is there a way to create them in bulk without open every invoice on creating?

Sure, that’s not a problem. The frappe.new_doc method doesn’t require you to open the invoices manually. If you have a list of customers, you can burn through them very quickly to generate as many invoices as you’d like.

The specifics will depend on how your customer data is aggregated and stored.

1 Like

And then there is frappe.db.insert How create and insert a new document through custom script - #6 by rmeyer
So which one is best to go with on Client Side Scripting? Or is there a way to hand the data to the server and generate those invoices there?
Atm I think frappe.db.insert is the way to go like: How I can insert multi rows in Child Table using Client Script (frappe.db.insert())?

Thanks that works!

1 Like

I believe frappe.db.insert() is just a shorthand for frappe.db.new_doc({...}).insert(), though I’d have to check to be sure. In any case, they appear to do the same thing.

You could certainly do this all on the server side too. If you have a custom doctype that defines customers and charges, you could write a server script that generates individual invoices. If you’re doing hundreds of invoices at once, server-side is definitely the better option.

1 Like