Skip to content

Commit

Permalink
Merge pull request #470 from itpp-labs/16.0-sync
Browse files Browse the repository at this point in the history
  • Loading branch information
itpp-bot authored Dec 12, 2023
2 parents 46643ec + b949536 commit 0378d4a
Show file tree
Hide file tree
Showing 61 changed files with 6,286 additions and 0 deletions.
1 change: 1 addition & 0 deletions setup/sync/odoo/addons/sync
6 changes: 6 additions & 0 deletions setup/sync/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)
103 changes: 103 additions & 0 deletions sync/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
.. image:: https://itpp.dev/images/infinity-readme.png
:alt: Tested and maintained by IT Projects Labs
:target: https://itpp.dev

.. image:: https://img.shields.io/badge/license-MIT-blue.svg
:target: https://opensource.org/licenses/MIT
:alt: License: MIT

=============
Sync Studio
=============

Synchronize something with anything:

* System X ↔ Odoo
* Odoo 1 ↔ Odoo 2
* System X ↔ System Y

Provides a single place to handle synchronization trigered by one of the following events:

* **Cron** -- provided by ``ir.cron``
* **DB Event** -- provided by ``base.automation``
* **Incoming webhook** -- modified version of ``/website/action`` controller from ``website`` module
* **Manual Triggering** -- provided by ``ir.actions.server``. User needs to click a button to run this action

Difference with built-in code evaluation:

* Allows to use json format for incomming webhooks
* Provides helpers for resource linking. See *Links* section in `<doc/index.rst>`__
* Uses queue_job module as a job broker
* Asynchronous calls to split big task into few small ones
* Allows repeat job on temporary fails (e.g. when external API is not available)

Roadmap
=======

* Code widget: show line numbers
* Webhooks: add a possibility to retry failed webhook (e.g. to debug code)
* Webhooks: during the migration rename `website` appearances in links to `sync`. We decided not to do this in the stable branch to not break existing integrations

Developer Hints
===============

Public webhook address
----------------------

If you run Odoo locally and need to test webhook, your Odoo server should be available via public URL. You can either use specialized services like https://ngrok.com/ or make proxing via ssh tunneling as described in the next section. Once it's done set corresponding ``https://...`` value for ``web.base.url`` parameter (menu ``[[ Settings ]] >> System Parameters``). Also, you should set any value to `web.base.url.freeze <https://odoo-source.com/?q=web.base.url.freeze&i=nope&files=&excludeFiles=po%24%7Cpot%24%7Cyml%24%7Cyaml%24%7Ccss%24%7C%2Fstatic%2Flib%2F&repos=odoo>`__ to avoid automatic change of ``web.base.url``.

SSH tunneling
~~~~~~~~~~~~~

* Connect your server:

* Edit file ``/etc/ssh/sshd_config``:

* Find ``GatewayPorts`` attribute and set value to ``yes``

* Restart ssh daemon::

service ssh restart

* Connect to your server with ``-R`` attribute::

ssh [email protected] -R 0.0.0.0:8069:localhost:8069

Now you can use ``http://yourserver.example:8069`` as a value for ``web.base.url`` in Odoo.

Few more steps requires to use https connection (e.g. telegram api works with https only). In your server do as following:

* Install nginx in your server
* Add nginx config::

server {
listen 80;
server_name yourserver.example;
location / {
proxy_set_header Host $host;
proxy_pass http://localhost:8069;
}
}

* Install `certbot <https://certbot.eff.org/lets-encrypt/ubuntuxenial-nginx.html>`__
* Run
::

sudo certbot --nginx

* Done!

Questions?
==========

To get an assistance on this module contact us by email :arrow_right: [email protected]

Further information
===================

Odoo Apps Store: https://apps.odoo.com/apps/modules/14.0/sync/


Notifications on updates: `via Atom <https://github.com/itpp-labs/sync-addons/commits/15.0/sync.atom>`_, `by Email <https://blogtrottr.com/?subscribe=https://github.com/itpp-labs/sync-addons/commits/15.0/sync.atom>`_

Tested on `Odoo 15.0 <https://github.com/odoo/odoo/commit/77e62b56ce57edf621e4c7ed42d6b53a98fc044f>`_
7 changes: 7 additions & 0 deletions sync/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# License MIT (https://opensource.org/licenses/MIT).

from . import models
from . import wizard
from . import controllers
from . import lib
from . import tools
50 changes: 50 additions & 0 deletions sync/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Copyright 2020-2021 Ivan Yelizariev <https://twitter.com/yelizariev>
# Copyright 2020-2021 Denis Mudarisov <https://github.com/trojikman>
# Copyright 2021 Ilya Ilchenko <https://github.com/mentalko>
# License MIT (https://opensource.org/licenses/MIT).

{
"name": """Sync Studio""",
"summary": """Synchronize something with anything: SystemX↔Odoo, Odoo1↔Odoo2, SystemX↔SystemY. ETL/ESB tool similar to OCA/connector, but more flexible""",
"category": "Extra Tools",
"images": ["images/sync-studio.jpg"],
"version": "16.0.6.2.0",
"application": True,
"author": "IT Projects Labs, Ivan Yelizariev",
"support": "[email protected]",
"website": "https://sync_studio.t.me/",
"license": "Other OSI approved licence", # MIT
"depends": ["base_automation", "mail", "queue_job"],
"external_dependencies": {"python": [], "bin": []},
"data": [
"security/sync_groups.xml",
"security/ir.model.access.csv",
"views/sync_menus.xml",
"views/ir_logging_views.xml",
"views/sync_job_views.xml",
"views/sync_trigger_cron_views.xml",
"views/sync_trigger_automation_views.xml",
"views/sync_trigger_webhook_views.xml",
"views/sync_trigger_button_views.xml",
"views/sync_task_views.xml",
"views/sync_project_views.xml",
"views/sync_link_views.xml",
"wizard/sync_make_module_views.xml",
"data/queue_job_function_data.xml",
],
"demo": [
"data/sync_project_context_demo.xml",
"data/sync_project_telegram_demo.xml",
"data/sync_project_odoo2odoo_demo.xml",
"data/sync_project_trello_github_demo.xml",
"data/sync_project_unittest_demo.xml",
"data/sync_project_context_demo.xml",
],
"qweb": [],
"post_load": None,
"pre_init_hook": None,
"post_init_hook": None,
"uninstall_hook": None,
"auto_install": False,
"installable": True,
}
3 changes: 3 additions & 0 deletions sync/controllers/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# License MIT (https://opensource.org/licenses/MIT).

from . import webhook
36 changes: 36 additions & 0 deletions sync/controllers/webhook.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Copyright 2020 Ivan Yelizariev <https://twitter.com/yelizariev>
# Copyright 2021 Denis Mudarisov <https://github.com/trojikman>
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

from odoo import http

from ..lib.controllers.main import Website


class Webhook(Website):
@http.route(
[
"/website/action-json/<path_or_xml_id_or_id>",
"/website/action-json/<path_or_xml_id_or_id>/<path:path>",
],
type="json",
auth="public",
website=True,
csrf=False,
)
def actions_server_json(self, path_or_xml_id_or_id, **post):
res = self.actions_server(path_or_xml_id_or_id, **post)
return res.data

@http.route(
[
"/website/action-http/<path_or_xml_id_or_id>",
"/website/action-http/<path_or_xml_id_or_id>/<path:path>",
],
type="http",
auth="public",
website=True,
csrf=False,
)
def actions_server_http(self, path_or_xml_id_or_id, **post):
return self.actions_server(path_or_xml_id_or_id, **post)
13 changes: 13 additions & 0 deletions sync/data/queue_job_function_data.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!-- Copyright 2020 Ivan Yelizariev <https://twitter.com/yelizariev>
License MIT (https://opensource.org/licenses/MIT). -->
<odoo>
<record id="queue_job_function_task_run" model="queue.job.function">
<field name="model_id" ref="sync.model_sync_task" />
<field name="method">run</field>
<field
name="retry_pattern"
eval="{1: 5 * 60, 2: 15 * 60, 3: 60 * 60, 4: 3 * 60 * 60}"
/>
</record>
</odoo>
25 changes: 25 additions & 0 deletions sync/data/sync_project_context_demo.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<data>
<record id="sync_project_context_odoo2odoo_demo" model="sync.project.context">
<field name="name">odoo2odoo_demo</field>
<field name="display_name">Odoo2odoo (Demo)</field>
</record>
<record id="sync_project_context_telegram_demo" model="sync.project.context">
<field name="name">telegram_demo</field>
<field name="display_name">Telegram (Demo)</field>
</record>
<record id="sync_project_context_trello_demo" model="sync.project.context">
<field name="name">trello</field>
<field name="display_name">Trello (Demo)</field>
</record>
<record id="sync_project_context_github_demo" model="sync.project.context">
<field name="name">github</field>
<field name="display_name">Github (Demo)</field>
</record>
<record id="sync_project_context_math_demo" model="sync.project.context">
<field name="name">math</field>
<field name="display_name">Math functions (Demo)</field>
</record>
</data>
</odoo>
Loading

0 comments on commit 0378d4a

Please sign in to comment.