Print batch number on work order

Hello!

When I create a new work order for a product and before it is finally submitted I see that ERPNext creates an empty batch number for the new products on the “Batch List”. How can I have this new batch number printed on the work order form?

I tried using {{ item.batch_no }} but it throws an error :

{{ item.batch_no }}
Traceback (most recent call last):
File “apps/frappe/frappe/utils/jinja.py”, line 86, in render_template
return get_jenv().from_string(template).render(context)
File “env/lib/python3.8/site-packages/jinja2/environment.py”, line 1291, in render
self.environment.handle_exception()
File “env/lib/python3.8/site-packages/jinja2/environment.py”, line 925, in handle_exception
raise rewrite_traceback_stack(source=source)
File "

Thanks in advance!

I dont’t think that it will work.

From my point of view, the work order is created by someone to tell the people in some warehouse area to start fetch the items for manufacture. The batch and serial no of the items will be linked to the work order via stock entry after the people in charge of the warehouse perform data entry in the stock entry area.

So, I think you don’t have the stock entry item in the initial work order data , and you can not print something that doesn’t exist yet.

On the techincal side, there is no data of {{ item.batch_no }} if you try to print the work order doctype, cause simply the work order doctype doesn’t have any batch data.

If the work order report with link to the batch order is what you need, I think you have to create a custom report, maybe a server based script report using python.

I believe it’s about linking the batch data list made in stock entry doctype to the work order doctype , and you need to do script based report mechanism in order to bridge them.

Solved it with an html block on the template like this :

{% for name in frappe.get_all("Batch", filters = {"reference_name": doc.name}) %}
<p>{{ name['name'] }}</p>
{% endfor %}
1 Like