I got an error after trying to use Jinja variable in Terms and Conditions.
Traceback (most recent call last):
File "/home/frappe/frappe-bench/apps/frappe/frappe/app.py", line 55, in application
response = frappe.handler.handle()
File "/home/frappe/frappe-bench/apps/frappe/frappe/handler.py", line 21, in handle
data = execute_cmd(cmd)
File "/home/frappe/frappe-bench/apps/frappe/frappe/handler.py", line 52, in execute_cmd
return frappe.call(method, **frappe.form_dict)
File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 907, in call
return fn(*args, **newargs)
File "/home/frappe/frappe-bench/apps/erpnext/erpnext/setup/doctype/terms_and_conditions/terms_and_conditions.py", line 23, in get_terms_and_conditions
return frappe.render_template(terms_and_conditions.terms, doc)
File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/jinja.py", line 50, in render_template
return get_jenv().from_string(template).render(context)
File "/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/jinja2/environment.py", line 1008, in render
return self.environment.handle_exception(exc_info, True)
File "/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/jinja2/environment.py", line 780, in handle_exception
reraise(exc_type, exc_value, tb)
File "
And here below is my code :
<div><b>Terms and Conditions</b></div>
<div>Document No. {{ name }} is valid until {{ frappe.utils.formatdate(doc.get_formatted('quote_valid_until'), "dd-mm-yyyy") }}.</div>
Then probably you are using [quote=“cipher, post:1, topic:23572”]
frappe.utils.
[/quote]
somewhere improperly . Try building a new custom script where you use the
to check whether you get the correct date format and proceed building the remaining things.
Thanks so much again for your reply. Could you please show me some example that how to use the custom script with your suggested code? because I’m quite new to ERPNext and trying to find and learn about it from Discuss ERPNext for long time.
@cipher . We both sail in the same boat , even I’m trying to learn erpnext from Discuss ERPNext for a long time . Anyway for my use case I wanted to print a date in dd-mm-yyyy format but could not get that done with ubuntu , so here is what I did .
I use this code exactly as it is, but is inside a HTML custom field or at a custom print format. {{ frappe.utils.formatdate(doc.get_formatted('posting_date'), "dd-MMMM-yyyy") }}
You’re right, at Terms and Conditions seems that doesn’t work any, can’t be changed, why don’t you try creating a custom print format? Or adding a HTML custom field and calling at the custom print format.