Custom Fields in POS

I need to fetch data from the database using the POS screen, other meaning i need to get the value to custom field in POS

Currently this is not out of the box…you need to customize POS page

I need example code to fetch data from another doctype to pos custom field

waiting for example also…

@Tarek_Esmail do you want add your custom field in pos?? if yes here i have added batch field in pos by customizing html and finding events in js see below i have taken pos_item.js where i am rendering batch no on pos
Here s html for pos_item

<div class="row pos-bill-row pos-bill-item" data-item-code="{%= item_code %}" item-idx="{%= idx %}">
    <div class="col-xs-3"><h6>{%= item_code || "" %}{%= item_name || "" %}</h6></div>
    <div class="col-xs-3">
        <div class="row pos-batch-row">
            <div class="batch-no"></div>
             <input type="text" name="Production date" value="{%= production_date%}" style="margin-bottom: 1%;" class="form-control input-sm pos-item-batch-pro  text-right" id="prod_date" placeholder="Production Date" readonly>
            <input type="text" value="{%= expiry_date %}" style="margin-bottom: 1%;" class="form-control input-sm pos-item-batch-exp text-right" id="Expi_date" placeholder="Expiration Date" readonly>
    <div class="col-xs-3">
        <div class="row pos-qty-row">
            <div class="col-xs-2 text-center pos-qty-btn" data-action="decrease-qty"><i class="fa fa-minus text-muted" style="font-size:12px"></i></div>
            <div class="col-xs-8">
                    <input type="text" value="{%= qty %}" class="form-control input-sm pos-item-qty text-right">
                {% if(actual_qty != null) { %}
                <div style="margin-top: 5px;" class="text-muted small text-right">
                    <span title="{%= __("In Stock") %}">{%= actual_qty || 0 %}<span>
                {% } %}
            <div class="col-xs-2 text-center pos-qty-btn" data-action="increase-qty"><i class="fa fa-plus text-muted" style="font-size:12px"></i></div>
    <div class="col-xs-3 text-right">
        <div class="text-muted" style="margin-top: 5px;">
            {% if(enabled) { %}
                <input type="text" value="{%= rate %}" class="form-control input-sm pos-item-rate text-right">
            {% } else { %}
                <h6>{%= format_currency(rate) %}</h6>
            {% } %}
        <p><h6>{%= amount %}</h6></p>

below i am manipulating link field

		var demo=$('div[item-idx='+idx+']')
		var me=this;
		var item_obj = $(this).parents(".pos-bill-item")
		this.batch_no= frappe.ui.form.make_control({

			df: {
				"fieldtype": "Link",
				"options": "Batch",
				"label": "Batch-no",
				"fieldname": "Batch",
				"placeholder": __("Batch"),
					return {
			parent: $('div[item-idx='+idx+']').find(".batch-no"),
			only_input: true,


//Added By Khushal
		var me=this


			var batch_no = $(this).val()
			var item_idx = $(this).parents(".pos-bill-item").attr("item-idx");
			var item_code = $(this).parents(".pos-bill-item").attr("data-item-code");
			var item_obj = $(this).parents(".pos-bill-item")


			// console.log("TT",item_idx){
				method: "goodfood_trading.customization.poss.get_data",
				args: {
					"batch_item": batch_no
				callback: function(r) {
					me.batch_according_to_batch_no(item_code, batch_no, item_obj)						// console.log("RRRRRRRRRRRRR",d.item_counter,d.item_code)


here i am finding item add to cart event and attaching link field



@khushal_t I want also. But my question is How?

gave you reference code i hope will be helpful

Thank you @khushal_t for the reference code. Can you insert a screenshot of your customized POS? Thanks a lot.

Here i have created batch link field you can whichever you want in pos.

1 Like

Thanks a lot @khushal_t :slight_smile:

1 Like