Jinja child table

hi ,
I’ve created Purchase Order webhook

this my JSON Request Body:

{
{% for item in doc.items %}
{% if loop.index > 1 %}
,
{% endif %}
“item_code”:“{{item.item_code }}”
{% endfor %}

}

and the error is:

Traceback with variables (most recent call last):
File “apps/frappe/frappe/utils/background_jobs.py”, line 162, in execute_job
method(**kwargs)
site = ‘mysite’
method = <function enqueue_webhook at 0x7f7ff7fa6710>
event = None
job_name = ‘frappe.integrations.doctype.webhook.webhook.enqueue_webhook’
kwargs = {‘doc’: <PurchaseOrder: PUR-ORD-2023-00019 docstatus=1>, ‘webhook’: {‘name’: ‘HOOK-0002’, ‘condition’: “doc.status == ‘To Receive and Bill’”, ‘webhook_docevent’: ‘on_submit’, ‘webhook_doctype’: ‘Purchase Order’}}
user = ‘Administrator’
is_async = True
retry = 0
method_name = ‘frappe.integrations.doctype.webhook.webhook.enqueue_webhook’
File “apps/frappe/frappe/integrations/doctype/webhook/webhook.py”, line 117, in enqueue_webhook
data = get_webhook_data(doc, webhook)
doc = <PurchaseOrder: PUR-ORD-2023-00019 docstatus=1>
webhook = <Webhook: HOOK-0002>
headers = {‘Content-Type’: ‘application/json’, ‘Authorization’: ‘0ec26f36af0417a1bffc2dcbb388a9c0biQAWmTmfaCrqsaCCEGW265SPE83MCUxvv8RhbEMBQE1IoDU3U15a6Y0Lg3isYfnTnFAPTXatlcCaqhdKijvpHvBxztqXZd0MsBlMjM’}
File “apps/frappe/frappe/integrations/doctype/webhook/webhook.py”, line 192, in get_webhook_data
data = frappe.render_template(webhook.webhook_json, get_context(doc))
webhook = <Webhook: HOOK-0002>
data = {}
doc = {‘name’: ‘PUR-ORD-2023-00019’, ‘owner’: ‘Administrator’, ‘creation’: ‘2023-03-09 08:56:35.920395’, ‘modified’: ‘2023-03-09 08:56:39.800743’, ‘modified_by’: ‘Administrator’, ‘docstatus’: 1, ‘idx’: 0, ‘title’: ‘{supplier_name}’, ‘naming_series’: ‘PUR-ORD-.YYYY.-’, ‘supplier’: ‘01A041’, ‘supplier_name’: ‘01A041’, ‘order_confirmation_no’: None, ‘order_confirmation_date’: None, ‘transaction_date’: ‘2023-03-09’, ‘schedule_date’: ‘2023-03-09’, ‘company’: ‘xyz’, ‘apply_tds’: 0, ‘tax_withholding_category’: None, ‘is_subcontracted’: 0, ‘supplier_warehouse’: None, ‘amended_from’: None, ‘cost_center’: None, ‘project’: None, ‘currency’: ‘IDR’, ‘conversion_rate’: 1.0, ‘buying_price_list’: ‘Standard Buying’, ‘price_list_currency’: ‘IDR’, ‘plc_conversion_rate’: 1.0, ‘ignore_pricing_rule’: 0, ‘scan_barcode’: None, ‘set_from_warehouse’: None, ‘set_warehouse’: None, ‘total_qty’: 2.0, ‘total_net_weight’: 0.0, ‘base_total’: 0.0, ‘base_net_total’: 0.0, ‘total’: 0.0, ‘net_total’: 0.0, 'tax_withholding_net_to…
File “apps/frappe/frappe/utils/jinja.py”, line 85, in render_template
return get_jenv().from_string(template).render(context)
template = ‘{\r\n\t{% for item in doc.items %} \r\n {% if loop.index > 1 %}\r\n\t\t\t\t,\r\n\t\t\t{% endif %}\r\n\t"item_code":“{{item.item_code }}”\t\r\n\t{% endfor %}\r\n\r\n}’
context = {‘doc’: {‘name’: ‘PUR-ORD-2023-00019’, ‘owner’: ‘Administrator’, ‘creation’: ‘2023-03-09 08:56:35.920395’, ‘modified’: ‘2023-03-09 08:56:39.800743’, ‘modified_by’: ‘Administrator’, ‘docstatus’: 1, ‘idx’: 0, ‘title’: ‘{supplier_name}’, ‘naming_series’: ‘PUR-ORD-.YYYY.-’, ‘supplier’: ‘01A041’, ‘supplier_name’: ‘01A041’, ‘order_confirmation_no’: None, ‘order_confirmation_date’: None, ‘transaction_date’: ‘2023-03-09’, ‘schedule_date’: ‘2023-03-09’, ‘company’: ‘xyz’, ‘apply_tds’: 0, ‘tax_withholding_category’: None, ‘is_subcontracted’: 0, ‘supplier_warehouse’: None, ‘amended_from’: None, ‘cost_center’: None, ‘project’: None, ‘currency’: ‘IDR’, ‘conversion_rate’: 1.0, ‘buying_price_list’: ‘Standard Buying’, ‘price_list_currency’: ‘IDR’, ‘plc_conversion_rate’: 1.0, ‘ignore_pricing_rule’: 0, ‘scan_barcode’: None, ‘set_from_warehouse’: None, ‘set_warehouse’: None, ‘total_qty’: 2.0, ‘total_net_weight’: 0.0, ‘base_total’: 0.0, ‘base_net_total’: 0.0, ‘total’: 0.0, ‘net_total’: 0.0, 'tax_withholdin…
is_path = None
safe_render = True
TemplateError = <class ‘jinja2.exceptions.TemplateError’>
_ = <function _ at 0x7f8000970280>
get_traceback = <function get_traceback at 0x7f7fffb9bbe0>
throw = <function throw at 0x7f7fffbbc160>
File “env/lib/python3.10/site-packages/jinja2/environment.py”, line 1301, in render
self.environment.handle_exception()
self =
args = ({‘doc’: {‘name’: ‘PUR-ORD-2023-00019’, ‘owner’: ‘Administrator’, ‘creation’: ‘2023-03-09 08:56:35.920395’, ‘modified’: ‘2023-03-09 08:56:39.800743’, ‘modified_by’: ‘Administrator’, ‘docstatus’: 1, ‘idx’: 0, ‘title’: ‘{supplier_name}’, ‘naming_series’: ‘PUR-ORD-.YYYY.-’, ‘supplier’: ‘01A041’, ‘supplier_name’: ‘01A041’, ‘order_confirmation_no’: None, ‘order_confirmation_date’: None, ‘transaction_date’: ‘2023-03-09’, ‘schedule_date’: ‘2023-03-09’, ‘company’: ‘xyz’, ‘apply_tds’: 0, ‘tax_withholding_category’: None, ‘is_subcontracted’: 0, ‘supplier_warehouse’: None, ‘amended_from’: None, ‘cost_center’: None, ‘project’: None, ‘currency’: ‘IDR’, ‘conversion_rate’: 1.0, ‘buying_price_list’: ‘Standard Buying’, ‘price_list_currency’: ‘IDR’, ‘plc_conversion_rate’: 1.0, ‘ignore_pricing_rule’: 0, ‘scan_barcode’: None, ‘set_from_warehouse’: None, ‘set_warehouse’: None, ‘total_qty’: 2.0, ‘total_net_weight’: 0.0, ‘base_total’: 0.0, ‘base_net_total’: 0.0, ‘total’: 0.0, ‘net_total’: 0.0, 'tax_withholdi…
kwargs = {}
ctx = <Context {‘range’: <class ‘range’>, ‘dict’: <class ‘dict’>, ‘lipsum’: <function generate_lorem_ipsum at 0x7f7ffe5b6290>, ‘cycler’: <class ‘jinja2.utils.Cycler’>, ‘joiner’: <class ‘jinja2.utils.Joiner’>, ‘namespace’: <class ‘jinja2.utils.Namespace’>, ‘json’: {‘loads’: <function loads at 0x7f80008384c0>, ‘dumps’: <function dumps at 0x7f800082beb0>}, ‘as_json’: <function as_json at 0x7f7fffbbea70>, ‘log’: <function log at 0x7f7fffb9bd90>, ‘_dict’: <class ‘frappe._dict’>, ‘args’: {}, ‘frappe’: {‘call’: <function call_whitelisted_function at 0x7f7ff7fa5900>, ‘flags’: {}, ‘format’: <function format_value at 0x7f7fffbbec20>, ‘format_value’: <function format_value at 0x7f7fffbbec20>, ‘date_format’: ‘dd-mm-yyyy’, ‘time_format’: ‘HH:mm:ss’, ‘format_date’: <function global_date_format at 0x7f7fffb7ab90>, ‘form_dict’: {}, ‘bold’: <function bold at 0x7f7fffbbf400>, ‘copy_doc’: <function copy_doc at 0x7f7fffbbe560>, ‘errprint’: <function errprint at 0x7f7fffb9bc70>, ‘qb’: <class 'frappe.query_builde…
File “env/lib/python3.10/site-packages/jinja2/environment.py”, line 936, in handle_exception
raise rewrite_traceback_stack(source=source)
self = <jinja2.sandbox.SandboxedEnvironment object at 0x7f7ffc136c50>
source = None
rewrite_traceback_stack = <function rewrite_traceback_stack at 0x7f7ff7957490>
File “”, line 2, in top-level template code
range = <class ‘range’>
dict = <class ‘dict’>
lipsum = <function generate_lorem_ipsum at 0x7f7ffe5b6290>
cycler = <class ‘jinja2.utils.Cycler’>
joiner = <class ‘jinja2.utils.Joiner’>
namespace = <class ‘jinja2.utils.Namespace’>
json = {‘loads’: <function loads at 0x7f80008384c0>, ‘dumps’: <function dumps at 0x7f800082beb0>}
as_json = <function as_json at 0x7f7fffbbea70>
log = <function log at 0x7f7fffb9bd90>
_dict = <class ‘frappe._dict’>
args = {}
frappe = {‘call’: <function call_whitelisted_function at 0x7f7ff7fa5900>, ‘flags’: {}, ‘format’: <function format_value at 0x7f7fffbbec20>, ‘format_value’: <function format_value at 0x7f7fffbbec20>, ‘date_format’: ‘dd-mm-yyyy’, ‘time_format’: ‘HH:mm:ss’, ‘format_date’: <function global_date_format at 0x7f7fffb7ab90>, ‘form_dict’: {}, ‘bold’: <function bold at 0x7f7fffbbf400>, ‘copy_doc’: <function copy_doc at 0x7f7fffbbe560>, ‘errprint’: <function errprint at 0x7f7fffb9bc70>, ‘qb’: <class ‘frappe.query_builder.builder.MariaDB’>, ‘get_meta’: <function get_meta at 0x7f7fffbbd360>, ‘new_doc’: <function new_doc at 0x7f7fffbbcd30>, ‘get_doc’: <function get_doc at 0x7f7fffbbd1b0>, ‘get_mapped_doc’: <function get_mapped_doc at 0x7f7ffe53caf0>, ‘get_last_doc’: <function get_last_doc at 0x7f7fffbbd240>, ‘get_cached_doc’: <function get_cached_doc at 0x7f7fffbbce50>, ‘get_list’: <function get_list at 0x7f7fffbbe8c0>, ‘get_all’: <function get_all at 0x7f7fffbbe950>, ‘get_system_settings’: <function get_sys…
FrappeClient = <class ‘frappe.frappeclient.FrappeClient’>
style = {‘border_color’: ‘#d1d8dd’}
get_toc = <function get_toc at 0x7f7ffd94dab0>
get_next_link = <function get_next_link at 0x7f7ffd94db40>
_ = <function _ at 0x7f8000970280>
get_shade = <function get_shade at 0x7f7ffd94d990>
scrub = <function scrub at 0x7f7ffe999900>
guess_mimetype = <function guess_type at 0x7f800000d510>
html2text = <function html2text at 0x7f7ffdb4caf0>
dev_server = 1
run_script = <function run_script at 0x7f7ff7fa5990>
is_job_queued = <function is_job_queued at 0x7f7ff7fa57e0>
get_visible_columns = <function get_visible_columns at 0x7f7ff7fa5510>
builtins = {‘build_class’: , ‘None’: None, ‘False’: False, ‘True’: True, ‘abs’: , ‘bool’: <class ‘bool’>, ‘bytes’: <class ‘bytes’>, ‘callable’: , ‘chr’: , ‘complex’: <class ‘complex’>, ‘divmod’: , ‘float’: <class ‘float’>, ‘hash’: , ‘hex’: , ‘id’: , ‘int’: <class ‘int’>, ‘isinstance’: , ‘issubclass’: , ‘len’: , ‘oct’: , ‘ord’: , ‘pow’: , ‘range’: <class ‘range’>, ‘repr’: , ‘round’: , ‘slice’: <class ‘slice’>, ‘sorted’: , ‘str’: <class ‘str’>, ‘tuple’: <class ‘tuple’>, ‘zip’: <class ‘zip’>, ‘ArithmeticError’: <class ‘ArithmeticError’>, ‘AssertionError’: <class 'Assertion…
write = <function _write at 0x7f7ff7fa6050>
getitem = <function _getitem at 0x7f7ff7fa5f30>
getattr = <function _getattr at 0x7f7ff7fa5fc0>
getiter =
iter_unpack_sequence = <function guarded_iter_unpack_sequence at 0x7f7ffc1840d0>
abs =
all =
any =
bool = <class ‘bool’>
enumerate = <class ‘enumerate’>
isinstance =
issubclass =
list = <class ‘list’>
max =
min =
set = <class ‘set’>
sorted =
sum =
tuple = <class ‘tuple’>
bundled_asset = <function bundled_asset at 0x7f7ff7fa4a60>
get_dom_id = <function get_dom_id at 0x7f7ff7fa48b0>
include_script = <function include_script at 0x7f7ff7fa4940>
include_style = <function include_style at 0x7f7ff7fa49d0>
inspect = <function inspect at 0x7f7ff7fa4700>
is_rtl = <function is_rtl at 0x7f7ff7fa4af0>
resolve_class = <function resolve_class at 0x7f7ff7fa45e0>
web_block = <function web_block at 0x7f7ff7fa4790>
web_blocks = <function web_blocks at 0x7f7ff7fa4820>
doc = {‘name’: ‘PUR-ORD-2023-00019’, ‘owner’: ‘Administrator’, ‘creation’: ‘2023-03-09 08:56:35.920395’, ‘modified’: ‘2023-03-09 08:56:39.800743’, ‘modified_by’: ‘Administrator’, ‘docstatus’: 1, ‘idx’: 0, ‘title’: ‘{supplier_name}’, ‘naming_series’: ‘PUR-ORD-.YYYY.-’, ‘supplier’: ‘01A041’, ‘supplier_name’: ‘01A041’, ‘order_confirmation_no’: None, ‘order_confirmation_date’: None, ‘transaction_date’: ‘2023-03-09’, ‘schedule_date’: ‘2023-03-09’, ‘company’: ‘xyz’, ‘apply_tds’: 0, ‘tax_withholding_category’: None, ‘is_subcontracted’: 0, ‘supplier_warehouse’: None, ‘amended_from’: None, ‘cost_center’: None, ‘project’: None, ‘currency’: ‘IDR’, ‘conversion_rate’: 1.0, ‘buying_price_list’: ‘Standard Buying’, ‘price_list_currency’: ‘IDR’, ‘plc_conversion_rate’: 1.0, ‘ignore_pricing_rule’: 0, ‘scan_barcode’: None, ‘set_from_warehouse’: None, ‘set_warehouse’: None, ‘total_qty’: 2.0, ‘total_net_weight’: 0.0, ‘base_total’: 0.0, ‘base_net_total’: 0.0, ‘total’: 0.0, ‘net_total’: 0.0, 'tax_withholding_net_to…
utils = {‘DATE_FORMAT’: ‘%Y-%m-%d’, ‘TIME_FORMAT’: ‘%H:%M:%S.%f’, ‘DATETIME_FORMAT’: ‘%Y-%m-%d %H:%M:%S.%f’, ‘is_invalid_date_string’: <function is_invalid_date_string at 0x7f7fffb78e50>, ‘getdate’: <function getdate at 0x7f7fffb78ee0>, ‘get_datetime’: <function get_datetime at 0x7f7fffb78f70>, ‘get_timedelta’: <function get_timedelta at 0x7f7fffb79000>, ‘to_timedelta’: <function to_timedelta at 0x7f7fffb79090>, ‘add_to_date’: <function add_to_date at 0x7f7fffb79120>, ‘add_days’: <function add_days at 0x7f7fffb791b0>, ‘add_months’: <function add_months at 0x7f7fffb79240>, ‘add_years’: <function add_years at 0x7f7fffb792d0>, ‘date_diff’: <function date_diff at 0x7f7fffb79360>, ‘month_diff’: <function month_diff at 0x7f7fffb793f0>, ‘time_diff’: <function time_diff at 0x7f7fffb79480>, ‘time_diff_in_seconds’: <function time_diff_in_seconds at 0x7f7fffb79510>, ‘time_diff_in_hours’: <function time_diff_in_hours at 0x7f7fffb795a0>, ‘now_datetime’: <function now_datetime at 0x7f7fffb79630>, 'get_times…
File “env/lib/python3.10/site-packages/jinja2/runtime.py”, line 417, in init
self._iterator = self._to_iterator(iterable)
self = Traceback (most recent call last):
File “env/lib/python3.10/site-packages/traceback_with_variables/core.py”, line 222, in to_cropped_str
raw = print
(obj)
File “env/lib/python3.10/site-packages/jinja2/runtime.py”, line 581, in repr
return f"<{type(self).name} {self.index}/{self.length}>"
File “env/lib/python3.10/site-packages/jinja2/runtime.py”, line 440, in length
iterable = list(self._iterator)
AttributeError: ‘LoopContext’ object has no attribute ‘_iterator’

  iterable = <built-in method items of _dict object at 0x7f7ffca2e1c0>
  undefined = <class 'jinja2.runtime.DebugUndefined'>
  recurse = None
  depth0 = 0

File “env/lib/python3.10/site-packages/jinja2/runtime.py”, line 425, in _to_iterator
return iter(iterable)
iterable = <built-in method items of _dict object at 0x7f7ffca2e1c0>
builtins.TypeError: ‘builtin_function_or_method’ object is not iterable

kindly adv
thanks