Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
O
odoo
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
cooperatic-foodcoops
odoo
Commits
e5d21217
Commit
e5d21217
authored
May 12, 2023
by
François C.
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#4074 : add product to order if scanned in search input
parent
7e8fb37e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
2 deletions
+41
-2
backend.js
...ette_addons/lacagette_custom_pos/static/src/js/backend.js
+41
-2
No files found.
lacagette_addons/lacagette_custom_pos/static/src/js/backend.js
View file @
e5d21217
...
...
@@ -128,7 +128,7 @@ odoo.define('lacagette_custom_pos.DB', function(require) {
this
.
category_cache
=
new
screens
.
DomCache
();
this
.
start_categ_id
=
this
.
pos
.
config
.
iface_start_categ_id
?
this
.
pos
.
config
.
iface_start_categ_id
[
0
]
:
0
;
this
.
set_category
(
this
.
pos
.
db
.
get_category_by_id
(
this
.
start_categ_id
));
this
.
switch_category_handler
=
function
(
event
){
self
.
set_category
(
self
.
pos
.
db
.
get_category_by_id
(
Number
(
this
.
dataset
.
categoryId
)));
self
.
renderElement
();
...
...
@@ -153,10 +153,49 @@ odoo.define('lacagette_custom_pos.DB', function(require) {
// Add timeout: loose focus after 5s without a keypress
clearTimeout
(
blur_timeout
)
blur_timeout
=
setTimeout
(
function
()
{
$
(
'.searchbox input'
).
blur
()
$
(
'.searchbox input'
).
blur
()
this
.
lastSubmittedQuery
=
null
;
},
5000
)
}
};
// If a barcode has been search, let's add it to the order
this
.
perform_search
=
function
(
category
,
query
,
buy_result
){
// redefine odoo/addons/point_of_sale/static/src/js/screens.js to fit need
var
products
;
if
(
query
){
let
significant_string
=
query
.
replace
(
/
[^
0-9
]
/g
,
''
)
if
(
significant_string
.
length
>
13
)
{
// The last scanned barcode is the last 13 figures
significant_string
=
significant_string
.
substring
(
significant_string
.
length
-
13
)
}
if
(
significant_string
.
length
>=
8
)
{
// it may be a barcode (it could be a string completed after getting new focus on search input)
// Remove every thing wich is not a figure
var
found_product
;
found_product
=
this
.
pos
.
db
.
get_product_by_barcode
(
significant_string
)
if
(
found_product
)
{
this
.
pos
.
get_order
().
add_product
(
found_product
);
this
.
clear_search
();
$
(
'.searchbox input'
).
blur
();
}
}
else
{
products
=
this
.
pos
.
db
.
search_product_in_category
(
category
.
id
,
query
);
if
(
buy_result
&&
products
.
length
===
1
){
this
.
pos
.
get_order
().
add_product
(
products
[
0
]);
this
.
clear_search
();
}
else
{
this
.
product_list_widget
.
set_product_list
(
products
);
}
}
}
else
{
products
=
this
.
pos
.
db
.
get_product_by_category
(
this
.
category
.
id
);
this
.
product_list_widget
.
set_product_list
(
products
);
}
}
}
})
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment