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
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
14 deletions
+36
-14
res_partner.py
lacagette_addons/lacagette_membership/models/res_partner.py
+33
-11
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):
...
@@ -56,11 +56,29 @@ class ResPartner(models.Model):
new_values
[
'cooperative_state'
]
=
p
.
target_status
new_values
[
'cooperative_state'
]
=
p
.
target_status
if
new_values
[
'cooperative_state'
]
==
"unsubscribed"
:
if
new_values
[
'cooperative_state'
]
==
"unsubscribed"
:
new_values
[
'makeups_to_do'
]
=
makeups_todo_after_unsubscribed
new_values
[
'makeups_to_do'
]
=
makeups_todo_after_unsubscribed
new_values
[
'final_'
+
p
.
shift_type
+
'_point'
]
=
-
2
if
p
.
shift_type
==
'standard'
:
# Get points difference to set points to -2
new_values
[
'display_std_points'
]
=
-
2
current_points
=
p
[
'final_'
+
p
.
shift_type
+
'_point'
]
else
:
target_points
=
-
2
new_values
[
'display_ftop_points'
]
=
-
2
points_diff
=
abs
(
current_points
-
target_points
)
if
points_diff
!=
0
:
if
current_points
>
target_points
:
points_update
=
-
points_diff
else
:
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"
unlink model: "shift.template.registration"
to delete all future shifts linked to this coop.
to delete all future shifts linked to this coop.
...
@@ -73,16 +91,20 @@ class ResPartner(models.Model):
...
@@ -73,16 +91,20 @@ class ResPartner(models.Model):
.
search
([(
'partner_id'
,
'='
,
p
.
id
),
.
search
([(
'partner_id'
,
'='
,
p
.
id
),
(
'date_begin'
,
'>'
,
now
)]):
(
'date_begin'
,
'>'
,
now
)]):
sreg
.
unlink
()
sreg
.
unlink
()
# Close extensions
# Close extensions
for
ext
in
self
.
env
[
'shift.extension'
]
\
for
ext
in
self
.
env
[
'shift.extension'
]
\
.
search
([(
'partner_id'
,
'='
,
p
.
id
),
.
search
([(
'partner_id'
,
'='
,
p
.
id
),
(
'date_start'
,
'<='
,
now
),
(
'date_start'
,
'<='
,
now
),
(
'date_stop'
,
'>='
,
now
)]):
(
'date_stop'
,
'>='
,
now
)]):
ext
.
update
({
'date_stop'
:
now
})
ext
.
update
({
'date_stop'
:
now
})
mail_template
=
self
.
env
.
ref
(
'coop_membership.unsubscribe_email'
)
if
mail_template
:
try
:
mail_template
.
send_mail
(
p
.
id
)
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
)
p
.
update
(
new_values
)
except
Exception
as
e
:
except
Exception
as
e
:
_logger
.
error
(
"run_process_target_status :
%
s"
,
str
(
e
))
_logger
.
error
(
"run_process_target_status :
%
s"
,
str
(
e
))
...
@@ -148,7 +170,7 @@ class ResPartner(models.Model):
...
@@ -148,7 +170,7 @@ class ResPartner(models.Model):
@api.multi
@api.multi
def
update
(
self
,
vals
):
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
=
""
state_to_record
=
""
if
'cooperative_state'
in
vals
:
if
'cooperative_state'
in
vals
:
state_to_record
=
vals
[
'cooperative_state'
]
state_to_record
=
vals
[
'cooperative_state'
]
...
@@ -164,7 +186,7 @@ class ResPartner(models.Model):
...
@@ -164,7 +186,7 @@ class ResPartner(models.Model):
@api.multi
@api.multi
def
write
(
self
,
vals
):
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
:
if
'cooperative_state'
in
vals
:
self
.
_write_state_change
(
vals
[
'cooperative_state'
])
self
.
_write_state_change
(
vals
[
'cooperative_state'
])
return
super
(
ResPartner
,
self
)
.
write
(
vals
)
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):
...
@@ -36,13 +36,13 @@ class ShiftCounterEvent(models.Model):
@api.model
@api.model
def
write
(
self
,
vals
):
def
write
(
self
,
vals
):
res
=
super
(
ShiftCounterEvent
,
self
)
.
write
(
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
)
self
.
_update_partner_target_status
(
vals
)
return
res
return
res
@api.model
@api.model
def
create
(
self
,
vals
):
def
create
(
self
,
vals
):
self
.
_update_partner_target_status
(
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
)
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):
...
@@ -12,7 +12,7 @@ class ShiftTemplateRegistrationLine(models.Model):
def
create
(
self
,
vals
):
def
create
(
self
,
vals
):
super_res
=
super
(
ShiftTemplateRegistrationLine
,
self
.
with_context
(
super_res
=
super
(
ShiftTemplateRegistrationLine
,
self
.
with_context
(
dict
(
self
.
env
.
context
,
**
{
'creation_in_progress'
:
True
})))
.
create
(
vals
)
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
:
if
'partner_id'
in
vals
and
'shift_ticket_id'
in
vals
:
conf
=
self
.
env
[
'ir.config_parameter'
]
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