Sample of Table used in ERPnext

hi every one…

i would like to know the content of table as it would be much helpful in my stage right now…

the table am interested in is the items table is there away to do so? or to know the content of the variables used in the drag and drop.

@ramielian Did you try something?
check this link to get sample print format

1 Like

@kolate_sambhaji i tried it by my self but its not working, and i tried to copy the code highlighted but gave me error :
Traceback (innermost last):
File “/home/frappe/frappe-bench/apps/frappe/frappe/app.py”, line 57, in application
response = frappe.handler.handle()
File “/home/frappe/frappe-bench/apps/frappe/frappe/handler.py”, line 19, in handle
execute_cmd(cmd)
File “/home/frappe/frappe-bench/apps/frappe/frappe/handler.py”, line 36, in execute_cmd
ret = frappe.call(method, **frappe.form_dict)
File “/home/frappe/frappe-bench/apps/frappe/frappe/init.py”, line 803, in call
return fn(*args, **newargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/templates/pages/print.py”, line 142, in get_html_and_style
no_letterhead=no_letterhead, trigger_print=trigger_print),
File “/home/frappe/frappe-bench/apps/frappe/frappe/templates/pages/print.py”, line 121, in get_html
html = template.render(args, filters={“len”: len})
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/jinja2/environment.py”, line 989, 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 754, in handle_exception
reraise(exc_type, exc_value, tb)
File “/home/frappe/frappe-bench/apps/frappe/frappe/./templates/print_formats/standard.html”, line 28, in top-level template code
{{ render_field(df, doc) }}
File “/home/frappe/frappe-bench/apps/frappe/frappe/./templates/print_formats/standard_macros.html”, line 5, in template

{{ frappe.render_template(df.options, {“doc”: doc}) or “” }}

File “/home/frappe/frappe-bench/apps/frappe/frappe/utils/jinja.py”, line 41, 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 989, 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 754, in handle_exception
reraise(exc_type, exc_value, tb)
File "

when i try to use by my self on same table the whole table is being copyd for each row, and i noticed the {%- for row in doc.items-%} and {%- endfor -%} will always change the place to the first and end of the document

@kolate_sambhaji do you have the one in version 6? maybe its changed?
@rmehta can you please help also, am stuck in this one…

@kolate_sambhaji
v5 and v6 are same,
You can check below code to test v6 Sales Order print format.

https://github.com/sbkolate/erpnext_print_format/blob/master/v6/sales_order.html#L67

@kolate_sambhaji when i use the one from your blobs it updates the html to different than the one i inputed:

{%- for row in doc.items -%} {%- endfor -%}
Sr Description Quantity Rate Amount
{{ row.idx }} {% if row.in_format_data("image") and row.get("image") -%}
{%- endif %} {{ row.item_code or '' }}
{{ row.description or '' }}
{{ row.qty }} {{ row.get_formatted("rate", doc) or ''}} {{ row.get_formatted("amount", doc) or ''}}

and when i run it, it gives an error:

Traceback (innermost last):
File “/home/frappe/frappe-bench/apps/frappe/frappe/app.py”, line 57, in application
response = frappe.handler.handle()
File “/home/frappe/frappe-bench/apps/frappe/frappe/handler.py”, line 19, in handle
execute_cmd(cmd)
File “/home/frappe/frappe-bench/apps/frappe/frappe/handler.py”, line 36, in execute_cmd
ret = frappe.call(method, **frappe.form_dict)
File “/home/frappe/frappe-bench/apps/frappe/frappe/init.py”, line 805, in call
return fn(*args, **newargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/templates/pages/print.py”, line 142, in get_html_and_style
no_letterhead=no_letterhead, trigger_print=trigger_print),
File “/home/frappe/frappe-bench/apps/frappe/frappe/templates/pages/print.py”, line 121, in get_html
html = template.render(args, filters={“len”: len})
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/jinja2/environment.py”, line 989, 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 754, in handle_exception
reraise(exc_type, exc_value, tb)
File “/home/frappe/frappe-bench/apps/frappe/frappe/./templates/print_formats/standard.html”, line 28, in top-level template code
{{ render_field(df, doc) }}
File “/home/frappe/frappe-bench/apps/frappe/frappe/./templates/print_formats/standard_macros.html”, line 5, in template

{{ frappe.render_template(df.options, {“doc”: doc}) or “” }}

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 989, 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 754, in handle_exception
reraise(exc_type, exc_value, tb)
File "
</code

You closed for loop at first line, please check my code.

@kolate_sambhaji thats the problem, i am not closing the loop, i put the code in right locations but when i hit update from html to visual it will change it by it self…

@ramielian share your full code

@kolate_sambhaji please note below:

<table style="border: 1px gray solid;line-height: 2em;width: 100%;" border="1" cellpadding="2" cellspacing="2">
  </thead>
        <tr>
            <th>Sr</th>
            <th>{{ _("Brand") }}</th>
            <th>{{ _("Description") }}</th>
            <th>{{_("UOM")}}</th>
            <th>{{_("Quantity")}}</th>
            <th>{{_("Weight")}}</th>
            <th>{{_("rate")}}</th>
            <th>{{_("Discount Percent")}}</th>
            <th>{{_("Amount")}}</th>
        </tr>
    </thead>
    <tbody>
        <tr>{%- for row in doc.items-%}
            <td>{{ row.idx }}</td>
            <td>{{ row.brand}}</td>
            <td>{{ row.item_name}}</td>
            <td>{{ row.stock_uom}}</td>
            <td>{{ row.qty}}</td>
            <td>{% set it = frappe.get_doc("Item", row.item_code) %}{{it.net_weight or''}} {{it.weight_uom}}</td>
            <td>{{ row.get_formatted("rate", doc) or ''}}</td>
            <td>{{ row.get_formatted("discount_percentage", doc) or ''}}</td>
            <td>{{ row.get_formatted("amount", doc) or ''}}</td>
        </tr>{%- endfor -%}
    </tbody>
</table>

@ramielian above code works in my erp, what is the problem?

@kolate_sambhaji how did you use it!!!
what i do is i add it in html block and use html code:

after i update it comes like this:

@ramielian what is the output on Sales Invoice for this?
It should work fine.

I am using Custom Print Format instead of Print Format Builder Tool

1 Like

@kolate_sambhaji you mean you used it in all HTML format?

am using format builder and i think there is the problem…

is there any way to override the paython correction of the code in format builder?

1 Like

@kolate_sambhaji yup its working in there :smiley: but how i would call the letter heading when its called and hide it when its not called like in the regular case?

@kolate_sambhaji got it :slight_smile: and sorry for many answers :smiley:

{% if letter_head %}{{ letter_head }}<br>{% endif -%}

@ramielian Now you are expert, you can create whole new html format if you want.
:+1:

1 Like

@kolate_sambhaji do you know of a good training for python? am trying to search in my free time to learn it :smiley:

@ramielian https://www.codecademy.com/ will work if you want to learn python

You can also try Frappe Tutorial.
https://frappe.github.io/frappe/user/tutorial/before.html