2. Dynamic Business Processes using
Automated Actions
Daniel Reis
twitter: @reis_pt
email: dgreis(at)sapo.pt
https://github.com/dreispt
●
IT Applications at Securitas
●
Board Member at the Odoo
Community Association
●
Partner at ThinkOpen Solutions
●
Author of a couple of Odoo
development books
Introductions
3. Dynamic Business Processes using
Automated Actions
Dynamic Business Processes using
Automated Actions
"Can it automatically
assign requests to the
right person?"
"Can we see a
warning if the
customer has no
more credit?"
"We need prior
manager approval
for these requests"
"A reminder on
requests
unattended
for more than 3
days
would be great!"
Real people have very specific problems to
tackle
4. Dynamic Business Processes using
Automated Actions
Dynamic Business Processes using
Automated Actions
Automated Action Rules
5. Dynamic Business Processes using
Automated Actions
Dynamic Business Processes using
Automated Actions
Some useful
Techniques
• Post Messages to followers
• Add Follower and assign Responsibles
• Use Color and Priority
• Use Kanban States
• Use Actions on Time Conditions
• Use Warnings and “On change” Actions
6. Dynamic Business Processes using
Automated Actions
Dynamic Business Processes using
Automated Actions
1. New Task notifications should be more informative.
2. Special requests should be highlighted and given priority.
3. For particular customer conditions display warnings.
4. On warnings require approval from the Customer manager.
5. Automatically assign the work, based on Tags.
6. Remind about Tasks idle for 3 days
Requirements from our customer
7. Dynamic Business Processes using
Automated Actions
Dynamic Business Processes using
Automated Actions
#1 "New Task notifications should be more
informative"
Use
message_post()
Custom notification with
details such as Customer and
Tags
8. Dynamic Business Processes using
Automated Actions
Dynamic Business Processes using
Automated Actions
#1 Add an “On Create” Automated Action
9. Dynamic Business Processes using
Automated Actions
Dynamic Business Processes using
Automated Actions
title = "[New Task] %s" % object.name
tag_list = object.tag_ids.mapped('name')
tag_text = '; '.join(tag_list)
msg = """<ul>
<li>Tags: %s</li>
<li>Customer: %s</li>
</ul>
""" % (tag_text or 'None',
object.partner_id.name or 'None')
object.message_post(
subtype='mt_comment',
subject=title,
body=msg)
#1 Use message_post() in a Python Code Server
Action
10. Dynamic Business Processes using
Automated Actions
Dynamic Business Processes using
Automated Actions
#1 Disable the original “Task Opened”
notifications
11. Dynamic Business Processes using
Automated Actions
Dynamic Business Processes using
Automated Actions
tag_names = object.tag_ids.mapped('name')
if 'Urgent' in tag_names:
object.write({
'color': 2,
'priority': '1'})
john = env['res.users'].search(
[('login','=','john')].partner_id
object.message_subscribe([john.id])
#2 "Special requests should be highlighted and
given priority"
For specific Tags, such
as “Urgent”: change
color, priority, add
Followers
Write() Color and priority values
message_subscribe() to add followers
12. Dynamic Business Processes using
Automated Actions
Dynamic Business Processes using
Automated Actions
#3 "For particular customer conditions display
warnings"
I need to see a warning
when the customer has
overdue payments
“on change” actions
raise warning()
13. Dynamic Business Processes using
Automated Actions
Dynamic Business Processes using
Automated Actions
#3 Install the “warning” addon module
15. Dynamic Business Processes using
Automated Actions
Dynamic Business Processes using
Automated Actions
#3 Create an Action “Based on form
modification”
16. Dynamic Business Processes using
Automated Actions
Dynamic Business Processes using
Automated Actions
if object.partner_id.sale_warn_msg:
raise Warning(object.partner_id.sale_warn_msg)
#3 Raise the warning that was set on the
partner form
17. Dynamic Business Processes using
Automated Actions
Dynamic Business Processes using
Automated Actions
#4 "On warning, require an approval from the
customer manager"
Will use Kanban States
for approval state
18. Dynamic Business Processes using
Automated Actions
Dynamic Business Processes using
Automated Actions
if object.partner_id.sale_warn_msg:
approver = object.partner_id.user_id # the Manager
if not approver:
domain = [('login', '=', 'john')]
approver = self.env['res.users'].search(domain)
object.write({
'kanban_state': 'blocked',
'user_id': approver.id
})
#4 Request the approval to the customer
manager
If there are warnings,
request approval to the
customer
salesperson/manager
19. Dynamic Business Processes using
Automated Actions
Dynamic Business Processes using
Automated Actions
raise Warning(u'Approval required')
[('stage_id.sequence', '!=', 1)]
[('kanban_state', '=', 'blocked'),
('stage_id.sequence', '=', 1)]
#4 Automated Action to enforce that an
approval is required to proceed
“on change”
automated action
FROM FILTER
Python Action
TO FILTER
20. Dynamic Business Processes using
Automated Actions
Dynamic Business Processes using
Automated Actions
approver = object.partner_id.user_id
if env.user_id != approver:
raise Warning(u'Must be approved by %s' % approver)
[('kanban_state', '=', 'done')]
[('kanban_state', '=', 'done'),
('stage_id.sequence', '=', 1)]
#4 Automated Action to enforce that the
approver is the customer manager
FROM FILTER
Python Action
TO FILTER
21. Dynamic Business Processes using
Automated Actions
Dynamic Business Processes using
Automated Actions
[('kanban_state', '!=', 'done')]
[('stage_id.sequence', '=', 1)]
#5 "Automatically assign the work, based on
tags"
FROM FILTER
TO FILTER
22. Dynamic Business Processes using
Automated Actions
Dynamic Business Processes using
Automated Actions
categ_names = object.tag_ids.mapped('name')
categ_string = '; '.join(categ_names)
assign_name = None
if 'Desktop Support' in categ_string:
assign_name = 'demo'
# if … Other assignment conditions
if assign_name:
domain = [('login', '=', assign_name)]
asign = env['res.users'].search(domain, limit=1)
object.write({'user_id': asign.id,
'kanban_state': 'blocked'})
#5 Write the logic to pick a responsible and
assign it
PYTHON ACTION
23. Dynamic Business Processes using
Automated Actions
Dynamic Business Processes using
Automated Actions
msg = "[Reminder] %s needs love!" % object.name
object.message_post(
body=msg,
subtype='mt_comment',
)
#6 "Remind about tasks idle for 3 days"
AUTOMATED ACTIONS ON TIME CONDITIONS
24. Dynamic Business Processes using
Automated Actions
Dynamic Business Processes using
Automated Actions
1. New Task notifications should be more informative:
use message_post() to create custom notification texts.
2. Special requests should be highlighted and given priority:
use write() on the color and priority fields.
3. For particular customer conditions display warnings:
use "On change" actions with a raise Warning().
Our solution for the customer requirements
25. Dynamic Business Processes using
Automated Actions
Dynamic Business Processes using
Automated Actions
4. On warnings require approval from the Customer manager:
use Kanban State
5. Automatically assign the work, based on Tags.
code the rules in Python and use write() to assign the user_id
6. Remind about Tasks idle for 3 days
use "Timed Condition" scheduled actions
Our solution for the customer requirements
26. Lisboa
Miraflores Office Center
Avenida das Tulipas, nº6, 13º A/B
1495-161 Algés
t: 808 455 255
e: sales@thinkopen.solutions
Porto
Rua do Espinheiro, nº 641
2,Escritório 2.3
4400-450 Vila Nova de Gaia
t: 808 455 255
e: sales@thinkopen.solutions
São Paulo
Av Paulista 1636,
São Paulo, SP
t: +55 (11) 957807759 / 50493125
e: info.br@tkobr.com
Luanda
Rua Dr. António Agostinho Neto 43
Bairro Operário, Luanda Angola
t: +244 923 510 491
e: comercial@thinkopensolutions.co.ao
Find more about
Automated actions in chapter 12
of the Odoo Development
Cookbook
Thank you
Daniel Reis
twitter: @reis_pt
email: dgreis(at)sapo.pt
www.thinkopen.solutions