Fetch packing unit into item doctype

hey there , please any one can help me about ,how to get packing unit from item Price doctype to print it into quotation doc , with items table

Hi @ALI_ALKOUSA,

Directly get value in print format to apply it.

{%- for row in doc.items -%}

    {{ frappe.db.get_value("Item Price",{"item_code": row.item_code},'packing_unit') }}

{%- endfor -%}

And set value in table for apply server script:

Script Type: DocType Event
Reference Document Type: Quotation
DocType Event: Before Save

Script:

for d in doc.get('items'):
    pack_unit = frappe.db.get_value("Item Price",{'item_code': d.item_code},'packing_unit')
    d.Your_table_field_name = pack_unit

Thanks.

1 Like