Jinja templating Variables and Codes

@kolate_sambhaji i understand, but like i have tried to use the below in sales order and its not working:
{{ doc.create_date}}
{{ doc.billing_address}}
{{ doc.billing}}
{{doc.Customer_purchase_order_date}}
{{ doc.get_formatted(“posting_date”) }}

1 Like

@ramielian You can find all field names in Customize form.

For sales order and other form, check this link to know all available field names
https://frappe.github.io/erpnext/current/models/selling/sales_order.html
perhaps this? https://erpnext.org/docs/user/manual/en/selling/sales-order

@kolate_sambhaji thanxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

3 Likes

just another question please, @kolate_sambhaji is there away to change the variables, like the one for now i want to change is doc.shipping_address, when i use it, it will get me the address and fax and phone…etc but what i need is only the address…

i tried to change in the address template but it didn’t change…

sorry my bad i had cached data :smiley:

@ramielian you can not change variable name as it is actual column name in database, but you can always change Label in print and form.

To print address, you can set address template to remove fax and phone.
Also when you change address template, changes will apply on new transaction only, so you need to create new invoice to test address template change.

thank you very much for all your help…

i will open a new discussion that i would appreciate if you also answer it :smiley:

thanks again
mark

hi, sorry i have another one question please @kolate_sambhaji :smile:
i am trying to get the sales person name from sales team but its not working, i have tried two methods (which is only i know) as the following:

{{doc.sales_person}}
{% set cc = frappe.get_doc(“Sales”, doc.sales_team) %}
{{cc.sales_person}}

also tried {{doc.sales_team.sales_person}}

but nothing is working… any heads up in there?

thanks again

Check this code:

{%- for row in doc.sales_team -%}
{{ row.sales_person }}<br>
{% set cc = frappe.get_doc("Sales Person", row.sales_person) %}
EMP ID: {{cc.employee or ''}} <br>
{%- endfor -%}

Some more example:

{% set u = frappe.get_doc("Company", doc.company) %}
{{ u.country or '' }} 
    {{u.address}}
4 Likes

Thanks for your reply @kolate_sambhaji but if i want to translate EMP ID: as in your example how would i translate it?

@ramielian check this example to fetch values from another doctype.

hmmm, i think you were answering another question or didnt understand what i asked @kolate_sambhaji .

what i meant is i want to translate the below EMP ID: to another language, how can i do that?

{%- for row in doc.sales_team -%}
{% set cc = frappe.get_doc(“Sales Person”, row.sales_person) %}
EMP ID: {{cc.employee or ‘’}}
{%- endfor -%}

{{ _(“EMP ID”) }} will translate EMP ID if it is present in Translation List

1 Like

Great @kolate_sambhaji, thank you again :smiley:

2 Likes

Looks great. How can I fetch based on a string. something like this:

{% set u = frappe.get_doc("User", doc.user, "user@domain.com") %}
{{ u.first_name }} {{ u.last_name }}
1 Like

how did you clear the cache?

Hello @ramielian,

You can refer below link for Jinja template.
http://jinja.pocoo.org/docs/2.10/templates/

Thanks.

@kolate_sambhaji,

Can this be used in auto email alerts to set CC. When PO is submitted, an email is to be sent to the supplier automatically. Actually had to set To: to the supplier, but I find only 2 options: owner/customer, hence trying to use CC. Thanks in advance.

Yes, can be used.

Jinj templates in auto email report is not working. Do you have any idea?

Did you find any solution ?