16.0-negative-leaves-and-allocation #13

Merged
laetitiadacosta merged 5 commits from 16.0-negative-leaves-and-allocation into 16.0 2025-11-24 10:00:02 +00:00
No description provided.
laetitiadacosta added 4 commits 2025-10-31 09:00:30 +00:00
Author
Owner
lié à la tache https://elabore.coop/web#id=5573&menu_id=198&cids=1&action=317&active_id=122&model=project.task&view_type=form
laetitiadacosta added 1 commit 2025-11-07 09:33:20 +00:00
[IMP]hr_negative_leave:add tests
Some checks failed
pre-commit / pre-commit (pull_request) Failing after 1m29s
80cfc25a0a
Owner

Coverage de 78% pour hr_leave_type.py, c'est plutôt cool :)

Je te mets des captures d'écran pour voir les parties non couvertes :

image.png image.png image.png image.png image.png
Coverage de 78% pour `hr_leave_type.py`, c'est plutôt cool :) Je te mets des captures d'écran pour voir les parties non couvertes : <img width="698" alt="image.png" src="attachments/18f41faa-af41-4f30-8075-c86de540e825"> <img width="743" alt="image.png" src="attachments/30f30e48-03e2-4ff4-9d83-4b5830e16588"> <img width="642" alt="image.png" src="attachments/5c2ab668-f1f1-4280-b980-f81a451a1b22"> <img width="960" alt="image.png" src="attachments/d3b90119-af27-41d7-b2a7-087d6059e063"> <img width="960" alt="image.png" src="attachments/11b061cd-75d6-44e1-a7f8-8d8ba75c7da9">
mondot requested changes 2025-11-12 16:18:29 +00:00
mondot left a comment
Owner

Ce qui est rassurant c'est que les tests de hr_holidays passent :)

Ce qui est rassurant c'est que les tests de `hr_holidays` passent :)
@@ -0,0 +24,4 @@
for holiday_type in self:
if holiday_type.allows_negative:
# if left != usable : remaining_leaves_allowing_negative = left + usable
if holiday_type.virtual_remaining_leaves < 0 (holiday_type.max_leaves - holiday_type.virtual_leaves_taken) != holiday_type.virtual_remaining_leaves:
Owner

Tu peux ajouter des tests pour ce compute please ?

On se serait vite rendu compte qu'il manque qqch dans la formulation
if holiday_type.virtual_remaining_leaves < 0 (holiday_type.max_leaves - holiday_type.virtual_leaves_taken) != holiday_type.virtual_remaining_leaves:

(à priori un and ?)

Tu peux ajouter des tests pour ce compute please ? On se serait vite rendu compte qu'il manque qqch dans la formulation `if holiday_type.virtual_remaining_leaves < 0 (holiday_type.max_leaves - holiday_type.virtual_leaves_taken) != holiday_type.virtual_remaining_leaves:` (à priori un `and` ?)
Owner

Vu ensemble, remaining_leaves_allowing_negative à supprimer.

Vu ensemble, remaining_leaves_allowing_negative à supprimer.
Author
Owner

c'est un reliquat de code qui n'est plus utilisé nulle part et que j'ai oublié de supprimer, c'est maintenant fait

c'est un reliquat de code qui n'est plus utilisé nulle part et que j'ai oublié de supprimer, c'est maintenant fait
@@ -0,0 +37,4 @@
res = super()._compute_valid()
for holiday_type in res:
if not holiday_type.has_valid_allocation:
holiday_type.has_valid_allocation = holiday_type.allows_negative
Owner

en faisant ça tu mets sous le tapis toute cette condition

                allocation = self.env['hr.leave.allocation'].search([
                    ('holiday_status_id', '=', holiday_type.id),
                    ('employee_id', '=', employee_id),
                    '|',
                    ('date_to', '>=', date_to),
                    '&',
                    ('date_to', '=', False),
                    ('date_from', '<=', date_from)])
                holiday_type.has_valid_allocation = bool(allocation)

qu'on retrouve dans le _compute_valid(), non ?

en faisant ça tu mets sous le tapis toute cette condition ``` allocation = self.env['hr.leave.allocation'].search([ ('holiday_status_id', '=', holiday_type.id), ('employee_id', '=', employee_id), '|', ('date_to', '>=', date_to), '&', ('date_to', '=', False), ('date_from', '<=', date_from)]) holiday_type.has_valid_allocation = bool(allocation) ``` qu'on retrouve dans le `_compute_valid()`, non ?
Owner

Vu ensemble : mettre un petit commentaire qui explique que has_valid_allocation n'a plus de sens si on accepte les congés négatifs

Vu ensemble : mettre un petit commentaire qui explique que has_valid_allocation n'a plus de sens si on accepte les congés négatifs
Author
Owner

vu en visio avec @mondot , j'ai ajouté un commentaire pour expliquer le code

vu en visio avec @mondot , j'ai ajouté un commentaire pour expliquer le code
@@ -0,0 +40,4 @@
holiday_type.has_valid_allocation = holiday_type.allows_negative
#overwrite _get_employees_days_per_allocation() from hr_holidays module
def _get_employees_days_per_allocation(self, employee_ids, date=None):
Owner

J'ai du mal à comprendre cette maxi fonction. Je veux bien qu'on voit ça ensemble.

J'ai du mal à comprendre cette maxi fonction. Je veux bien qu'on voit ça ensemble.
mondot reviewed 2025-11-13 15:25:55 +00:00
@@ -0,0 +165,4 @@
# if negative is not allowed for this leave type, then we cannot exceed the allocation amount
# the max leaves for this allocation is the minimum between the remaining available days and the leave duration
max_leaves = min(virtual_remaining_leaves, leave_duration)
# the new calculation of days taken for this allocation is previous taken + max_leaves (which can never exceed the allocation total)
Owner
                                    ###########################################
                                    # END OF Modification for leaves allowing negative #
                                    ###########################################
########################################### # END OF Modification for leaves allowing negative # ###########################################
Author
Owner

ok

ok
mondot reviewed 2025-11-13 15:38:32 +00:00
@@ -0,0 +39,4 @@
if not holiday_type.has_valid_allocation:
holiday_type.has_valid_allocation = holiday_type.allows_negative
#overwrite _get_employees_days_per_allocation() from hr_holidays module
Owner

on pourrait ajouter
# Check for 'Modification for leaves allowing negative' to see the modifications

on pourrait ajouter `# Check for 'Modification for leaves allowing negative' to see the modifications`
laetitiadacosta added 2 commits 2025-11-24 09:55:14 +00:00
[IMP]hr_negative_leave:add tests
Some checks failed
pre-commit / pre-commit (pull_request) Failing after 1m29s
80cfc25a0a
[IMP]hr_negative_leave:add tests
Some checks failed
pre-commit / pre-commit (pull_request) Failing after 1m30s
2d36c701bf
laetitiadacosta added 2 commits 2025-11-24 09:58:03 +00:00
[IMP]hr_negative_leave:add tests
Some checks failed
pre-commit / pre-commit (pull_request) Failing after 1m30s
2d36c701bf
[IMP]hr_negative_leave:add tests
Some checks failed
pre-commit / pre-commit (pull_request) Failing after 1m29s
726e34febc
laetitiadacosta merged commit 726e34febc into 16.0 2025-11-24 10:00:02 +00:00
laetitiadacosta deleted branch 16.0-negative-leaves-and-allocation 2025-11-24 10:00:02 +00:00
Sign in to join this conversation.
No description provided.