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
3d909fc9
Commit
3d909fc9
authored
Jun 29, 2022
by
Damien Moulard
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
prevent payment if products at 0 or none
parent
aa009959
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
51 additions
and
0 deletions
+51
-0
screens.js
...ette_addons/lacagette_custom_pos/static/src/js/screens.js
+51
-0
No files found.
lacagette_addons/lacagette_custom_pos/static/src/js/screens.js
View file @
3d909fc9
...
@@ -132,6 +132,57 @@ odoo.define("lacagette_custom_pos.screens", function (require) {
...
@@ -132,6 +132,57 @@ odoo.define("lacagette_custom_pos.screens", function (require) {
}
}
});
});
screens
.
ActionpadWidget
.
include
({
renderElement
:
function
()
{
this
.
_super
();
this
.
$
(
'.pay'
).
off
(
'click'
);
// remove base event to redirect to payment screen
this
.
$
(
'.pay'
).
click
(()
=>
{
// Get order lines
let
orderlines
=
this
.
pos
.
get_order
().
orderlines
.
models
// Prevent payment if the order is empty
if
(
orderlines
.
length
==
0
)
{
this
.
gui
.
show_popup
(
"alert"
,
{
'title'
:
_t
(
"Paiement non autorisé"
),
'body'
:
_t
(
"Le panier doit contenir au moins 1 article."
)
});
return
;
}
// Prevent payment if any line in order has a 0 qty
let
products_empty_qty
=
[]
for
(
let
orderline
of
orderlines
)
{
if
(
orderline
.
quantity
===
0
)
{
products_empty_qty
.
push
(
orderline
);
}
}
if
(
products_empty_qty
.
length
>
0
)
{
let
msg
=
products_empty_qty
.
length
>
1
?
"Les articles "
:
"L'article "
;
products_empty_qty
.
forEach
((
el
)
=>
{
msg
+=
el
.
product
.
display_name
+
", "
;
});
msg
=
msg
.
substring
(
0
,
msg
.
length
-
2
);
// Remove last ", "
msg
+=
products_empty_qty
.
length
>
1
?
" ont "
:
" a "
;
msg
+=
"une quantité de zéro"
;
this
.
gui
.
show_popup
(
"alert"
,
{
'title'
:
_t
(
"Paiement non autorisé"
),
'body'
:
msg
});
return
;
}
// Redirect if all checks passed
this
.
gui
.
show_screen
(
'payment'
);
});
}
});
screens
.
ScreenWidget
.
include
({
screens
.
ScreenWidget
.
include
({
init
:
function
(
parent
,
options
){
init
:
function
(
parent
,
options
){
this
.
_super
(
parent
,
options
);
this
.
_super
(
parent
,
options
);
...
...
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