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
850f73f5
Commit
850f73f5
authored
Oct 04, 2024
by
François C.
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixing makups_to_do bug
parent
cc641c14
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
4 deletions
+16
-4
shift_counter_event.py
...addons/lacagette_membership/models/shift_counter_event.py
+16
-4
No files found.
lacagette_addons/lacagette_membership/models/shift_counter_event.py
View file @
850f73f5
...
@@ -128,6 +128,18 @@ class ShiftCounterEvent(models.Model):
...
@@ -128,6 +128,18 @@ class ShiftCounterEvent(models.Model):
return
None
return
None
return
result
return
result
def
_update_partner_makeups_to_do
(
self
,
vals
):
if
'technical_note'
in
vals
and
vals
[
'technical_note'
]
==
'no trigger'
:
return
0
try
:
if
'point_qty'
in
vals
and
vals
[
'point_qty'
]
<
0
:
res_partner
=
self
.
env
[
'res.partner'
]
.
search
([(
'id'
,
'='
,
vals
[
'partner_id'
])])
res_partner
[
0
]
.
update
({
makeups_to_do
:
partner
[
0
]
.
makeups_to_do
+
1
})
return
0
except
Exception
as
e
:
_logger
.
error
(
"_update_partner_makeups_to_do :
%
s"
,
str
(
e
))
return
1
def
_update_partner_target_status
(
self
,
vals
):
def
_update_partner_target_status
(
self
,
vals
):
"""actions when points are removed or added"""
"""actions when points are removed or added"""
partner
=
None
partner
=
None
...
@@ -142,7 +154,7 @@ class ShiftCounterEvent(models.Model):
...
@@ -142,7 +154,7 @@ class ShiftCounterEvent(models.Model):
to_consider_vals
=
vals
# TODO : Reimplement this adjustments
to_consider_vals
=
vals
# TODO : Reimplement this adjustments
if
res_partner
:
if
res_partner
:
partner
=
res_partner
[
0
]
partner
=
res_partner
[
0
]
_logger
.
info
(
"partner = :
%
s
"
,
str
(
partner
))
_logger
.
info
(
"partner = :
%
s
, makeups_to_do :
%
s"
,
str
(
partner
),
str
(
partner
.
makeups_to_do
))
if
to_consider_vals
[
'type'
]
!=
partner
.
shift_type
:
if
to_consider_vals
[
'type'
]
!=
partner
.
shift_type
:
_logger
.
error
(
"Counter shift type is not corresponding to partner shift_type :
%
s"
,
str
(
to_consider_vals
))
_logger
.
error
(
"Counter shift type is not corresponding to partner shift_type :
%
s"
,
str
(
to_consider_vals
))
return
None
return
None
...
@@ -171,8 +183,6 @@ class ShiftCounterEvent(models.Model):
...
@@ -171,8 +183,6 @@ class ShiftCounterEvent(models.Model):
target_status
=
'delay'
target_status
=
'delay'
if
target_status
is
not
None
:
if
target_status
is
not
None
:
vals_for_update
=
{
'working_state'
:
target_status
,
'cooperative_state'
:
target_status
}
vals_for_update
=
{
'working_state'
:
target_status
,
'cooperative_state'
:
target_status
}
if
vals
[
'point_qty'
]
<
0
:
vals_for_update
[
'makeups_to_do'
]
=
partner
.
makeups_to_do
+
1
partner
.
update
(
vals_for_update
)
partner
.
update
(
vals_for_update
)
if
target_status
==
'unsubscribed'
:
if
target_status
==
'unsubscribed'
:
self
.
unsubscribe_partner
(
partner
,
unsubscribe_limit
,
points_after_computation
)
self
.
unsubscribe_partner
(
partner
,
unsubscribe_limit
,
points_after_computation
)
...
@@ -189,8 +199,9 @@ class ShiftCounterEvent(models.Model):
...
@@ -189,8 +199,9 @@ class ShiftCounterEvent(models.Model):
@api.model
@api.model
def
write
(
self
,
vals
):
def
write
(
self
,
vals
):
res
=
super
(
ShiftCounterEvent
,
self
)
.
write
(
vals
)
_logger
.
info
(
"Vals recues =
%
s"
,
str
(
vals
))
_logger
.
info
(
"Vals recues =
%
s"
,
str
(
vals
))
self
.
_update_partner_makeups_to_do
(
vals
)
res
=
super
(
ShiftCounterEvent
,
self
)
.
write
(
vals
)
self
.
_update_partner_target_status
(
vals
)
self
.
_update_partner_target_status
(
vals
)
self
.
affect_associated_people
(
vals
[
'partner_id'
])
self
.
affect_associated_people
(
vals
[
'partner_id'
])
return
res
return
res
...
@@ -198,6 +209,7 @@ class ShiftCounterEvent(models.Model):
...
@@ -198,6 +209,7 @@ class ShiftCounterEvent(models.Model):
@api.model
@api.model
def
create
(
self
,
vals
):
def
create
(
self
,
vals
):
_logger
.
info
(
"Vals recues creation =
%
s"
,
str
(
vals
))
_logger
.
info
(
"Vals recues creation =
%
s"
,
str
(
vals
))
self
.
_update_partner_makeups_to_do
(
vals
)
res
=
super
(
ShiftCounterEvent
,
self
)
.
create
(
vals
)
res
=
super
(
ShiftCounterEvent
,
self
)
.
create
(
vals
)
self
.
_update_partner_target_status
(
vals
)
self
.
_update_partner_target_status
(
vals
)
self
.
affect_associated_people
(
vals
[
'partner_id'
])
self
.
affect_associated_people
(
vals
[
'partner_id'
])
...
...
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