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
e0176a59
Commit
e0176a59
authored
Jul 13, 2023
by
Damien Moulard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
create module for mona & set eligible amount to payment line at mona payment & security checks
parent
9153baf5
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
272 additions
and
28 deletions
+272
-28
__init__.py
lacagette_addons/lacagette_mona/__init__.py
+1
-0
__openerp__.py
lacagette_addons/lacagette_mona/__openerp__.py
+28
-0
__init__.py
lacagette_addons/lacagette_mona/models/__init__.py
+2
-0
account_journal.py
lacagette_addons/lacagette_mona/models/account_journal.py
+10
-0
pos_config.py
lacagette_addons/lacagette_mona/models/pos_config.py
+9
-0
lacagette_mona.css
...e_addons/lacagette_mona/static/src/css/lacagette_mona.css
+23
-0
models.js
lacagette_addons/lacagette_mona/static/src/js/models.js
+48
-0
screens.js
lacagette_addons/lacagette_mona/static/src/js/screens.js
+71
-0
lacagette_mona.xml
...e_addons/lacagette_mona/static/src/xml/lacagette_mona.xml
+30
-0
templates.xml
lacagette_addons/lacagette_mona/views/templates.xml
+10
-0
view_account_journal.xml
...ette_addons/lacagette_mona/views/view_account_journal.xml
+17
-0
view_pos_config.xml
lacagette_addons/lacagette_mona/views/view_pos_config.xml
+17
-0
__openerp__.py
lacagette_addons/pos_meal_voucher/__openerp__.py
+0
-1
pos_meal_voucher.css
...dons/pos_meal_voucher/static/src/css/pos_meal_voucher.css
+5
-5
screens.js
lacagette_addons/pos_meal_voucher/static/src/js/screens.js
+1
-5
pos_meal_voucher.xml
...dons/pos_meal_voucher/static/src/xml/pos_meal_voucher.xml
+0
-17
No files found.
lacagette_addons/lacagette_mona/__init__.py
0 → 100644
View file @
e0176a59
from
.
import
models
lacagette_addons/lacagette_mona/__openerp__.py
0 → 100644
View file @
e0176a59
# -*- coding: utf-8 -*-
{
"name"
:
"La Cagette - MonA"
,
"summary"
:
"Handle the relation with MonA (Caisse Alimentaire Commune / Common Food Fund). "
"This module changes information handled by the Pos Meal Voucher module (eg meal voucher eligible amount)."
,
"version"
:
"1.0.0"
,
"category"
:
"Point of Sale"
,
"author"
:
"Damien Moulard"
,
"website"
:
"https://lacagette-coop.fr"
,
"depends"
:
[
"base"
,
"point_of_sale"
,
"pos_meal_voucher"
],
"data"
:
[
"views/templates.xml"
,
"views/view_pos_config.xml"
,
"views/view_account_journal.xml"
,
#"data/barcode_rule.xml",
#"data/ir_config_parameter_data.xml",
#"views/view_product_category.xml",
#"views/view_product_template.xml",
],
"qweb"
:
[
"static/src/xml/lacagette_mona.xml"
,
],
"installable"
:
True
,
}
lacagette_addons/lacagette_mona/models/__init__.py
0 → 100644
View file @
e0176a59
from
.
import
pos_config
from
.
import
account_journal
lacagette_addons/lacagette_mona/models/account_journal.py
0 → 100644
View file @
e0176a59
from
openerp
import
fields
,
models
class
AccountJournal
(
models
.
Model
):
_inherit
=
'account.journal'
mona_used
=
fields
.
Boolean
(
string
=
"Paiement en MonA"
,
default
=
False
)
lacagette_addons/lacagette_mona/models/pos_config.py
0 → 100644
View file @
e0176a59
from
openerp
import
fields
,
models
class
PosConfig
(
models
.
Model
):
_inherit
=
'pos.config'
enable_mona
=
fields
.
Boolean
(
string
=
"Activer le paiement MonA"
,
default
=
False
)
lacagette_addons/lacagette_mona/static/src/css/lacagette_mona.css
0 → 100644
View file @
e0176a59
.payment-screen
div
.monA-summary
{
border-top
:
dashed
1px
gainsboro
;
}
.payment-screen
div
.monA-summary
table
{
width
:
100%
;
}
.payment-screen
div
.monA-summary
tbody
{
background
:
white
;
}
.payment-screen
div
.monA-summary
th
{
font-size
:
16px
;
padding
:
8px
;
text-align
:
center
;
}
.payment-screen
div
.monA-summary
td
{
font-size
:
22px
;
padding
:
8px
12px
;
}
\ No newline at end of file
lacagette_addons/lacagette_mona/static/src/js/models.js
0 → 100644
View file @
e0176a59
odoo
.
define
(
"lacagette_mona.models"
,
function
(
require
)
{
"use strict"
;
var
models
=
require
(
"point_of_sale.models"
);
var
utils
=
require
(
"web.utils"
);
var
round_pr
=
utils
.
round_precision
;
models
.
load_fields
(
"account.journal"
,
[
"mona_used"
]);
var
OrderSuper
=
models
.
Order
.
prototype
;
var
Order
=
models
.
Order
.
extend
({
get_total_mona_received
:
function
(){
return
round_pr
(
this
.
paymentlines
.
reduce
((
function
(
sum
,
paymentLine
)
{
if
(
paymentLine
.
is_mona
())
{
return
sum
+
paymentLine
.
get_amount
();
}
else
{
return
sum
;
}
}),
0
),
this
.
pos
.
currency
.
rounding
);
},
get_total_mona_eligible_including_meal_vouchers
:
function
()
{
let
total_meal_voucher_received
=
this
.
get_total_meal_voucher_received
();
let
mona_eligible
=
this
.
get_total_meal_voucher_eligible
();
// eligible amount is the same as meal vouchers
// Since the same products are eligible for mona & meal vouchers, deduce one's eligible amount with the other's received amount
return
round_pr
(
mona_eligible
-
total_meal_voucher_received
,
this
.
pos
.
currency
.
rounding
);
},
get_total_meal_vouchers_eligible_including_mona
:
function
()
{
let
total_mona_received
=
this
.
get_total_mona_received
();
let
meal_voucher_eligible
=
this
.
get_total_meal_voucher_eligible
();
let
meal_voucher_max_amount
=
this
.
pos
.
config
.
max_meal_voucher_amount
;
return
round_pr
(
Math
.
min
(
meal_voucher_eligible
-
total_mona_received
,
meal_voucher_max_amount
),
this
.
pos
.
currency
.
rounding
);
},
});
models
.
Order
=
Order
;
var
PaymentlineSuper
=
models
.
Paymentline
.
prototype
;
var
Paymentline
=
models
.
Paymentline
.
extend
({
is_mona
:
function
()
{
return
this
.
cashregister
.
journal
.
mona_used
;
},
});
models
.
Paymentline
=
Paymentline
;
});
lacagette_addons/lacagette_mona/static/src/js/screens.js
0 → 100644
View file @
e0176a59
odoo
.
define
(
"lacagette_mona.screens"
,
function
(
require
)
{
"use strict"
;
var
screens
=
require
(
"point_of_sale.screens"
);
var
core
=
require
(
'web.core'
);
var
formats
=
require
(
'web.formats'
);
var
_t
=
core
.
_t
;
var
QWeb
=
core
.
qweb
;
var
Model
=
require
(
'web.DataModel'
);
var
config_parameter
=
new
Model
(
'ir.config_parameter'
);
screens
.
PaymentScreenWidget
.
include
({
click_paymentmethods
:
function
(
id
)
{
var
self
=
this
;
var
methods
=
this
.
_super
.
apply
(
this
,
arguments
);
var
paymentScreen
=
this
.
pos
.
gui
.
current_screen
;
var
order
=
this
.
pos
.
get_order
();
if
(
!
order
.
selected_paymentline
.
is_meal_voucher
()
&&
order
.
selected_paymentline
.
cashregister
.
journal
.
mona_used
)
{
let
total_mona_eligible
=
order
.
get_total_mona_eligible_including_meal_vouchers
();
order
.
selected_paymentline
.
set_amount
(
total_mona_eligible
);
paymentScreen
.
order_changes
();
paymentScreen
.
render_paymentlines
();
paymentScreen
.
$
(
".paymentline.selected .edit"
).
text
(
paymentScreen
.
format_currency_no_symbol
(
total_mona_eligible
));
let
total_mona_received
=
order
.
get_total_mona_received
();
if
(
total_mona_received
>
total_mona_eligible
)
{
this
.
gui
.
show_popup
(
"alert"
,
{
'title'
:
_t
(
"Impossible de rajouter un paiement MonA"
),
'body'
:
_t
(
"Le montant éligible a déjà été payé."
),
cancel
:
function
()
{
self
.
remove_selected_paymentline
(
order
);
}
});
}
}
else
if
(
order
.
selected_paymentline
.
is_meal_voucher
()
&&
order
.
get_total_meal_vouchers_eligible_including_mona
()
==
0
)
{
this
.
gui
.
show_popup
(
"alert"
,
{
'title'
:
_t
(
"Impossible de payer en titre restaurant"
),
'body'
:
_t
(
"Le montant éligible a déjà été payé en MonA."
),
cancel
:
function
()
{
self
.
remove_selected_paymentline
(
order
);
}
});
}
},
render_paymentlines
:
function
()
{
var
self
=
this
;
this
.
_super
.
apply
(
this
,
arguments
);
var
order
=
this
.
pos
.
get_order
();
if
(
!
order
)
{
return
;
}
// Update MonA summary
if
(
this
.
pos
.
config
.
enable_mona
)
{
let
total_mona_received
=
order
.
get_total_mona_received
();
let
total_mona_eligible
=
order
.
get_total_mona_eligible_including_meal_vouchers
();
let
total_meal_vouchers_eligible
=
order
.
get_total_meal_vouchers_eligible_including_mona
();
this
.
el
.
querySelector
(
"#monA-eligible-amount"
).
textContent
=
this
.
format_currency
(
total_mona_eligible
);
this
.
el
.
querySelector
(
"#meal-voucher-eligible-amount"
).
textContent
=
this
.
format_currency
(
total_meal_vouchers_eligible
);
this
.
el
.
querySelector
(
"#monA-received-amount"
).
textContent
=
this
.
format_currency
(
total_mona_received
);
}
},
});
});
lacagette_addons/lacagette_mona/static/src/xml/lacagette_mona.xml
0 → 100644
View file @
e0176a59
<?xml version="1.0" encoding="UTF-8"?>
<templates
id=
"template"
xml:space=
"preserve"
>
<t
t-extend=
"PaymentScreen-Paymentmethods"
>
<t
t-jquery=
"div.paymentmethods"
t-operation=
"after"
>
<div
t-if=
"widget.pos.config.enable_mona"
class=
"monA-summary"
>
<table
class=
"monA-summary"
>
<thead>
<tr>
<th
colspan=
"2"
>
MonA
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
Total Eligible
</td>
<td>
<span
id=
"monA-eligible-amount"
>
0.00 €
</span>
</td>
</tr>
<tr>
<td>
Total Received
</td>
<td>
<span
id=
"monA-received-amount"
>
0.00 €
</span>
</td>
</tr>
</tbody>
</table>
</div>
</t>
</t>
</templates>
lacagette_addons/lacagette_mona/views/templates.xml
0 → 100644
View file @
e0176a59
<?xml version="1.0" encoding="UTF-8"?>
<openerp>
<template
id=
"assets"
inherit_id=
"point_of_sale.assets"
>
<xpath
expr=
"."
position=
"inside"
>
<link
rel=
"stylesheet"
href=
"/lacagette_mona/static/src/css/lacagette_mona.css"
/>
<script
type=
"text/javascript"
src=
"/lacagette_mona/static/src/js/models.js"
></script>
<script
type=
"text/javascript"
src=
"/lacagette_mona/static/src/js/screens.js"
></script>
</xpath>
</template>
</openerp>
lacagette_addons/lacagette_mona/views/view_account_journal.xml
0 → 100644
View file @
e0176a59
<?xml version="1.0" encoding="UTF-8"?>
<openerp>
<record
id=
"view_account_journal"
model=
"ir.ui.view"
>
<field
name=
"model"
>
account.journal
</field>
<field
name=
"inherit_id"
ref=
"point_of_sale.view_account_journal_pos_user_form"
/>
<field
name=
"arch"
type=
"xml"
>
<xpath
expr=
"//field[@name='amount_authorized_diff']/.."
position=
"after"
>
<group
name=
"mona_section"
string=
"Caisse Alimentaire Commune"
>
<field
name=
"mona_used"
/>
</group>
</xpath>
</field>
</record>
</openerp>
lacagette_addons/lacagette_mona/views/view_pos_config.xml
0 → 100644
View file @
e0176a59
<?xml version="1.0" encoding="UTF-8"?>
<openerp>
<record
id=
"view_pos_config_form"
model=
"ir.ui.view"
>
<field
name=
"model"
>
pos.config
</field>
<field
name=
"inherit_id"
ref=
"point_of_sale.view_pos_config_form"
/>
<field
name=
"arch"
type=
"xml"
>
<field
name=
"journal_ids"
position=
"after"
>
<group
string=
"Caisse Alimentaire Commune"
>
<field
name=
"enable_mona"
/>
</group>
</field>
</field>
</record>
</openerp>
lacagette_addons/pos_meal_voucher/__openerp__.py
View file @
e0176a59
# Copyright (C) 2020 - Today: GRAP (http://www.grap.coop)
# @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
# TODO: Rendre l'affichage MonA paramétrable
{
"name"
:
"Point Of Sale - Meal Voucher"
,
"summary"
:
"Handle meal vouchers in Point of Sale"
...
...
lacagette_addons/pos_meal_voucher/static/src/css/pos_meal_voucher.css
View file @
e0176a59
...
...
@@ -37,7 +37,7 @@
background
:
rgba
(
255
,
255
,
255
,
0.4
);
}
.payment-screen
div
.meal-voucher-summary
,
.payment-screen
div
.monA-summary
{
.payment-screen
div
.meal-voucher-summary
{
border-top
:
dashed
1px
gainsboro
;
}
...
...
@@ -45,20 +45,20 @@
color
:
red
;
}
.payment-screen
div
.meal-voucher-summary
table
,
.payment-screen
div
.monA-summary
table
{
.payment-screen
div
.meal-voucher-summary
table
{
width
:
100%
;
}
.payment-screen
div
.meal-voucher-summary
tbody
,
.payment-screen
div
.monA-summary
tbody
{
.payment-screen
div
.meal-voucher-summary
tbody
{
background
:
white
;
}
.payment-screen
div
.meal-voucher-summary
th
,
.payment-screen
div
.monA-summary
th
{
.payment-screen
div
.meal-voucher-summary
th
{
font-size
:
16px
;
padding
:
8px
;
text-align
:
center
;
}
.payment-screen
div
.meal-voucher-summary
td
,
.payment-screen
div
.monA-summary
td
{
.payment-screen
div
.meal-voucher-summary
td
{
font-size
:
22px
;
padding
:
8px
12px
;
}
...
...
lacagette_addons/pos_meal_voucher/static/src/js/screens.js
View file @
e0176a59
...
...
@@ -311,7 +311,7 @@ odoo.define("pos_meal_voucher.screens", function (require) {
return
false
;
}
// if user choose card meal voucher
if
(
order
.
selected_paymentline
.
is_meal_voucher
()
&&
order
.
selected_paymentline
.
is_dematerialized_meal_voucher
()){
// update selected (last) payment line & order with meal voucher data
...
...
@@ -423,10 +423,6 @@ odoo.define("pos_meal_voucher.screens", function (require) {
if
(
!
this
.
meal_voucher_activated
())
{
this
.
$
(
".meal-voucher-summary"
).
addClass
(
"oe_hidden"
);
}
// Update MonA summary
this
.
el
.
querySelector
(
"#monA-eligible-amount"
).
textContent
=
this
.
format_currency
(
total_eligible
)
},
order_is_valid
:
function
(
force_validation
)
{
...
...
lacagette_addons/pos_meal_voucher/static/src/xml/pos_meal_voucher.xml
View file @
e0176a59
...
...
@@ -56,23 +56,6 @@
</tbody>
</table>
</div>
<div
class=
"monA-summary"
>
<table
class=
"monA-summary"
>
<thead>
<tr>
<th
colspan=
"2"
>
MonA
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
Total Eligible
</td>
<td>
<span
id=
"monA-eligible-amount"
>
0.00 €
</span>
</td>
</tr>
</tbody>
</table>
</div>
</t>
</t>
...
...
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