Merge lp:~guerrerocarlos/openobject-addons/point_of_sale_6.1_barcode__merge into lp:openobject-addons/6.1

Proposed by Carlos Guerrero on 2012-03-23
Status: Needs review
Proposed branch: lp:~guerrerocarlos/openobject-addons/point_of_sale_6.1_barcode__merge
Merge into: lp:openobject-addons/6.1
Diff against target: 44 lines (+13/-5)
1 file modified
point_of_sale/static/src/js/pos.js (+13/-5)
To merge this branch: bzr merge lp:~guerrerocarlos/openobject-addons/point_of_sale_6.1_barcode__merge
Reviewer Review Type Date Requested Status
Olivier Dony (Odoo) Abstain on 2012-03-30
Selami Demir (community) Approve on 2012-03-26
Roberto López López (community) 2012-03-23 Approve on 2012-03-26
Nhomar - Vauxoo (community) Approve on 2012-03-26
Antony Lesuisse (OpenERP) 2012-03-30 Pending
Review via email: mp+99129@code.launchpad.net

Description of the change

Solves 'OpenERP 6.1 POS: lookup by barcode (EAN13 or Reference)'[1] bug.

* [FIX] point_of_sale: Added product search by EAN13 or Reference in the POS

[1] https://bugs.launchpad.net/openobject-addons/+bug/949664

To post a comment you must log in.
Cristian Salamea (ovnicraft) wrote :

Hello thanks for fix it, so i have a question, is possible get on if for both evaluations ?

Regards,

Carlos Guerrero (guerrerocarlos) wrote :

Yes but then another if would be needed for selecting the right field
to apply the "toLowerCase" and "indexOf(s)", so I think that with two
separated "if" like it is right now, is the most efficient.

On Fri, Mar 23, 2012 at 4:27 PM, Cristian Salamea (Gnuthink)
<email address hidden> wrote:
> Hello thanks for fix it, so i have a question, is possible get on if for both evaluations ?
>
> Regards,
> --
> https://code.launchpad.net/~guerrerocarlos/openobject-addons/point_of_sale_6.1_barcode__merge/+merge/99129
> You are the owner of lp:~guerrerocarlos/openobject-addons/point_of_sale_6.1_barcode__merge.

--
Atte:
Carlos A. Guerrero M.
http://www.carlosguerrero.com

6703. By Carlos Guerrero on 2012-03-23

[FIX] Validation for searching of all three fields: "name", "ean13" and "code"

6704. By Carlos Guerrero on 2012-03-24

[IMP] point_of_sale: lookup by barcode in the same if

Carlos Guerrero (guerrerocarlos) wrote :

Now all the evaluations are in one same "if" as requested and has been proved to work as well.

6705. By Carlos Guerrero on 2012-03-24

[FIX] point_of_sale: Add product to order automatically with <Enter> from barcode reader

Carlos Guerrero (guerrerocarlos) wrote :

New improvement to the code, now the "if" has been removed at all, and the product is automatically added to the order when using a bar code reader.

6706. By Carlos Guerrero on 2012-03-24

[IMP] point_of_sale: Automatically clear the search box after <Enter> from bar code reader

Nhomar - Vauxoo (nhomar) wrote :

Hello.

Please core team, can you merge this improvement please.

Regards.

review: Approve
review: Approve
Selami Demir (sdemir) wrote :

Hi,

It is work now.

Thank you.

review: Approve
Olivier Dony (Odoo) (odo-openerp) wrote :

Hello Carlos,

Well done, your change looks clean and simple enough to me. However I'm not an expert in 6.1 web modules, so I'm not sure if this is the best way to handle the <ENTER> event to autoselect a product.
I'll request a second review by someone from the web team.

Thanks for your good contribution!

review: Abstain

Could you rebase your patch on the latest 6.1 ?

Carlos Guerrero (guerrerocarlos) wrote :

There seems to be a merge in
http://bazaar.launchpad.net/~openerp/openobject-addons/6.1/revision/6726

But it is a very different amount of code, and doesn't include the "Reference" product field, but seems to be trying to solve the same issue.

Could someone enlight me about this?

Where can I see the "discussion" of that other [MERGE] ?

Lluis Gili Belmonte (tictacbum) wrote :

Hi, I am working on same issue, there's any update about this?
I tried applying Carlos patch, but sometimes OpenERP can't find products, and I have to close and reopen PoS to make it work.

Sometimes it also shows a warning message repeated several times (overlapped):

"Warningclose
The product could not be recognized. Please contact an employee."

Unmerged revisions

6706. By Carlos Guerrero on 2012-03-24

[IMP] point_of_sale: Automatically clear the search box after <Enter> from bar code reader

6705. By Carlos Guerrero on 2012-03-24

[FIX] point_of_sale: Add product to order automatically with <Enter> from barcode reader

6704. By Carlos Guerrero on 2012-03-24

[IMP] point_of_sale: lookup by barcode in the same if

6703. By Carlos Guerrero on 2012-03-23

[FIX] Validation for searching of all three fields: "name", "ean13" and "code"

6702. By Carlos Guerrero on 2012-03-23

[FIX] point_of_sale: Added product search by EAN13 or Reference in the POS

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'point_of_sale/static/src/js/pos.js'
2--- point_of_sale/static/src/js/pos.js 2012-02-24 14:49:39 +0000
3+++ point_of_sale/static/src/js/pos.js 2012-03-24 22:24:18 +0000
4@@ -85,7 +85,7 @@
5 }, this));
6 }, this));
7 $.when(this.fetch('pos.category', ['name', 'parent_id', 'child_id']),
8- this.fetch('product.product', ['name', 'list_price', 'pos_categ_id', 'taxes_id', 'product_image_small'], [['pos_categ_id', '!=', 'false']]),
9+ this.fetch('product.product', ['name','code','ean13', 'list_price', 'pos_categ_id', 'taxes_id', 'product_image_small'], [['pos_categ_id', '!=', 'false']]),
10 this.fetch('account.bank.statement', ['account_id', 'currency', 'journal_id', 'state', 'name'],
11 [['state', '=', 'open'], ['user_id', '=', this.session.uid]]),
12 this.fetch('account.journal', ['auto_cash', 'check_dtls', 'currency', 'name', 'type']),
13@@ -1259,19 +1259,27 @@
14 });
15 (this.shop.get('products')).reset(products);
16 var self = this;
17- $('.searchbox input').keyup(function() {
18- var m, s;
19+ $('.searchbox input').keyup(function(event) {
20+ var m, s, myproduct;
21 s = $(this).val().toLowerCase();
22 if (s) {
23 m = products.filter( function(p) {
24- return p.name.toLowerCase().indexOf(s) != -1;
25+ return (String(p.code).toLowerCase().indexOf(s) != -1) || (String(p.ean13).toLowerCase().indexOf(s) != -1) || (p.name.toLowerCase().indexOf(s) != -1);
26 });
27 $('.search-clear').fadeIn();
28 } else {
29 m = products;
30 $('.search-clear').fadeOut();
31 }
32- return (self.shop.get('products')).reset(m);
33+ if (m.length == 1 && event.keyCode == 13) {
34+ myproduct = self.shop.get('products').get(m[0]);
35+ self.shop.get('selectedOrder').addProduct(myproduct);
36+ $(this).val('');
37+ m = products;
38+ }
39+ return (self.shop.get('products')).reset(m);
40+
41+
42 });
43 return $('.search-clear').click( function() {
44 (this.shop.get('products')).reset(products);