Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
third-party
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
2
Merge Requests
2
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
third-party
Commits
b9c9621d
Commit
b9c9621d
authored
Mar 08, 2022
by
Damien Moulard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
admin bdm - registrations - deleting a makeup adds a point
parent
41c352f2
Pipeline
#1882
passed with stage
in 1 minute 27 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
45 additions
and
12 deletions
+45
-12
admin.py
members/admin.py
+14
-4
manage_shift_registrations.css
members/static/css/admin/manage_shift_registrations.css
+4
-0
manage_shift_registrations.js
members/static/js/admin/manage_shift_registrations.js
+20
-5
models.py
shifts/models.py
+7
-3
No files found.
members/admin.py
View file @
b9c9621d
...
@@ -385,14 +385,24 @@ def delete_shift_registration(request):
...
@@ -385,14 +385,24 @@ def delete_shift_registration(request):
is_connected_user
=
CagetteUser
.
are_credentials_ok
(
request
)
is_connected_user
=
CagetteUser
.
are_credentials_ok
(
request
)
if
is_connected_user
is
True
:
if
is_connected_user
is
True
:
data
=
json
.
loads
(
request
.
body
.
decode
())
data
=
json
.
loads
(
request
.
body
.
decode
())
shift_registration_id
=
int
(
data
[
"shift_registration_id"
])
member_id
=
int
(
data
[
"member_id"
])
member_id
=
int
(
data
[
"member_id"
])
shift_registration_id
=
int
(
data
[
"shift_registration_id"
])
m
=
CagetteShift
()
shift_is_makeup
=
data
[
"shift_is_makeup"
]
res
[
"res"
]
=
m
.
cancel_shift
([
shift_registration_id
])
# Note: 'upcoming_registration_count' in res.partner won't change because the _compute method
# Note: 'upcoming_registration_count' in res.partner won't change because the _compute method
# in odoo counts canceled shift registrations.
# in odoo counts canceled shift registrations.
m
=
CagetteShift
()
res
[
"cancel_shift"
]
=
m
.
cancel_shift
([
shift_registration_id
])
if
shift_is_makeup
is
True
:
fields
=
{
'name'
:
"Admin BDM - Suppression d'un rattrapage"
,
'shift_id'
:
False
,
'type'
:
data
[
"member_shift_type"
],
'partner_id'
:
member_id
,
'point_qty'
:
1
}
res
[
"update_counter"
]
=
m
.
update_counter_event
(
fields
)
response
=
JsonResponse
(
res
,
safe
=
False
)
response
=
JsonResponse
(
res
,
safe
=
False
)
else
:
else
:
...
...
members/static/css/admin/manage_shift_registrations.css
View file @
b9c9621d
...
@@ -38,6 +38,10 @@
...
@@ -38,6 +38,10 @@
padding-top
:
0.755em
;
padding-top
:
0.755em
;
}
}
.makeup_row
{
background-color
:
#ffc854
!important
;
}
/* Search membres area */
/* Search membres area */
#search_member_area
{
#search_member_area
{
margin-top
:
30px
;
margin-top
:
30px
;
...
...
members/static/js/admin/manage_shift_registrations.js
View file @
b9c9621d
...
@@ -88,17 +88,29 @@ function display_member_shifts() {
...
@@ -88,17 +88,29 @@ function display_member_shifts() {
"sLoadingRecords"
:
"Chargement en cours..."
,
"sLoadingRecords"
:
"Chargement en cours..."
,
"sZeroRecords"
:
"Aucun élément à afficher"
,
"sZeroRecords"
:
"Aucun élément à afficher"
,
"sEmptyTable"
:
"Aucun futur service pour ce.tte membre"
"sEmptyTable"
:
"Aucun futur service pour ce.tte membre"
}
},
createdRow
:
function
(
row
,
rdata
)
{
if
(
rdata
.
is_makeup
===
true
)
{
$
(
row
).
addClass
(
"makeup_row"
);
$
(
row
).
prop
(
'title'
,
'Ce service est un rattrapage'
);
}
},
});
});
$
(
'#member_shifts_table'
).
on
(
'click'
,
'tbody td .delete_shift_registration'
,
function
()
{
$
(
'#member_shifts_table'
).
on
(
'click'
,
'tbody td .delete_shift_registration'
,
function
()
{
const
row_data
=
member_shifts_table
.
row
(
$
(
this
).
parents
(
'tr'
)).
data
();
const
row_data
=
member_shifts_table
.
row
(
$
(
this
).
parents
(
'tr'
)).
data
();
const
shift_reg_id
=
row_data
.
id
;
const
shift_reg_id
=
row_data
.
id
;
const
shift_is_makeup
=
row_data
.
is_makeup
;
let
msg
=
`<p>Enlever la présence de <b>
${
member
.
name
}
</b> au service du <b>
${
row_data
.
shift_id
[
1
]}
</b> ?</p>`
;
if
(
shift_is_makeup
===
true
)
{
msg
+=
`<p><i class="fas fa-exclamation-triangle"></i> Ce service est un rattrapage. Le supprimer ajoutera un point au compteur de ce.tte membre.</p>`
;
}
openModal
(
openModal
(
`Enlever la présence de
${
member
.
name
}
au service du
${
row_data
.
shift_id
[
1
]}
?`
,
msg
,
()
=>
{
()
=>
{
delete_shift_registration
(
shift_reg_id
);
delete_shift_registration
(
shift_reg_id
,
shift_is_makeup
);
},
},
"Confirmer"
,
"Confirmer"
,
false
false
...
@@ -109,13 +121,16 @@ function display_member_shifts() {
...
@@ -109,13 +121,16 @@ function display_member_shifts() {
/**
/**
* Send request to delete shift registration
* Send request to delete shift registration
* @param {Int} shift_reg_id Id of the shift_registration to delete
* @param {Int} shift_reg_id Id of the shift_registration to delete
* @param {Boolean} shift_is_makeup Is the shift a makeup?
*/
*/
function
delete_shift_registration
(
shift_reg_id
)
{
function
delete_shift_registration
(
shift_reg_id
,
shift_is_makeup
)
{
openModal
();
openModal
();
data
=
{
data
=
{
member_id
:
selected_member
.
id
,
member_id
:
selected_member
.
id
,
shift_registration_id
:
shift_reg_id
member_shift_type
:
selected_member
.
shift_type
,
shift_registration_id
:
shift_reg_id
,
shift_is_makeup
:
shift_is_makeup
};
};
$
.
ajax
({
$
.
ajax
({
...
...
shifts/models.py
View file @
b9c9621d
...
@@ -91,7 +91,7 @@ class CagetteShift(models.Model):
...
@@ -91,7 +91,7 @@ class CagetteShift(models.Model):
def
get_shift_partner
(
self
,
id
):
def
get_shift_partner
(
self
,
id
):
"""Récupère les shift du membre"""
"""Récupère les shift du membre"""
fields
=
[
'date_begin'
,
'date_end'
,
'final_standard_point'
,
fields
=
[
'date_begin'
,
'date_end'
,
'final_standard_point'
,
'shift_id'
,
'shift_type'
,
'partner_id'
,
"id"
,
"associate_registered"
]
# res.partner
'shift_id'
,
'shift_type'
,
'partner_id'
,
"id"
,
"associate_registered"
,
"is_makeup"
]
# res.partner
cond
=
[[
'partner_id.id'
,
'='
,
id
],[
'state'
,
'='
,
'open'
],
cond
=
[[
'partner_id.id'
,
'='
,
id
],[
'state'
,
'='
,
'open'
],
[
'date_begin'
,
'>'
,
datetime
.
datetime
.
now
()
.
isoformat
()]]
[
'date_begin'
,
'>'
,
datetime
.
datetime
.
now
()
.
isoformat
()]]
shiftData
=
self
.
o_api
.
search_read
(
'shift.registration'
,
cond
,
fields
,
order
=
"date_begin ASC"
)
shiftData
=
self
.
o_api
.
search_read
(
'shift.registration'
,
cond
,
fields
,
order
=
"date_begin ASC"
)
...
@@ -366,4 +366,8 @@ class CagetteShift(models.Model):
...
@@ -366,4 +366,8 @@ class CagetteShift(models.Model):
def
member_can_have_delay
(
self
,
partner_id
):
def
member_can_have_delay
(
self
,
partner_id
):
""" Can a member have a delay? """
""" Can a member have a delay? """
return
self
.
o_api
.
execute
(
'res.partner'
,
'can_have_extension'
,
[
partner_id
])
return
self
.
o_api
.
execute
(
'res.partner'
,
'can_have_extension'
,
[
partner_id
])
\ No newline at end of file
def
update_counter_event
(
self
,
fields
):
""" Add/remove points """
return
self
.
o_api
.
create
(
'shift.counter.event'
,
fields
)
\ No newline at end of file
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