Rounding ABS() CEIL() or similar in Jinja - Print Format HELP please

Hi All, just trying to do a simple operand on a calculation I’m doing in a Print Format and I keep getting errors - probably because my Jinja/Jscript skills are poor LOL.

This is where I’m up to and while the calcuation works, trying to add an ABS, ROUND or CEIL keeps creating errors. Could someone help me with the structure I need?

This works but I want to end up with an integer, not a decimal value:

{{ frappe.format_value((row.qty/row.number_up)+0.05*(row.qty/row.number_up), row.meta.get_field('qty'), row) }}

So I tried:

{{ frappe.format_value(abs((row.qty/row.number_up)+0.05*(row.qty/row.number_up)), row.meta.get_field('qty'), row) }}

{{ frappe.format_value(math.ceil((row.qty/row.number_up)+0.05*(row.qty/row.number_up)), row.meta.get_field('qty'), row) }}

{{ frappe.format_value(round(row.qty/row.number_up)+0.05*(row.qty/row.number_up)), row.meta.get_field('qty'), row) }}


1 Like

Hi @monojoker,

You can use the Jinja filters to round, ceil and abs.

please check the jinja built in filters


Thanks @makarand_b but I’m trying ABS as per my example above and getting long winded errors ending in:

File “”, line 321, in top-level template code
UndefinedError: ‘abs’ is undefined

Same with ceil and round.

Traceback (innermost last):
File “/home/frappe/v5press/benches/1606241137/apps/frappe/frappe/”, line 57, in application
response = frappe.handler.handle()
File “/home/frappe/v5press/benches/1606241137/apps/frappe/frappe/”, line 19, in handle
File “/home/frappe/v5press/benches/1606241137/apps/frappe/frappe/”, line 36, in execute_cmd
ret =, **frappe.form_dict)
File “/home/frappe/v5press/benches/1606241137/apps/frappe/frappe/”, line 806, in call
return fn(*args, **newargs)
File “/home/frappe/v5press/benches/1606241137/apps/frappe/frappe/templates/pages/”, line 142, in get_html_and_style
no_letterhead=no_letterhead, trigger_print=trigger_print),
File “/home/frappe/v5press/benches/1606241137/apps/frappe/frappe/templates/pages/”, line 121, in get_html
html = template.render(args, filters={“len”: len})
File “/home/frappe/v5press/benches/1606241137/env/lib/python2.7/site-packages/jinja2/”, line 989, in render
return self.environment.handle_exception(exc_info, True)
File “/home/frappe/v5press/benches/1606241137/env/lib/python2.7/site-packages/jinja2/”, line 754, in handle_exception
reraise(exc_type, exc_value, tb)
File “”, line 321, in top-level template code
UndefinedError: ‘abs’ is undefined

Hi @monojoker,

Not all frappe & python methods are available in Jinja templating that’s why it’s not able to find the ceil, round method hence the error. If you wish to use the math.ceil then you will need to configure the jinja environment.

you can find all the allowed / available function in in frappe app.

You can add the math.ceil, round, and abs method in or you can use the built-in filters provided by jinja itself.

Thanks, Makarand

Thanks Makarand, I am now having some success with round|int as it was rounding but returning a float. Appreciate your assistance!

I put this in the CSS but there is no change. I still see two decimal points in print format / PDF.


{ 42.55 | round } is not css. It’s jinja (though to be proper jinja you’d need {{ double brackets }} ). Jinja is a templating language used alongside normal HTML to create print formats.