Print format to display UOM after the quantity


We are trying to print the UOM (i.e. Case) after the Quantity in the Quantity column shown below :

We tried editing the ‘Items (Table)’ at the Print format and we set UOM to be be after the Quantity like shown below. However, it is not reflected at the Print :

Kindly advice on how to set the UOM to be after the Quantity in Print.
Thank you.

@asneha1 Not possible in standard formats. you will have to write your print format from scratch in HTML

Hi @rmehta,

Thank you for the reply.

We did see that it was not possible in standard format and did our own rearranging of the fields and saved it as a New Custom Print Format.
However, as you have mentioned, this rearranging within the items table was not possible via the Items (table) from the Print Format. In which case, we are curious to understand what is the following Items table edit box (shown below) at the Print Format for, if rearranging cannot be done by dragging to set order.

Qty and UOM are merged in the same column. Sorry thats just the way it is.

@asneha1 a small trick is instead of building te whole document you can just create that only line you need, but in your case its a table so you need to build it all from 0

to help you get started you can use the following which will get most of what you want, just you do the styling:

<table style="line-height: 2em;width: 100%;" border="1" cellpadding="2" cellspacing="2">
            <th style="width:3%">#</th>
            <th style="width:40%" >{{ _("Description") }}</th>
            <th style="width:10%">{{_("Quantity")}}</th>
            <th style="width:10%">{{_("Rate")}}</th>
            <th style="width:10%">{{_("Amount")}}</th>
        <tr>{%- for row in doc.items-%}
            <td>{{ row.idx }}</td>
            <td >{{ row.item_name}}</td>
            <td style="text-align:center">{{ row.qty}}</td>
            <td style="text-align:center">{{ row.get_formatted("rate", doc) or ''}}</td>
            <td>{{ row.get_formatted("amount", doc) or ''}}</td>
        </tr>{%- endfor -%}

I would love this feature too. It is just proper English for customers to read “20 kg” instead of “kg 20” for example.
So does it mean that I can align the count to the left and align UOM to right?

You can do What ever guy want if you have the right side for it, the snippet above is just to get you started…

Hi Rushabh,

Realised that Packing Slip’s item table print format has been designed in such a way that the UOM and Quantity could be interchanged - for UOM to be displayed after the Quantity. So interchanging of UOM and Quantity is possible in Packing Slip:

However, when it comes to Purchase Order, the above flexibility is not offered. We tried interchanging the UOM and Quantity but the print format did not seem to change.

Kindly advise if Purchase Order’s item table print format could be made more flexible in the Packing Slip way or is it for Purchase Order, the print format is restricted to not do the swap. Wondering if the swap of UOM and Quantity can be done in Purchase Order like in Packing Slip above, without writing our own print format from scratch in HTML?

Hi @rmehta,

Checking to see if you have any advice on the above post.
Thank you.

yeah this border me too
still anyway to change?

do you know how to merge Qty and UOM at Quantity column?

We need to Print format to display UOM after the quantity.
Please help.

We need to Print format to display UOM after the quantity.
Please help.

I found some solution.

To change format from “uom quantity” (e.g. “kg 1”) to “quantity uom” (e.g. “1 kg”) you can change the file:

{{ doc.get_formatted(“qty”, doc) }}
{% if (doc.uom and not doc.is_print_hide(“uom”)) %} {{ _(doc.uom) }}
{% elif (doc.stock_uom and not doc.is_print_hide(“stock_uom”)) %} {{ _(doc.stock_uom) }}
{%- endif %}

For currency, to change format “symbol amount” (e.g. “$ 5”) into “amount iso-code” (e.g. “5 USD”) you have to change two files:

  • /frappe-bench/apps/frappe/frappe/utils/
  • /frappe-bench/apps/frappe/frappe/public/js/frappe/utils/number_format.js

In, you have to modify fmt_money. I simply replaced this (just before “return”):
amount = symbol + " " + amount
with this:
amount = amount + " " + currency

In number_format.js you have to modify format_currency to return this:
format_number(v, format, decimals) + " " + currency;

After making changes you have to run command in terminal:
bench build

It would be good to have it in the core, as built-in customization option, but I don’t know how to contribute, yet.

I added pull request to ERPNext and it was accepted, so in future versions of v13 you will be able to choose option to print UOM after quantity in Print Settings. So you won’t have to make changes as in my previous post every time you update your ERPNext.


I SOLVED this!

Here is the solution:

  1. Find and locate your “item_table_qty.html” file in your server.
  2. Once you find it, type on your server console: “sudo nano /frappe-bench/apps/erpnext/erpnext/templates/print_formats/includes/item_table_qty.html” or “sudo nano” and copy paste your item_table_qty.html file path
  3. Once you can edit the file and replace ALL of the content by using this code:
{% if (doc.uom and not doc.is_print_hide("uom")) %}
        <medium class="pull-right">{{ _(doc.uom) }}</medium>
{% elif (doc.stock_uom and not doc.is_print_hide("stock_uom")) %}
        <medium class="pull-right">{{ _(doc.stock_uom) }}</medium>
{%- endif %}
{{ doc.get_formatted("qty", doc) }} &nbsp;
  1. Exit and save your file

I can get mine working. Here is the screenshot:

Violaa… here is the result:

Hope this helps…