Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
723 commits
Select commit Hold shift + click to select a range
8f08bcc
Allow to assign a default channel on @job functions
Apr 24, 2015
86e3568
[IMP] add attribute 'exported_fields'on Mapper classes to list the ex…
bguillot May 25, 2015
23c55eb
[FIX] remove useless print
bguillot May 28, 2015
a026e2f
[ADD] support function on direct fields
bguillot Jun 1, 2015
e770235
[IMP] rename exported_fields to changed_by_fields
bguillot Jun 1, 2015
0a6b865
[ADD] comment
bguillot Jun 1, 2015
2e93aa2
See if we can remove install_in_connector() by checking in ir.module.…
Jun 1, 2015
aebf3a3
Update doc
Jun 1, 2015
e138d53
Fix, the method 'module_uninstall' invalid the ormcache of is_module_…
Jun 1, 2015
19113b6
[FIX] change list to set and fix nested direct functions
bguillot Jun 1, 2015
f3181c7
improve comparaison test
Jun 1, 2015
2e21a02
[IMP] add tests for _changed_by_fields attribute
bguillot Jun 1, 2015
dc4466f
[FIX] use staticmethod to keep _mapping_field_name() inside the metac…
bguillot Jun 1, 2015
9b1be31
[FIX] _mapping_field_name()
bguillot Jun 1, 2015
4a704ee
[FIX] useless blank line
bguillot Jun 1, 2015
ee68903
no need to call self.env['ir.module.module'] in ir.module.module model
Jun 1, 2015
281afb8
no check a boolean value with None value
Jun 1, 2015
e477c72
[FIX] clean code
bguillot Jun 1, 2015
2538419
[FIX] rename method
bguillot Jun 1, 2015
bd98b2f
[FIX] flake8
bguillot Jun 1, 2015
5099b38
Fix is_module_installed function, check if one model of the module co…
Jun 2, 2015
aab3299
Fix unittest, when test is called by odoo, the module are not in the …
Jun 2, 2015
7df5210
[FIX] get the exact field name (mapping the closure entries)
bguillot Jun 2, 2015
afb6cf1
Invalid cache in write method only if the state is in the value to up…
Jun 2, 2015
29bb618
Update docstrings by Guewen (c2c)
Jun 2, 2015
b9928b9
Set Odoo path from travis environ
guewen Jun 1, 2015
6a57789
Use odoo-sphinx-autodoc to build correctly the doc
guewen Jun 2, 2015
097cdeb
New test: check if the cache is different for different modules
guewen Jun 3, 2015
857cada
Rename module.py to ir_module_module.py
guewen Jun 3, 2015
4f85a35
Test the cache invalidation on 'base' instead of 'connector'
guewen Jun 3, 2015
9c6384c
Remove useless trick in is_module_installed
guewen Jun 3, 2015
670f64a
[IMP] job view
bealdav Jun 4, 2015
68f120d
[FIX] common.DB is gone in 8.0 stable
sbidoul Jun 12, 2015
60b5ecd
[DOC] small improvent
mathi123 Jun 16, 2015
4ed5a5c
manage retryable job with runner
Jul 2, 2015
9e2ca29
Add an index on queue_job.worker_id
Jul 2, 2015
089df64
[IMP] Add retry pattern for jobs
JosDeGraeve Jun 1, 2015
ee97d28
FIX: sort the retry dictionairy by retry count
JosDeGraeve Jun 1, 2015
8510176
Keep the retry pattern on the @job definition rather than in jobs
guewen Jun 2, 2015
be08f68
Use seconds of the higher retry count of the retry pattern
guewen Jun 2, 2015
304ed3f
Remove field queue_job.retry_pattern
Jun 9, 2015
c7097e0
Add line in the changes file
Jul 3, 2015
454c427
Mapper: add modifier to follow m2o relations
LeartS Jul 14, 2015
e3e5e05
Add simple test case and fix PEP8
LeartS Jul 14, 2015
ec5797f
Move fields to avoid jobs view overflows
Jul 23, 2015
6f6d013
A None capacity means infinite. Fix logging error
Jul 24, 2015
f51153d
Do not pass self as 'message' of set_pending()
Jul 24, 2015
0340256
[FIX] seconds defaults to RETRY_INTERVAL when no retry_pattern is spe…
Jul 24, 2015
5eb7a27
[FIX] retry_pattern in job decorator.
Jul 27, 2015
edb5402
create environment with a classmethod
Aug 20, 2015
7021cf4
FIX: pep8
Aug 20, 2015
8ac9d80
Added unittests
Aug 20, 2015
3f830bf
FIX: Make sure kwargs is instantiated
Aug 20, 2015
178a341
FIX: documentation / ADD: authors and changes
Aug 20, 2015
699fafd
FIX: Typo in CHANGES.rst / DOC: py:meth instead py:class
Aug 20, 2015
69e685b
OCA Transbot updated translations from Transifex
oca-transbot Sep 1, 2015
a00032d
Implemented a default binder to avoid reimplementing it in each conne…
ccomb Jun 2, 2015
81b4859
Mention the default implementation is the doc
ccomb Jun 2, 2015
93de242
Correct flake8 warning: long line
Jul 3, 2015
8e5382c
Slight changes in the docstrings
Jul 3, 2015
d3e665d
Binder.to_openerp() always returns a recordset
Jul 3, 2015
e54688c
Add a line in the changes file
Jul 3, 2015
00c4000
Release 3.2.0
Sep 10, 2015
cb2d407
Correct the authors list: missing company
Sep 11, 2015
0f7ba06
OCA Transbot updated translations from Transifex
oca-transbot Sep 13, 2015
310d622
Add OCA icon
flotho Aug 21, 2015
c4049c6
[IMP] improve job runner documentation
sbidoul Sep 26, 2015
0c8501a
[IMP] mention web_kanban in the --load option as it is the odoo default
sbidoul Sep 26, 2015
58acaf9
[IMP] answer another jobrunner FAQ in the documentation
sbidoul Sep 28, 2015
b65ec25
Allow to define seconds when raising RetryableJobError
Oct 6, 2015
23235f9
Allow to ignore the retry counter when raising RetryableJobError
Oct 6, 2015
2d44fb6
Exception should be raised with arguments
Oct 7, 2015
74d77a1
[UPD] prefix versions with 8.0
sbidoul Oct 9, 2015
4efd4d2
OCA Transbot updated translations from Transifex
oca-transbot Oct 11, 2015
85fa0d1
Add WooCommerce connector link in documentation
Oct 13, 2015
b17b278
[MIG] Make modules uninstallable
pedrobaeza Oct 14, 2015
e88820d
Check if a module is installed from the registry
Oct 15, 2015
edadba8
OCA Transbot updated translations from Transifex
oca-transbot Oct 18, 2015
3c13913
Add 'mock_job_delay_to_direct' to ease tests on jobs
Oct 1, 2015
cfe2a91
[FIX] Set job to failed after non-retryable OperationalError
npiganeau Oct 26, 2015
840d07c
[FIX] Yield session in a clear_upon_failure() environment
npiganeau Oct 21, 2015
ae50c28
Update mailing list address
Oct 30, 2015
8d5d32c
[8.0][FIX] when a job fails, inactive users are added to its followers
Olivier-LAURENT Oct 30, 2015
a7d3e80
Context manager to acquire Postgres advisory locks
Nov 2, 2015
07e661a
Rename try_advisory_lock to advisory_lock_or_retry
Nov 3, 2015
05ffd87
OCA Transbot updated translations from Transifex
oca-transbot Nov 8, 2015
a3aae3b
Update index.rst
maxime-c2c Nov 16, 2015
f2ab654
Set job back to 'pending' in case of exception
mdietrichc2c Nov 18, 2015
56016cd
Fix bug introduced in c97ebbd in jobrunner
Nov 27, 2015
833e5f7
Fix the fix c3fefd2 :-(
Dec 3, 2015
443bea0
[FIX] correctly obtain the list of database with odoo is started with…
sbidoul Dec 27, 2015
d90fe07
[FIX] ignore dbfilter containing %d or %h, fixes #58
sbidoul Dec 27, 2015
9657d30
Manage non-ascii PG errors
npiganeau Dec 28, 2015
55022bb
Removed trailing whitespace
npiganeau Dec 28, 2015
3f2ba59
Use tools.ustr() instead of unicode()
npiganeau Jan 4, 2016
4910d67
OCA Transbot updated translations from Transifex
oca-transbot Jan 16, 2016
66a8acf
Prevent to unpickle globals which are not jobs
Feb 8, 2016
6092a34
Fix too long line
Feb 22, 2016
9afda5f
Release 8.0.3.3.0
Feb 29, 2016
528cd58
Update mailing list address
Oct 30, 2015
7ed94a8
Update index.rst
maxime-c2c Nov 16, 2015
0821ca3
[FIX] ignore dbfilter, fixes #58
sbidoul Jan 4, 2016
4ff557e
[MIG] Make module installable
lmignon Feb 15, 2016
394ea3e
[MIG] Use python standard lib unittest in place of unittest2
lmignon Feb 15, 2016
8949b8e
[MIG] email followers are instance of model 'mail.followers'
lmignon Feb 15, 2016
ddfb0e0
[MIG] value returned by _company_default_get is a BrowseRecord
lmignon Feb 15, 2016
a02a7c6
[DEL] Remove the old connector worker
lmignon Feb 15, 2016
b2d0149
[PEP8]
lmignon Feb 15, 2016
d385507
[FIX] In the last release of Odoo related partner created from an ina…
lmignon Feb 15, 2016
42fc457
[FIX] The first version is 9.0.1.0.0
lmignon Feb 15, 2016
b120b67
[FIX] fix path of odoo for doc build
lmignon Feb 18, 2016
76cd570
[DEL] Remove deprecated APIs
lmignon Feb 29, 2016
4ddc879
remove remnants of workers
sbidoul Mar 3, 2016
d6b8d13
enable the jobrunner by default
sbidoul Mar 3, 2016
664320c
bump version
sbidoul Mar 3, 2016
eadb459
remove unused import
sbidoul Mar 3, 2016
bbfac96
update changelog
sbidoul Mar 3, 2016
6ce697d
adapt to upstream api change to obtain db connection
sbidoul Mar 3, 2016
6fab49f
Bump version number
sbidoul Mar 3, 2016
2588bb8
Update changelog for 9.0.1.0.2
Mar 3, 2016
a676dd6
OCA Transbot updated translations from Transifex
oca-transbot Mar 5, 2016
c2830c2
OCA Transbot updated translations from Transifex
oca-transbot Mar 19, 2016
0ef8d01
OCA Transbot updated translations from Transifex
oca-transbot Apr 2, 2016
4a300c5
OCA Transbot updated translations from Transifex
oca-transbot Apr 23, 2016
0e42c55
Move connector settings menu to technical
lasley Apr 29, 2016
310b735
Fix backend_to_m2o to extract id of the binding
Dec 1, 2015
8d94987
[DOC] fix highlight of license
yvaucher Jun 29, 2016
3ffc619
OCA Transbot updated translations from Transifex
oca-transbot Aug 13, 2016
dae5ed9
Add job_uuid in context
YannickB Mar 2, 2016
e85d174
Added test for job uuid in session context.
nicolas-petit Mar 11, 2016
a40e0f5
Removing log traces.
nicolas-petit Mar 11, 2016
b96b011
[FIX] remove en.po that was erroneously created by transbot
sbidoul Aug 15, 2016
1b61b39
OCA Transbot updated translations from Transifex
oca-transbot Aug 20, 2016
3ae88e4
[FIX] error handling bug
sbidoul Aug 20, 2016
c5fd92c
[DOC] remove mention of v9 crowdfunding
sbidoul Aug 20, 2016
63aa69a
[REF] remove old code that was there for backward compatibility
sbidoul Aug 20, 2016
f078b1e
[ADD] first implementation of channel delay
sbidoul Aug 20, 2016
db81175
[IMP] to be consistent, use the same 'now' concept everywhere
sbidoul Aug 20, 2016
e15a1cf
[IMP] more precise wakeup at the end of delays between jobs
sbidoul Aug 22, 2016
016f11e
rename delay key as throttle
sbidoul Aug 23, 2016
7a97ca0
Fix wrong recordset returned when no binding found
Sep 6, 2016
ce4ec63
[FIX] connector: Zero value assertion
lasley Sep 14, 2016
a16decf
Remove cancellation of jobs and their active flag
May 24, 2016
35689e3
OCA Transbot updated translations from Transifex
oca-transbot Sep 17, 2016
d3238db
Set addons uninstallable
Oct 3, 2016
d0b6379
Make the connector addon installable
Oct 3, 2016
d5fa5b2
Replace 'select=True' by 'index=True'
Oct 3, 2016
8a2e018
Rename openerp to odoo in Python files
Oct 3, 2016
b129e0e
Rename xml files with odoo instead of openerp
Oct 3, 2016
5e6a588
Rename openerp to odoo in docs
Oct 3, 2016
d2f8daf
Replace monkey-patch by a proper inherit
Oct 3, 2016
c6e6c48
Remove usage of @api.one
Oct 3, 2016
fcd59bf
Upgrade version number
Oct 4, 2016
53bdbf4
Replace ConnectorSession by odoo.Environment
Oct 4, 2016
ff57a47
Merge JobStorage into Job
Oct 4, 2016
fbfd972
Extract the queue_job from connector
Oct 4, 2016
60df403
Remove ConnectorSession
Oct 4, 2016
dd42178
Typo
Oct 4, 2016
f0288e3
Remove migration code for a previous odoo version
Oct 4, 2016
b5e0e67
Use short license headers
Jan 12, 2017
35c7e8c
Add is_module_installed function
Jan 12, 2017
122d986
Rework slighty the default Binder
Jan 12, 2017
50af0fc
Add a test_connector addon
Jan 12, 2017
f304a36
Start to actualize documentation
Jan 12, 2017
63feca2
Remove 'env' argument from ConnectorEnvironment
Jan 12, 2017
9cbb733
Remove application flag, not an application
Jan 12, 2017
8bbcbed
str to ustr
leemannd Feb 17, 2017
648ed28
Tentative to build docs
Mar 6, 2017
e484086
Remove invalid URL
Mar 9, 2017
175b409
OCA Transbot updated translations from Transifex
oca-transbot Mar 11, 2017
b2f363b
[FIX] mapper: Remove orphan method _map_children
lmignon Jun 8, 2017
ccf6baf
OCA Transbot updated translations from Transifex
oca-transbot Jul 15, 2017
8f22cda
Start prototype of a component system
Jan 12, 2017
e2974c7
Start to implement the collection system
Jan 12, 2017
79009cb
Improve on the collections, work, ...
Jan 15, 2017
cb56287
Extract 'components' into an individual addon
Jan 15, 2017
55a637a
Add test_component
Jan 15, 2017
e00025b
Start to use 'components' in connector
Feb 27, 2017
1bfc8cc
Add core components in connector
Jun 12, 2017
fead82f
Add AbstractComponent
Jun 13, 2017
8685438
Remove overrides of attributes
Jun 13, 2017
0d7bb86
Replace unit_for by components
Jun 13, 2017
7c350b2
Instanciate the component returned by name
Jun 13, 2017
0f7fbbc
Get rid of MetaMapper
Jun 14, 2017
0096c0a
Make unwrap_binding compatible with components
Jun 14, 2017
3e389b9
Use 2 different methods for single/many lookup
Jun 15, 2017
de107b3
Add tests for connector mapper
Jun 16, 2017
3901779
Add deprecation comments
Jun 16, 2017
26b02b3
Remove some Mapper duplication
Jun 16, 2017
962c63c
Add/move tests for advisory locks
Jun 16, 2017
8cb679b
Update documentation
Jun 17, 2017
4f36f25
Start to write a migration guide
Jun 17, 2017
41f3c3a
Draft new component_event addon
Jun 17, 2017
0a5dfd8
Move test_producer in deprecated
Jun 19, 2017
7c71960
Continue the migration guide
Jun 19, 2017
8823db0
Rewrite some parts of the doc, notably code overview
Jun 19, 2017
2f3342b
Fix test: post_install
Jun 19, 2017
1313e81
We have now the 3 parts with a new API :)
Jun 20, 2017
965acb7
Add Manager group on partner view connector's tab
Jun 21, 2017
1098aa7
Add @skip_if decorator to skip events
Jun 22, 2017
4819e80
Change Collection.work_on() to a context manager
Jun 22, 2017
5f1bd4d
Remove required on the version field
Jun 23, 2017
ab2334c
Simplify tests by loading modules components
Jun 30, 2017
e0ac17a
Add new TestCase classes to test connectors
Jul 4, 2017
87a5f78
Exclude current addon in ComponentRegistryCase setup
Jul 6, 2017
7a4f898
Add a content index in the migration guide
Jul 10, 2017
233d04c
Checkpoint wizard is too slow
Jul 11, 2017
a004167
Add readme files
Jul 11, 2017
9e2bcf0
Bump connector version
Jul 11, 2017
0d1474c
Add links for versions in doc
Aug 22, 2017
5fc1acc
[10.0][FIX] connector : Avoid creating void child values
rousseldenis Sep 20, 2017
5deff64
[MIG] Set modules uninstallable
Oct 3, 2017
223e8ad
Make addons installable
Oct 3, 2017
fb2df10
PY3: apply automated changes by 2to3 on addons
Oct 3, 2017
fb17118
Remove ConnectorUnit features
Oct 3, 2017
d4dc233
Apply odoo renaming of models or methods in connector
Oct 3, 2017
7068ef4
PY3: hashlib.hasher takes bytes
Oct 3, 2017
d7d1549
Use the conventional module layout
Oct 3, 2017
e9d42c6
Fix build of docs
Oct 4, 2017
486c6ec
Build 11.0 docs
Jan 10, 2018
507ecf7
Fix connector docs dotted path to models
simahawk Mar 30, 2018
12eee27
remove obsolete .pot files [ci skip]
sbidoul Jun 15, 2018
ea5cd35
Translated using Weblate (French)
Jun 27, 2018
c08fb7c
Improve documentation of APIs
Mar 30, 2018
7443dce
Add RecordLocker component
Jul 18, 2018
3568880
Translated using Weblate (Portuguese (Brazil))
Aug 3, 2018
6b6fa90
Fix documentation build
Nov 6, 2018
0059aa6
Migrate connector to 12.0
Nov 26, 2018
d5eab9e
[IMP] add generic exporter extracted from Magento connector
Oct 9, 2017
48407bc
Make connector checkpoint compatible in multi company environment
florian-dacosta May 8, 2019
f1b29b3
[IMP] connector: Add Infor and Voicent connectors
max3903 Jul 1, 2019
6b10905
Translated using Weblate (Portuguese (Brazil))
Aug 26, 2019
01c93bc
Translated using Weblate (Chinese (Simplified))
liweijie0812 Aug 29, 2019
8090c34
Translated using Weblate (Chinese (Simplified))
liweijie0812 Aug 30, 2019
e6c2b36
Translated using Weblate (Chinese (Simplified))
liweijie0812 Sep 1, 2019
077e01f
Set modules uninstallable
Oct 10, 2019
35cd334
[UPD] make the sphinx config version independent
gurneyalex Oct 11, 2019
d3da9ed
[12.0][CHG] connector: Use more permissive licence: AGPL-> LGPL
lmignon Oct 14, 2019
758d8c9
[MIG] connector and test_connector: Migration to 13.0
Oct 22, 2019
89a5507
connector, test_connector: black isort
lmignon Oct 25, 2019
625f236
Translated using Weblate (Chinese (Simplified))
liweijie0812 Dec 13, 2019
162420e
Translated using Weblate (Portuguese (Brazil))
Mar 21, 2020
951b286
[doc] build 13.0 as main documentation
May 19, 2020
8c63e2d
[doc] fix links
May 19, 2020
06f3a5d
connector: Delete 12.0 migrations in module 13.0
Jun 17, 2020
44797b1
Translated using Weblate (Chinese (Simplified))
liweijie0812 Jul 8, 2020
3010818
[IMP] connector: black, isort, prettier
eantones Oct 16, 2020
9edb51d
[MIG] connector: Migration to 14.0
eantones Oct 16, 2020
a497da1
Remove connector checkpoints
guewen Mar 26, 2021
1e59bcd
Merge pull request #1 from guewen/14.0-mig-connector
eantones Mar 26, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
143 changes: 143 additions & 0 deletions connector/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
=========
Connector
=========

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |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-LGPL--3-blue.png
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
:alt: License: LGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fconnector-lightgray.png?logo=github
:target: https://github.com/OCA/connector/tree/13.0/connector
:alt: OCA/connector
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/connector-13-0/connector-13-0-connector
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/102/13.0
:alt: Try me on Runbot

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

This is a framework designed to build connectors with external systems,
usually called ``Backends`` in the documentation.

Documentation: http://odoo-connector.com

It features:

* A jobs queue

In which the connectors can push functions (synchronization tasks)
to be executed later.

* An event pattern

The connectors can subscribe listener functions on the events,
executed when the events are fired.

* Connector base classes

Called ``ConnectorUnit``.

Include base classes for the use in connectors, ready to be extended:

* ``Synchronizer``: flow of an import or export
* ``Mapper``: transform a record according to mapping rules
* ``Binder``: link external IDs with local IDS
* ``BackendAdapter``: adapter interface for the exchanges with the backend
* But ``ConnectorUnit`` can be extended to accomplish any task

* A multi-backend support

Each ``ConnectorUnit`` can be registered amongst a backend type (eg.
Magento) and a backend version (allow to have a different ``Mapper``
for each backend's version for instance)

It is used for example used to connect Magento_ and Prestashop_, but
also used with Solr, CMIS, ...

.. _Magento: http://odoo-magento-connector.com
.. _Prestashop: https://github.com/OCA/connector-prestashop

**Table of contents**

.. contents::
:local:

Usage
=====

This module does nothing on its own. It is a ground for developing
advanced connector modules. For further information, please go on:
http://odoo-connector.com

Changelog
=========

.. [ The change log. The goal of this file is to help readers
understand changes between version. The primary audience is
end users and integrators. Purely technical changes such as
code refactoring must not be mentioned here.

This file may contain ONE level of section titles, underlined
with the ~ (tilde) character. Other section markers are
forbidden and will likely break the structure of the README.rst
or other documents where this fragment is included. ]

Next
~~~~

12.0.1.0.0 (2018-11-26)
~~~~~~~~~~~~~~~~~~~~~~~

* [MIGRATION] from 12.0 branched at rev. 324e006

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

Bugs are tracked on `GitHub Issues <https://github.com/OCA/connector/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/connector/issues/new?body=module:%20connector%0Aversion:%2013.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
~~~~~~~

* Camptocamp
* Openerp Connector Core Editors

Contributors
~~~~~~~~~~~~

Read the `contributors list`_

.. _contributors list: ./AUTHORS

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/connector <https://github.com/OCA/connector/tree/13.0/connector>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
2 changes: 2 additions & 0 deletions connector/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import components
from . import models
18 changes: 18 additions & 0 deletions connector/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Copyright 2013 Camptocamp SA
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html)

{
"name": "Connector",
"version": "14.0.1.0.0",
"author": "Camptocamp,Odoo Community Association (OCA)",
"website": "https://github.com/OCA/connector",
"license": "LGPL-3",
"category": "Generic Modules",
"depends": ["mail", "queue_job", "component", "component_event"],
"data": [
"security/connector_security.xml",
"views/connector_menu.xml",
"views/res_partner_views.xml",
],
"installable": True,
}
7 changes: 7 additions & 0 deletions connector/components/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from . import core
from . import backend_adapter
from . import binder
from . import mapper
from . import listener
from . import locker
from . import synchronizer
64 changes: 64 additions & 0 deletions connector/components/backend_adapter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# Copyright 2013 Camptocamp SA
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html)

"""

Backend Adapter
===============

An external adapter has a common interface to speak with the backend.
It translates the basic orders (search, read, write) to the protocol
used by the backend.

"""

from odoo.addons.component.core import AbstractComponent


class BackendAdapter(AbstractComponent):
""" Base Backend Adapter for the connectors """

_name = "base.backend.adapter"
_inherit = "base.connector"
_usage = "backend.adapter"


# pylint: disable=W8106
class CRUDAdapter(AbstractComponent):
"""Base External Adapter specialized in the handling
of records on external systems.

This is an empty shell, Components can inherit and implement their own
implementation for the methods.

"""

_name = "base.backend.adapter.crud"
_inherit = "base.backend.adapter"
_usage = "backend.adapter"

def search(self, *args, **kwargs):
"""Search records according to some criterias
and returns a list of ids"""
raise NotImplementedError

def read(self, *args, **kwargs):
""" Returns the information of a record """
raise NotImplementedError

def search_read(self, *args, **kwargs):
"""Search records according to some criterias
and returns their information"""
raise NotImplementedError

def create(self, *args, **kwargs):
""" Create a record on the external system """
raise NotImplementedError

def write(self, *args, **kwargs):
""" Update records on the external system """
raise NotImplementedError

def delete(self, *args, **kwargs):
""" Delete a record on the external system """
raise NotImplementedError
148 changes: 148 additions & 0 deletions connector/components/binder.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
# Copyright 2013 Camptocamp SA
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html)

"""
Binders
=======

Binders are components that know how to find the external ID for an
Odoo ID, how to find the Odoo ID for an external ID and how to
create the binding between them.

"""

from odoo import fields, models, tools

from odoo.addons.component.core import AbstractComponent


class Binder(AbstractComponent):
"""For one record of a model, capable to find an external or
internal id, or create the binding (link) between them

This is a default implementation that can be inherited or reimplemented
in the connectors.

This implementation assumes that binding models are ``_inherits`` of
the models they are binding.

"""

_name = "base.binder"
_inherit = "base.connector"
_usage = "binder"

_external_field = "external_id" # override in sub-classes
_backend_field = "backend_id" # override in sub-classes
_odoo_field = "odoo_id" # override in sub-classes
_sync_date_field = "sync_date" # override in sub-classes

def to_internal(self, external_id, unwrap=False):
"""Give the Odoo recordset for an external ID

:param external_id: external ID for which we want
the Odoo ID
:param unwrap: if True, returns the normal record
else return the binding record
:return: a recordset, depending on the value of unwrap,
or an empty recordset if the external_id is not mapped
:rtype: recordset
"""
bindings = self.model.with_context(active_test=False).search(
[
(self._external_field, "=", tools.ustr(external_id)),
(self._backend_field, "=", self.backend_record.id),
]
)
if not bindings:
if unwrap:
return self.model.browse()[self._odoo_field]
return self.model.browse()
bindings.ensure_one()
if unwrap:
bindings = bindings[self._odoo_field]
return bindings

def to_external(self, binding, wrap=False):
"""Give the external ID for an Odoo binding ID

:param binding: Odoo binding for which we want the external id
:param wrap: if True, binding is a normal record, the
method will search the corresponding binding and return
the external id of the binding
:return: external ID of the record
"""
if isinstance(binding, models.BaseModel):
binding.ensure_one()
else:
binding = self.model.browse(binding)
if wrap:
binding = self.model.with_context(active_test=False).search(
[
(self._odoo_field, "=", binding.id),
(self._backend_field, "=", self.backend_record.id),
]
)
if not binding:
return None
binding.ensure_one()
return binding[self._external_field]
return binding[self._external_field]

def bind(self, external_id, binding):
"""Create the link between an external ID and an Odoo ID

:param external_id: external id to bind
:param binding: Odoo record to bind
:type binding: int
"""
# Prevent False, None, or "", but not 0
assert (
external_id or external_id == 0
) and binding, "external_id or binding missing, " "got: %s, %s" % (
external_id,
binding,
)
# avoid to trigger the export when we modify the `external_id`
now_fmt = fields.Datetime.now()
if isinstance(binding, models.BaseModel):
binding.ensure_one()
else:
binding = self.model.browse(binding)
binding.with_context(connector_no_export=True).write(
{
self._external_field: tools.ustr(external_id),
self._sync_date_field: now_fmt,
}
)

def unwrap_binding(self, binding):
"""For a binding record, gives the normal record.

Example: when called with a ``magento.product.product`` id,
it will return the corresponding ``product.product`` id.

:param browse: when True, returns a browse_record instance
rather than an ID
"""
if isinstance(binding, models.BaseModel):
binding.ensure_one()
else:
binding = self.model.browse(binding)

return binding[self._odoo_field]

def unwrap_model(self):
"""For a binding model, gives the normal model.

Example: when called on a binder for ``magento.product.product``,
it will return ``product.product``.
"""
try:
column = self.model._fields[self._odoo_field]
except KeyError:
raise ValueError(
"Cannot unwrap model %s, because it has no %s fields"
% (self.model._name, self._odoo_field)
)
return column.comodel_name
Loading