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
5db467b0
Commit
5db467b0
authored
Feb 09, 2022
by
Etienne Freiss
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
display a popup if the meal voucher was already scan on this order
parent
4183965e
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
68 additions
and
26 deletions
+68
-26
fr.po
lacagette_addons/pos_meal_voucher/i18n/fr.po
+22
-0
models.js
lacagette_addons/pos_meal_voucher/static/src/js/models.js
+9
-1
screens.js
lacagette_addons/pos_meal_voucher/static/src/js/screens.js
+37
-25
No files found.
lacagette_addons/pos_meal_voucher/i18n/fr.po
View file @
5db467b0
...
...
@@ -316,3 +316,24 @@ msgstr " ) est inférieur à la valeur du/des ticket(s)( "
#, python-format
msgid "Warning, the input amount of meal voucher is above the maximum amount of "
msgstr "Le montant saisi est supérieur au montant maximum/au maximum éligible de "
#. module: pos_meal_voucher
#. openerp-web
#: code:addons/pos_meal_voucher/static/src/js/screens.js:
#, python-format
msgid "Meal Voucher already used"
msgstr "Ticket restaurant déjà scanné"
#. module: pos_meal_voucher
#. openerp-web
#: code:addons/pos_meal_voucher/static/src/js/screens.js:
#, python-format
msgid "The paper meal voucher "
msgstr "Le ticket restaurant "
#. module: pos_meal_voucher
#. openerp-web
#: code:addons/pos_meal_voucher/static/src/js/screens.js:
#, python-format
msgid " was already used"
msgstr " a déjà été scanné"
\ No newline at end of file
lacagette_addons/pos_meal_voucher/static/src/js/models.js
View file @
5db467b0
...
...
@@ -7,7 +7,7 @@ odoo.define("pos_meal_voucher.models", function (require) {
var
models
=
require
(
"point_of_sale.models"
);
var
utils
=
require
(
"web.utils"
);
var
round_pr
=
utils
.
round_precision
;
models
.
load_fields
(
"product.product"
,
[
"meal_voucher_ok"
]);
...
...
@@ -16,6 +16,14 @@ odoo.define("pos_meal_voucher.models", function (require) {
var
OrderSuper
=
models
.
Order
.
prototype
;
var
Order
=
models
.
Order
.
extend
({
paper_meal_vouche_number_already_used
:
function
(
meal_voucher_number
){
for
(
const
paiementLine
of
this
.
get_paymentlines
()){
if
(
paiementLine
.
statement_note
==
meal_voucher_number
)
return
true
}
return
false
;
},
get_total_meal_voucher_eligible
:
function
()
{
return
round_pr
(
this
.
orderlines
.
reduce
((
function
(
sum
,
orderLine
)
{
...
...
lacagette_addons/pos_meal_voucher/static/src/js/screens.js
View file @
5db467b0
...
...
@@ -13,33 +13,46 @@ odoo.define("pos_meal_voucher.screens", function (require) {
screens
.
ScreenWidget
.
include
({
barcode_meal_voucher_payment_action
:
function
(
code
)
{
// Display the payment screen, if it is not the current one.
if
(
this
.
pos
.
gui
.
current_screen
.
template
!==
"PaymentScreenWidget"
){
this
.
gui
.
show_screen
(
"payment"
);
}
var
paymentScreen
=
this
.
pos
.
gui
.
current_screen
;
var
order
=
this
.
pos
.
get_order
();
var
amount
=
code
.
value
;
var
cashregister
=
null
;
// find a meal voucher cash register, if exist
for
(
var
i
=
0
;
i
<
this
.
pos
.
cashregisters
.
length
;
i
++
)
{
if
(
this
.
pos
.
cashregisters
[
i
].
journal
.
meal_voucher_type
===
"paper"
){
cashregister
=
this
.
pos
.
cashregisters
[
i
];
break
;
var
oder
=
this
.
pos
.
get_order
();
if
(
!
oder
.
paper_meal_vouche_number_already_used
(
code
.
code
)){
// Display the payment screen, if it is not the current one.
if
(
this
.
pos
.
gui
.
current_screen
.
template
!==
"PaymentScreenWidget"
){
this
.
gui
.
show_screen
(
"payment"
);
}
}
if
(
!
cashregister
){
return
;
var
paymentScreen
=
this
.
pos
.
gui
.
current_screen
;
var
order
=
this
.
pos
.
get_order
();
var
amount
=
code
.
value
;
var
cashregister
=
null
;
// find a meal voucher cash register, if exist
for
(
var
i
=
0
;
i
<
this
.
pos
.
cashregisters
.
length
;
i
++
)
{
if
(
this
.
pos
.
cashregisters
[
i
].
journal
.
meal_voucher_type
===
"paper"
){
cashregister
=
this
.
pos
.
cashregisters
[
i
];
break
;
}
}
if
(
!
cashregister
){
return
;
}
// Add new payment line with the amount found in the barcode
this
.
pos
.
get_order
().
add_paymentline
(
cashregister
);
paymentScreen
.
reset_input
()
order
.
selected_paymentline
.
set_amount
(
amount
);
order
.
selected_paymentline
.
statement_note
=
code
.
code
;
paymentScreen
.
order_changes
();
paymentScreen
.
render_paymentlines
();
paymentScreen
.
$
(
".paymentline.selected .edit"
).
text
(
paymentScreen
.
format_currency_no_symbol
(
amount
));
}
else
{
this
.
gui
.
show_popup
(
"alert"
,
{
'title'
:
_t
(
"Meal Voucher Amount already used"
),
'body'
:
_t
(
"The paper meal voucher "
)
+
code
.
code
+
_t
(
" was already used"
),
});
}
// Add new payment line with the amount found in the barcode
this
.
pos
.
get_order
().
add_paymentline
(
cashregister
);
paymentScreen
.
reset_input
()
order
.
selected_paymentline
.
set_amount
(
amount
);
order
.
selected_paymentline
.
statement_note
=
code
.
code
;
paymentScreen
.
order_changes
();
paymentScreen
.
render_paymentlines
();
paymentScreen
.
$
(
".paymentline.selected .edit"
).
text
(
paymentScreen
.
format_currency_no_symbol
(
amount
));
},
// Setup the callback action for the "meal_voucher_payment" barcodes.
...
...
@@ -97,7 +110,6 @@ odoo.define("pos_meal_voucher.screens", function (require) {
var
paymentScreen
=
this
.
pos
.
gui
.
current_screen
;
var
order
=
this
.
pos
.
get_order
();
if
(
order
.
selected_paymentline
.
is_dematerialized_meal_voucher
()){
var
total_eligible
=
order
.
get_total_meal_voucher_eligible
();
var
total_received
=
order
.
get_total_meal_voucher_received
();
...
...
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