Hi,
I inserted a custom field named ‘hora_actual’. This code works at print preview.
{{ frappe.utils.get_datetime(doc.hora_actual).strftime('%H:%M') }}
But when I try to print…

Or clic on PDF…

¿Is there any other way to print time in format ‘H:M’?
Can you share the full template? How are you calling it?
In the Print Format Builder, the code is like that inside a HTML field.
{{ frappe.utils.get_datetime(doc.hora_actual).strftime('%H:%M') }}
And it’s caused only because of the strftime('%H:%M')
part. I’ve made many tests.
@Francisco_Buendia I was wondering how you are calling the template. it seems the template is being printed raw, not processed.
I made the template using the Print format builder.
I mean is not a Custom format.
And it’s called right from print button.
(Sorry, it’s in Payment Entry, I just take an image from Quotation to explain the point, but it’s exactly the way I call any format to print)
This code is exactly like that, inside a HTML field. When I delete this part strftime('%H:%M')
the format can be printed normally.
Of course, the time it’s shown like ‘10:17:43’, not like ‘10:17’ as is needed.
Could you solve this issue?
Try this
{%- set time = doc.get_formatted('posting_time') -%}{{ time[:5] }}
1 Like