How do you also pull {{ item.manufacturer_part_no }} To Display in POS Printformat

How do you pull {{ item.manufacturer_part_no }} as that doesn’t seem to work

While other variables like {{ item.serial_no }} shows up, variables like {{ item.manufacturer_part_no }} doesn’t show up in the POS print format.

image

Ref: https://github.com/frappe/erpnext/issues/13462

seems this field has no value in the item doctype
You can remove all row if there is no value using if condition like this
{% if row.manufacturer_part_no %}PN: {{ row.manufacturer_part_no }}<br>{%- endif %}

The item actually has a value for manufacture part number. Only that the print format does not display it.

Hi, this field may not be there by default in POS doctype.
You can fetch it using following code:

{{ frappe.db.get_value("Item", {"item_code": row.item_code}, "manufacturer_part_no") }}
1 Like

Thanks @snv it didn’t really work, it freezes the print. I noticed that if the custom code isn’t acceptable, the print button on the POS view gets disconnected.

@OmarJaber, below is the full code with @snv suggestion which freezes the POS print button:

<style>
	.print-format table, .print-format tr, 
	.print-format td, .print-format div, .print-format p {
		font-family: Monospace;
		line-height: 200%;
		vertical-align: middle;
	}
	@media screen {
		.print-format {
			width: 4in;
			padding: 0.25in;
			min-height: 8in;
		}
	}
</style>

<p class="text-center">
	{{ company }}<br>
	{{  __("POS No : ") }} {{ offline_pos_name }}<br>
</p>
<p>
	<b>{{ __("Customer") }}:</b> {{ customer }}<br>
</p>

<p>
	<b>{{ __("Date") }}:</b> {{ dateutil.global_date_format(posting_date) }} <br>
	<b>{{ __("Posting Time") }}:</b> {{ posting_time }} <br>
	<b>{{ __("Paid Amount") }}:</b> {{ paid_amount }} <br>
</p>

<hr>
<table class="table table-condensed cart no-border">
	<thead>
		<tr>
			<th width="50%">{{ __("Item") }}</b></th>
			<th width="25%" class="text-right">{{ __("Qty") }}</th>
			<th width="25%" class="text-right">{{ __("Amount") }}</th>
		</tr>
	</thead>
	<tbody>
		{% for item in items %}
		<tr>
			<td>
				{{ item.item_name }}
				<br>
				PN: {{ frappe.db.get_value("Item", {"item_code": row.item_code}, "manufacturer_part_no") }} <br>
				SN(s): {{ item.serial_no }}
			</td>
			<td class="text-right">{{ format_number(item.qty, null,precision("difference")) }}<br>@ {{ format_currency(item.rate, currency) }}</td>
			<td class="text-right">{{ format_currency(item.amount, currency) }}</td>
		</tr>
		{% endfor %}
	</tbody>
</table>

<table class="table table-condensed no-border">
	<tbody>
		<tr>
			<td class="text-right" style="width: 70%">
				{{ __("Net Total") }}
			</td>
			<td class="text-right">
				{{ format_currency(total, currency) }}
			</td>
		</tr>
		{% for row in taxes %}
		{% if not row.included_in_print_rate %}
		<tr>
			<td class="text-right" style="width: 70%">
				{{ row.description }}
			</td>
			<td class="text-right">
				{{ format_currency(row.tax_amount, currency) }}
			</td>
		</tr>
		{% endif %}
		{% endfor %}
		{% if discount_amount %}
		<tr>
			<td class="text-right" style="width: 75%">
				{{ __("Discount") }}
			</td>
			<td class="text-right">
				{{ format_currency(discount_amount, currency) }}
			</td>
		</tr>
		{% endif %}
		<tr>
			<td class="text-right" style="width: 75%">
				<b>{{ __("Grand Total") }}</b>
			</td>
			<td class="text-right">
				{{ format_currency(grand_total, currency) }}
			</td>
		</tr>
		<tr>
			<td class="text-right" style="width: 75%">
				<b>{{ __("Paid Amount") }}</b>
			</td>
			<td class="text-right">
				{{ format_currency(paid_amount, currency) }}
			</td>
		</tr>
	</tbody>
</table>


<hr>
<p>{{ terms }}</p>
<p class="text-center">{{ __("Thank you, please visit again.") }}</p>

Hi @rohit_w,

I see that your comment solved the issue of Not able to get value from other doctype

Using your recommendation, I couldn’t replicate the solution.

Anyone with suggested solution, still can’t crack this!

There a silly mistake:
Instead of row.item_code in:

{{ frappe.db.get_value("Item", {"item_code": row.item_code}, "manufacturer_part_no") }}

use item.item_code like this:

{{ frappe.db.get_value("Item", {"item_code": item.item_code}, "manufacturer_part_no") }}

This is because you have used item instead of row in the for loop.

This might not work in offline POS mode, considering that whole Item DB may not be available offline.