How to use the barcode scanner on a custom POS popup?
Asked Answered
B

1

7

I'm trying to create form which would simplify adding of the products which are not yet registered to nomenclatures for my small shop. For this I've created module with following form:

<t t-extend="ConfirmPopupWidget">
    <t t-jquery="p.body" t-operation="replace">
        <div class="product-container">
            <div id="search_row" style="padding-bottom: 12px;padding-top: 11px;border-bottom: 1px solid gray;">
                <label>Barcode </label>
                <input style="height: 18px;" type="text" id="is_ean13" class="search" placeholder="EAN13 Barcode"/>
            </div>
            <div class="form-group">
                <label for="is_name" class="col-sm-2 control-label">Product Name </label>
                <div class="col-sm-10">
                    <input type="text" id="is_name" class="form-control" placeholder="Product name" style="height: 32px;background-color:#D2D2FF"/>
                </div>
            </div>
            <div class="form-group">
                <label for="is_sale_price" class="col-sm-2 control-label">Sale price</label>
                <div class="col-sm-10">
                    <input type="text" id="is_sale_price" class="form-control" placeholder="Sale Price"/>
                </div>
            </div>
            <div class="form-group">
                <label for="is_internal_reference" class="col-sm-2 control-label">Internal Reference</label>
                <div class="col-sm-10">
                    <input type="text" id="is_internal_reference" class="form-control" placeholder="Internal Reference"/>
                </div>
            </div>
        </div>
    </t>
</t>

I want to fill up ean13 barcode field "is_ean13" from barcode scanner, which is already used by POS interface, but could not make it working.

odoo.define('instant_sale.add_product', function (require) {
    "use strict";
    var bus = core.bus;
    // bind event handler
    bus.on('barcode_scanned', this, function(barcode) {
        this.scan(barcode);
    })
});

As it is written in https://media.readthedocs.org/pdf/odoo-development/latest/odoo-development.pdf page 38, but it seems I'm missing something, because I can't catch any event.

How can I catch barcode events in POS interface. Any help is highly appreciated. Thank you!

Babel answered 29/8, 2016 at 20:6 Comment(1)
Do you still need an answer to this or has your problem been resolved? (since it was posted a while back)Forbidding
O
-2

When the barcode scanner scans something, it will write it like if it was a keyboard then hit enter. This is how you get the information on a scan.

Because of this, you need to put the focus on the field input when you open your view so that the scanner writes in the correct html input.

Olnek answered 16/4, 2019 at 9:46 Comment(1)
Ok, I'm keeping my help for myself then. I'm sure its better this way.Olnek

© 2022 - 2024 — McMap. All rights reserved.