Odoo Help


How can I add a product to a Sales Order with its Barcode?

Stavros Christodoulou
on 10/18/13, 4:17 AM 3,100 views

Is there a way to search products from the sales order line with their barcode?

The search of a product wan be performed with its name and internal reference. Is there a way to include its barcode as well?


On 10/22/13, 12:00 AM

You can actually type a SKU, a product ID, http://www.keepautomation.com/online_barcode_generator/ean_13/ (EAN), UPC, http://www.keepautomation.com/products/net_barcode/barcodes/isbn.html (ISBN) or even part of a product name. If there is only one item found in the system that matches, then the item will be added to the order. javascript:(function(){var barcode=prompt("Scan barcode:");if(barcode!=''){ $.get("ajaxData.php",{op:"autosearch_product",price_list:priceList,warehouse:"2",orderType:orderType,term:barcode},function(data){item=jQuery.parseJSON(data);if(item.length==0){alert("Nothing found with that barcode...");return false;};if(item.length>1){alert("There are multiple items with that code!");return false;};console.log(item[0]);addItem(item[0],0);alert("Added item OK");});}})();

Can you please explain to me a bit more how I can achieve this? Lets say that a product has 2 barcodes. How can I include both of them in the line search?

Stavros Christodoulou
on 10/25/13, 10:20 AM

Hello Mariahlewis ,, could you please explain where should i put the JS ?

iwan soenarto
on 9/2/14, 11:30 PM

CMIIW, I think the code mariahlewis cannot be used as is for 2 reasons: it has a dependency to ajaxData.php, and it used autosearch_product method which I couldn't find in the standard OpenERP. On Stavros' question on product having 2 barcodes: OpenERP by default provides a few fields that can be used for searching. EAN13 Barcode, Internal Reference, and the Name fields. So you can store the barcode information in any of the fields, and when you are searching a product (e.g. when entering the Product information in Sale Order's Line) you can type in (or scan) the barcode. But, if you want to search using BOTH barcode, you need to develop a way to do it. Currently, when searching a record in many2one field, Odoo only provide one parameter to serve as search criteria, although it can compare the parameter to multiple fields. To Iwan: generally JSes are stored under static/src/js folder of the module. But it need to be defined (full path) in the js key in __openerp__.py. For sample of how to handle barcode scanning, you can take a look at how point_of_sales module handles it.

on 9/3/14, 3:18 AM

"Currently, when searching a record in many2one field, Odoo only provide one parameter to serve as search criteria, although it can compare the parameter to multiple fields" Can I use any other custom field to add sales order line. e.g. I added One2Many field called GenuineNumbers, can I use it to add product order line ?

Mahmoud Korayem
on 11/22/14, 1:07 AM

Yes you use pretty much any field (custom or base) to search. You still need to develop the functionality first, though.

on 11/24/14, 2:45 AM

First, Thanks for you fast reply @John Doe But I need to just clarify something. I mean that I added a column in the sales-order-line called genuine number. I am adding items using inline not Pop-Up window. Normally, the drop down menu by which I can add item line is is only for the name/internal-reference. My question is, in this situation can I make the genuine numbers column also be a drop down menu, when I choose one of them, it automatically add the item line same it does for the name/internal reference ?

Mahmoud Korayem
on 11/24/14, 2:54 AM

Mahmoud, if you are adding the column to sale.order.line, then you cannot search the column for a product.product. You need to add the column to product.product so that you can search it from product.product's column. You want look into inheriting name_search method of ORM in order to do so. Also, if you have a totally different question, I would suggest that you create your own thread. Stavros' questions is about adding sale.order.line by barcode scanning.

on 11/24/14, 3:55 AM

Thanks, I created a new post https://www.odoo.com/forum/help-1/question/add-column-from-product-to-sales-order-line-and-use-it-to-add-item-line-68502

Mahmoud Korayem
on 11/24/14, 4:07 AM
iwan soenarto
On 9/2/14, 11:29 PM

Thanks John Doe for the explanation ... Really appreciate it...

iwan soenarto
on 9/3/14, 3:45 AM

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

2 follower(s)


Asked: 10/18/13, 4:17 AM
Seen: 3100 times
Last updated: 2/2/17, 5:54 AM