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
54208bec
Commit
54208bec
authored
5 months ago
by
François C.
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implements new way of sending shift reminder
parent
a3e3560c
nouvelle_implentation_mails_rappel
…
correctifs_lacagette_membership
No related merge requests found
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
77 additions
and
4 deletions
+77
-4
NEW_SHIFT_REMINDER.md
lacagette_addons/lacagette_shifts/NEW_SHIFT_REMINDER.md
+15
-0
email_template_data.xml
...ette_addons/lacagette_shifts/data/email_template_data.xml
+17
-0
ir_cron.xml
lacagette_addons/lacagette_shifts/data/ir_cron.xml
+17
-2
lacagette_shift_registrations.py
.../lacagette_shifts/models/lacagette_shift_registrations.py
+28
-2
No files found.
lacagette_addons/lacagette_shifts/NEW_SHIFT_REMINDER.md
0 → 100644
View file @
54208bec
After module updates, before activated new cron
===============================================
Run the following SQL command :
UPDATE shift_registration
SET reminder_mail_sent = true
WHERE id IN
(SELECT registration_id FROM shift_mail_registration WHERE mail_sent = true AND write_date
<
=
now
()
AND
write_date
>
now() - '14 days'::interval);
*
then Unactivate previous cron
activate new cron task
This diff is collapsed.
Click to expand it.
lacagette_addons/lacagette_shifts/data/email_template_data.xml
View file @
54208bec
...
...
@@ -28,4 +28,21 @@
</p>
]]>
</field>
</record>
<record
id=
"custom_shift_email_reminder"
model=
"mail.template"
>
<field
name=
"name"
>
Mail rappel service
</field>
<field
name=
"model_id"
ref=
"lacagette_shifts.model_shift_registration"
/>
<field
name=
"email_from"
>
${(object.partner_id.company_id.email or '')|safe}
</field>
<field
name=
"email_to"
>
${object.partner_id.email|safe}
</field>
<field
name=
"lang"
>
${object.partner_id.lang}
</field>
<field
name=
"reply_to"
>
${object.company_id.email|safe}
</field>
<field
name=
"subject"
>
Rappel du service ${object.shift_id.name}
</field>
<field
name=
"body_html"
>
<![CDATA[
Bonjour ${object.name},
Texte en rapport avec le magasin.
]]>
</field>
</record>
</odoo>
This diff is collapsed.
Click to expand it.
lacagette_addons/lacagette_shifts/data/ir_cron.xml
View file @
54208bec
...
...
@@ -19,4 +19,20 @@
<field
name=
"active"
eval=
"False"
/>
<field
name=
"priority"
>
2
</field>
</record>
</odoo>
\ No newline at end of file
<record
forcecreate=
"True"
id=
"cron_shift_reminder_email"
model=
"ir.cron"
>
<field
name=
"name"
>
LaCagette Shift Email Reminder
</field>
<field
name=
"user_id"
ref=
"base.user_root"
/>
<field
name=
"interval_number"
>
1
</field>
<field
name=
"interval_type"
>
days
</field>
<field
name=
"numbercall"
>
-1
</field>
<field
name=
"nextcall"
eval=
"(DateTime.now() + timedelta(days=1)).strftime('%Y-%m-%d 20:00:00')"
/>
<field
name=
"doall"
eval=
"False"
/>
<field
name=
"model"
eval=
"'shift.registration'"
/>
<field
name=
"function"
eval=
"'send_shift_reminder_emails'"
/>
<field
name=
"args"
eval=
"'()'"
/>
<field
name=
"active"
eval=
"False"
/>
<field
name=
"priority"
>
2
</field>
</record>
</odoo>
This diff is collapsed.
Click to expand it.
lacagette_addons/lacagette_shifts/models/lacagette_shift_registrations.py
View file @
54208bec
...
...
@@ -6,17 +6,28 @@ import datetime
class
ShiftRegistration
(
models
.
Model
):
_inherit
=
'shift.registration'
reminder_mail_sent
=
fields
.
Boolean
(
"Reminder mail has been sent"
,
default
=
False
)
@api.multi
def
send_shift_missing_email
(
self
):
mail_template
=
self
.
env
.
ref
(
'lacagette_shifts.missing_shift_email'
)
if
not
mail_template
:
return
False
for
reg_target
in
self
:
mail_template
.
send_mail
(
reg_target
.
id
)
return
True
@api.multi
def
send_shift_reminder_email
(
self
):
mail_template
=
self
.
env
.
ref
(
'lacagette_shifts.custom_shift_email_reminder'
)
if
not
mail_template
:
return
False
for
reg_target
in
self
:
mail_template
.
send_mail
(
reg_target
.
id
)
self
.
write
({
'reminder_mail_sent'
:
True
})
return
True
@api.model
def
send_shift_missing_emails
(
self
):
...
...
@@ -30,3 +41,18 @@ class ShiftRegistration(models.Model):
(
'date_begin'
,
'<'
,
now
.
strftime
(
"
%
Y-
%
m-
%
d
%
H:
%
M:
%
S"
))
])
reg_targets
.
send_shift_missing_email
()
@api.model
def
send_shift_reminder_emails
(
self
):
shift_env
=
self
.
env
[
'shift.registration'
]
# Find out the candidate shifts (between tomorrow and after tomorrow
# TODO : The time window could be changed, using odoo parameters
now
=
datetime
.
datetime
.
now
()
tomorrow
=
now
+
datetime
.
timedelta
(
hours
=
24
)
after_tomorrow
=
tomorrow
+
datetime
.
timedelta
(
hours
=
24
)
reg_targets
=
shift_env
.
search
([
(
'state'
,
'='
,
'open'
),
(
'reminder_mail_sent'
,
'='
,
False
),
(
'date_begin'
,
'>='
,
tomorrow
.
strftime
(
"
%
Y-
%
m-
%
d
%
H:
%
M:
%
S"
)),
(
'date_begin'
,
'<'
,
after_tomorrow
.
strftime
(
"
%
Y-
%
m-
%
d
%
H:
%
M:
%
S"
))])
reg_targets
.
send_shift_reminder_email
()
This diff is collapsed.
Click to expand it.
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