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
aee62659
Commit
aee62659
authored
Jan 20, 2022
by
Damien Moulard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add points instead of forcing points counter when unbsuscribing partner
parent
d5e94325
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
10 deletions
+32
-10
res_partner.py
lacagette_addons/lacagette_membership/models/res_partner.py
+29
-7
shift_counter_event.py
...addons/lacagette_membership/models/shift_counter_event.py
+2
-2
shift_template_registration_line.py
...tte_membership/models/shift_template_registration_line.py
+1
-1
No files found.
lacagette_addons/lacagette_membership/models/res_partner.py
View file @
aee62659
...
...
@@ -56,11 +56,29 @@ class ResPartner(models.Model):
new_values
[
'cooperative_state'
]
=
p
.
target_status
if
new_values
[
'cooperative_state'
]
==
"unsubscribed"
:
new_values
[
'makeups_to_do'
]
=
makeups_todo_after_unsubscribed
new_values
[
'final_'
+
p
.
shift_type
+
'_point'
]
=
-
2
if
p
.
shift_type
==
'standard'
:
new_values
[
'display_std_points'
]
=
-
2
# Get points difference to set points to -2
current_points
=
p
[
'final_'
+
p
.
shift_type
+
'_point'
]
target_points
=
-
2
points_diff
=
abs
(
current_points
-
target_points
)
if
points_diff
!=
0
:
if
current_points
>
target_points
:
points_update
=
-
points_diff
else
:
new_values
[
'display_ftop_points'
]
=
-
2
points_update
=
points_diff
data
=
{
'name'
:
"Désinscription : passage à -2 pts"
,
'shift_id'
:
False
,
'type'
:
p
.
shift_type
,
'partner_id'
:
p
.
id
,
'point_qty'
:
points_update
}
self
.
env
[
'shift.counter.event'
]
.
create
(
data
)
"""
unlink model: "shift.template.registration"
to delete all future shifts linked to this coop.
...
...
@@ -73,16 +91,20 @@ class ResPartner(models.Model):
.
search
([(
'partner_id'
,
'='
,
p
.
id
),
(
'date_begin'
,
'>'
,
now
)]):
sreg
.
unlink
()
# Close extensions
# Close extensions
for
ext
in
self
.
env
[
'shift.extension'
]
\
.
search
([(
'partner_id'
,
'='
,
p
.
id
),
(
'date_start'
,
'<='
,
now
),
(
'date_stop'
,
'>='
,
now
)]):
ext
.
update
({
'date_stop'
:
now
})
try
:
mail_template
=
self
.
env
.
ref
(
'coop_membership.unsubscribe_email'
)
if
mail_template
:
mail_template
.
send_mail
(
p
.
id
)
except
Exception
as
e
:
_logger
.
error
(
"run_process_target_status - send mail :
%
s - Process not interrupted"
,
str
(
e
))
p
.
update
(
new_values
)
except
Exception
as
e
:
_logger
.
error
(
"run_process_target_status :
%
s"
,
str
(
e
))
...
...
@@ -148,7 +170,7 @@ class ResPartner(models.Model):
@api.multi
def
update
(
self
,
vals
):
_logger
.
info
(
"valeurs re
ç
ues pour update partner =
%
s"
,
str
(
vals
))
_logger
.
info
(
"valeurs re
c
ues pour update partner =
%
s"
,
str
(
vals
))
state_to_record
=
""
if
'cooperative_state'
in
vals
:
state_to_record
=
vals
[
'cooperative_state'
]
...
...
@@ -164,7 +186,7 @@ class ResPartner(models.Model):
@api.multi
def
write
(
self
,
vals
):
_logger
.
info
(
"valeurs re
ç
ues pour write partner =
%
s"
,
str
(
vals
))
_logger
.
info
(
"valeurs re
c
ues pour write partner =
%
s"
,
str
(
vals
))
if
'cooperative_state'
in
vals
:
self
.
_write_state_change
(
vals
[
'cooperative_state'
])
return
super
(
ResPartner
,
self
)
.
write
(
vals
)
...
...
lacagette_addons/lacagette_membership/models/shift_counter_event.py
View file @
aee62659
...
...
@@ -36,13 +36,13 @@ class ShiftCounterEvent(models.Model):
@api.model
def
write
(
self
,
vals
):
res
=
super
(
ShiftCounterEvent
,
self
)
.
write
(
vals
)
_logger
.
info
(
"Vals re
ç
ues =
%
s"
,
str
(
vals
))
_logger
.
info
(
"Vals re
c
ues =
%
s"
,
str
(
vals
))
self
.
_update_partner_target_status
(
vals
)
return
res
@api.model
def
create
(
self
,
vals
):
self
.
_update_partner_target_status
(
vals
)
_logger
.
info
(
"Vals re
ç
ues creation =
%
s"
,
str
(
vals
))
_logger
.
info
(
"Vals re
c
ues creation =
%
s"
,
str
(
vals
))
return
super
(
ShiftCounterEvent
,
self
)
.
create
(
vals
)
lacagette_addons/lacagette_membership/models/shift_template_registration_line.py
View file @
aee62659
...
...
@@ -12,7 +12,7 @@ class ShiftTemplateRegistrationLine(models.Model):
def
create
(
self
,
vals
):
super_res
=
super
(
ShiftTemplateRegistrationLine
,
self
.
with_context
(
dict
(
self
.
env
.
context
,
**
{
'creation_in_progress'
:
True
})))
.
create
(
vals
)
#_logger.info("valeurs re
ç
ues pour create shift.template.registration.line = %s", str(vals))
#_logger.info("valeurs re
c
ues pour create shift.template.registration.line = %s", str(vals))
if
'partner_id'
in
vals
and
'shift_ticket_id'
in
vals
:
conf
=
self
.
env
[
'ir.config_parameter'
]
...
...
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