Skip to content

Commit

Permalink
Merge PR #1 into 16.0
Browse files Browse the repository at this point in the history
Signed-off-by gurneyalex
  • Loading branch information
OCA-git-bot committed Apr 26, 2024
2 parents f3347bc + 84c9232 commit 2f5e225
Show file tree
Hide file tree
Showing 57 changed files with 6,178 additions and 0 deletions.
182 changes: 182 additions & 0 deletions automation_oca/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
==============
Automation Oca
==============

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:5d9710e6bc1697d84bcd87bdd88f0cf9544b2f82053cf7dc3f5c232f788a4a07
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fautomation-lightgray.png?logo=github
:target: https://github.com/OCA/automation/tree/16.0/automation_oca
:alt: OCA/automation
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/automation-16-0/automation-16-0-automation_oca
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/automation&target_branch=16.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

This module allows to automate several process according to some rules.

This is useful for creating automated actions on your database like:

- Send a welcome email to all new partners (or filtered according to
some rules)
- Remember to online customers that they forgot their basket with some
items
- Send documents to sign to all new employees

**Table of contents**

.. contents::
:local:

Usage
=====

Configure your processes
------------------------

1. Access the ``Automation`` menu.
2. Create a new Automation Configuration.
3. Set the model and domains.
4. Go to Configuration -> Filters to create filters as a preconfigured
domains. Filters can be established in the proper field in the
Automation Configuration record.
5. Create the different steps by clicking the "ADD" button inside the
automation configuration form.
6. Create child steps by clicking the "Add child activity" at the
bottom of a created step.
7.

8. Select the kind of configuration you create. You can choose between:

- *Periodic configurations*: every 6 hours, a process will check if
new records need to be created.
- *On demand configurations*: user need to execute manually the
job.

9. Press ``Start``.
10. Inside the process, you can check all the created items.

|Configuration Screenshot|

Configuration of steps
----------------------

Steps can trigger one of the following options:

- ``Mail``: Sends an email using a template.
- ``Server Action``: Executes a server action.
- ``Activity``: Creates an activity to the related record.

All the steps need to specify the moment of execution. We will set the
number of hours/days and a trigger type:

- ``Start of workflow``: It will be executed at the
previously-configured time after we create the record.
- ``Execution of another step``: It will be executed at the
previously-configured time after the previous step is finished
properly.
- ``Mail opened``: It will be executed at the previously-configured
time after the mail from the previous step is opened.
- ``Mail not opened``: It will be executed at the previously-configured
time after the mail from the previous step is sent if it is not
opened before this time.
- ``Mail replied``: It will be executed at the previously-configured
time after the mail from the previous step is replied.
- ``Mail not replied``: It will be executed at the
previously-configured time after the mail from the previous step is
opened if it has not been replied.
- ``Mail clicked``: It will be executed at the previously-configured
time after the links of the mail from the previous step are clicked.
- ``Mail not clicked``: It will be executed at the
previously-configured time after the mail from the previous step is
opened and no links are clicked.
- ``Mail bounced``: It will be executed at the previously-configured
time after the mail from the previous step is bounced back for any
reason.
- ``Activity has been finished``: It will be executed at the
previously-configured time after the activity from the previous
action is done.
- ``Activity has not been finished``: It will be executed at the
previously-configured time after the previous action is executed if
the related activity is not done.

Important to remember to define a proper template when sending the
email. It will the template without using a notification template. Also,
it is important to define correctly the text partner or email to field
on the template

Records creation
----------------

Records are created using a cron action. This action is executed every 6
hours by default.

Step execution
--------------

Steps are executed using a cron action. This action is executed every
hour by default. On the record view, you can execute manually an action.

.. |Configuration Screenshot| image:: https://raw.githubusercontent.com/OCA/automation/16.0/automation_oca/static/description/configuration.png

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/automation/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/automation/issues/new?body=module:%20automation_oca%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
-------

* Dixmit

Contributors
------------

- Enric Tobella (`Dixmit <https://www.dixmit.com/>`__)

Other credits
-------------

The development of this module has been financially supported by:

- Associacion Española de Odoo (`AEODOO <https://www.aeodoo.org/>`__)

Maintainers
-----------

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

This module is part of the `OCA/automation <https://github.com/OCA/automation/tree/16.0/automation_oca>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
3 changes: 3 additions & 0 deletions automation_oca/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from . import controllers
from . import models
from . import wizards
38 changes: 38 additions & 0 deletions automation_oca/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Copyright 2024 Dixmit
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

{
"name": "Automation Oca",
"summary": """
Automate actions in threaded models""",
"version": "16.0.1.0.0",
"license": "AGPL-3",
"category": "Automation",
"author": "Dixmit,Odoo Community Association (OCA)",
"website": "https://github.com/OCA/automation",
"depends": ["mail", "link_tracker"],
"data": [
"security/security.xml",
"security/ir.model.access.csv",
"views/menu.xml",
"wizards/automation_configuration_test.xml",
"views/automation_record.xml",
"views/automation_record_step.xml",
"views/automation_configuration_step.xml",
"views/automation_configuration.xml",
"views/link_tracker_clicks.xml",
"views/automation_filter.xml",
"views/automation_tag.xml",
"data/cron.xml",
],
"assets": {
"web.assets_backend": [
"automation_oca/static/src/**/*.js",
"automation_oca/static/src/**/*.xml",
"automation_oca/static/src/**/*.scss",
],
},
"demo": [
"demo/demo.xml",
],
}
1 change: 1 addition & 0 deletions automation_oca/controllers/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import main
65 changes: 65 additions & 0 deletions automation_oca/controllers/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Copyright 2024 Dixmit
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

import base64

from werkzeug.exceptions import NotFound

from odoo import http, tools
from odoo.http import Response, request
from odoo.tools import consteq


class AutomationOCAController(http.Controller):
# ------------------------------------------------------------
# TRACKING
# ------------------------------------------------------------

@http.route(
"/automation_oca/track/<int:record_id>/<string:token>/blank.gif",
type="http",
auth="public",
)
def automation_oca_mail_open(self, record_id, token, **post):
"""Email tracking. Blank item added.
We will return the blank item allways, but we will make the request only if
the data is correct"""
if consteq(
token,
tools.hmac(request.env(su=True), "automation_oca", record_id),
):
request.env["automation.record.step"].sudo().browse(
record_id
)._set_mail_open()
response = Response()
response.mimetype = "image/gif"
response.data = base64.b64decode(
b"R0lGODlhAQABAIAAANvf7wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw=="
# This is the code of a blank small image
)

return response

@http.route(
"/r/<string:code>/au/<int:record_id>/<string:token>", type="http", auth="public"
)
def automation_oca_redirect(self, code, record_id, token, **post):
# don't assume geoip is set, it is part of the website module
# which mass_mailing doesn't depend on
country_code = request.geoip.get("country_code")
automation_record_step_id = False
if consteq(
token,
tools.hmac(request.env(su=True), "automation_oca", record_id),
):
automation_record_step_id = record_id
request.env["link.tracker.click"].sudo().add_click(
code,
ip=request.httprequest.remote_addr,
country_code=country_code,
automation_record_step_id=automation_record_step_id,
)
redirect_url = request.env["link.tracker"].get_url_from_code(code)
if not redirect_url:
raise NotFound()
return request.redirect(redirect_url, code=301, local=False)
28 changes: 28 additions & 0 deletions automation_oca/data/cron.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo noupdate="1">
<record forcecreate="True" id="cron_step_execute" model="ir.cron">
<field name="name">Automation: Execute scheduled activities</field>
<field name="model_id" ref="model_automation_record_step" />
<field name="state">code</field>
<field name="code">model._cron_automation_steps()</field>
<field name="user_id" ref="base.user_root" />
<field name="interval_number">1</field>
<field name="interval_type">hours</field>
<field name="numbercall">-1</field>
<field name="active" eval="True" />
<field name="doall" eval="False" />
</record>
<record forcecreate="True" id="cron_configuration_run" model="ir.cron">
<field name="name">Automation: Create records</field>
<field name="model_id" ref="model_automation_configuration" />
<field name="state">code</field>
<field name="code">model.cron_automation()</field>
<field name="user_id" ref="base.user_root" />
<field name="interval_number">6</field>
<field name="interval_type">hours</field>
<field name="numbercall">-1</field>
<field name="active" eval="True" />
<field name="doall" eval="False" />
</record>

</odoo>
62 changes: 62 additions & 0 deletions automation_oca/demo/demo.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<record id="demo_tag_process" model="automation.tag">
<field name="name">Automatic Process</field>
</record>
<record id="demo_tag_demo" model="automation.tag">
<field name="name">Demo</field>
</record>

<record id="demo_bounce_action" model="ir.actions.server">
<field name="name">Blacklist Partner</field>
<field name="type">ir.actions.server</field>
<field name="state">code</field>
<field name="model_id" ref="base.model_res_partner" />
<field name="code">
for record in records.filtered(lambda r: not r.is_blacklisted):
env["mail.blacklist"].create({"email": record.email})
</field>
</record>
<record id="demo_welcome_template" model="mail.template">
<field name="name">Welcome</field>
<field name="model_id" ref="base.model_res_partner" />
<field name="partner_to">{{object.id}}</field>
<field name="subject">Welcome! Thanks for being part of our database</field>
<field name="body_html" type="html">
<p>Welcome!</p>
<p>Thanks <t t-out="object.name" /> for becoming a contact.</p>
<p>Kind regards,</p>
</field>
</record>
<record id="demo_configuration_welcome" model="automation.configuration">
<field name="name">Welcome email</field>
<field name="model_id" ref="base.model_res_partner" />
<field
name="tag_ids"
eval="[(4, ref('demo_tag_process')), (4, ref('demo_tag_demo'))]"
/>
<field name="field_id" ref="base.field_res_partner__email" />
<field name="editable_domain">[('email', '!=', False)]</field>
</record>
<record id="demo_configuration_welcome_send" model="automation.configuration.step">
<field name="name">Send email</field>
<field name="configuration_id" ref="demo_configuration_welcome" />
<field name="step_type">mail</field>
<field name="trigger_interval">2</field>
<field name="mail_template_id" ref="demo_welcome_template" />
</record>
<record
id="demo_configuration_welcome_bounced"
model="automation.configuration.step"
>
<field name="name">Blacklist bounced</field>
<field name="configuration_id" ref="demo_configuration_welcome" />
<field name="step_type">action</field>
<field name="trigger_type">mail_bounce</field>
<field name="expiry" eval="True" />
<field name="expiry_interval">24</field>
<field name="parent_id" ref="demo_configuration_welcome_send" />
<field name="trigger_interval">1</field>
<field name="server_action_id" ref="demo_bounce_action" />
</record>
</odoo>
10 changes: 10 additions & 0 deletions automation_oca/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from . import automation_configuration
from . import automation_configuration_step
from . import automation_record
from . import automation_record_step
from . import mail_mail
from . import mail_thread
from . import link_tracker
from . import automation_filter
from . import automation_tag
from . import mail_activity
Loading

0 comments on commit 2f5e225

Please sign in to comment.