Skip to content

Commit bad536d

Browse files
committed
Merge PR #493 into 18.0
Signed-off-by simahawk
2 parents 704476c + 470213b commit bad536d

23 files changed

+1853
-0
lines changed

component_event/README.rst

+139
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
=================
2+
Components Events
3+
=================
4+
5+
..
6+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
7+
!! This file is generated by oca-gen-addon-readme !!
8+
!! changes will be overwritten. !!
9+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10+
!! source digest: sha256:e1f378350f3505fa79426d36ed2b62b2bd099ef5da9445f77ada6247dca1a8c0
11+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
12+
13+
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
14+
:target: https://odoo-community.org/page/development-status
15+
:alt: Beta
16+
.. |badge2| image:: https://img.shields.io/badge/licence-LGPL--3-blue.png
17+
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
18+
:alt: License: LGPL-3
19+
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fconnector-lightgray.png?logo=github
20+
:target: https://github.com/OCA/connector/tree/18.0/component_event
21+
:alt: OCA/connector
22+
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
23+
:target: https://translation.odoo-community.org/projects/connector-18-0/connector-18-0-component_event
24+
:alt: Translate me on Weblate
25+
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
26+
:target: https://runboat.odoo-community.org/builds?repo=OCA/connector&target_branch=18.0
27+
:alt: Try me on Runboat
28+
29+
|badge1| |badge2| |badge3| |badge4| |badge5|
30+
31+
This module implements an event system (`Observer
32+
pattern <https://en.wikipedia.org/wiki/Observer_pattern>`__) and is a
33+
base block for the Connector Framework. It can be used without using the
34+
full Connector though. It is built upon the ``component`` module.
35+
36+
Documentation: http://odoo-connector.com/
37+
38+
**Table of contents**
39+
40+
.. contents::
41+
:local:
42+
43+
Usage
44+
=====
45+
46+
As a developer, you have access to a events system. You can find the
47+
documentation in the code or on http://odoo-connector.com
48+
49+
In a nutshell, you can create trigger events:
50+
51+
::
52+
53+
class Base(models.AbstractModel):
54+
_inherit = 'base'
55+
56+
@api.model
57+
def create(self, vals):
58+
record = super(Base, self).create(vals)
59+
self._event('on_record_create').notify(record, fields=vals.keys())
60+
return record
61+
62+
And subscribe listeners to the events:
63+
64+
::
65+
66+
from odoo.addons.component.core import Component
67+
from odoo.addons.component_event import skip_if
68+
69+
class MagentoListener(Component):
70+
_name = 'magento.event.listener'
71+
_inherit = 'base.connector.listener'
72+
73+
@skip_if(lambda self, record, **kwargs: self.no_connector_export(record))
74+
def on_record_create(self, record, fields=None):
75+
""" Called when a record is created """
76+
record.with_delay().export_record(fields=fields)
77+
78+
This module triggers 3 events:
79+
80+
- ``on_record_create(record, fields=None)``
81+
- ``on_record_write(record, fields=None)``
82+
- ``on_record_unlink(record)``
83+
84+
Changelog
85+
=========
86+
87+
Next
88+
----
89+
90+
12.0.1.0.0 (2018-11-26)
91+
-----------------------
92+
93+
- [MIGRATION] from 12.0 branched at rev. 324e006
94+
95+
Bug Tracker
96+
===========
97+
98+
Bugs are tracked on `GitHub Issues <https://github.com/OCA/connector/issues>`_.
99+
In case of trouble, please check there if your issue has already been reported.
100+
If you spotted it first, help us to smash it by providing a detailed and welcomed
101+
`feedback <https://github.com/OCA/connector/issues/new?body=module:%20component_event%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
102+
103+
Do not contact contributors directly about support or help with technical issues.
104+
105+
Credits
106+
=======
107+
108+
Authors
109+
-------
110+
111+
* Camptocamp
112+
113+
Contributors
114+
------------
115+
116+
- Guewen Baconnier <guewen.baconnier@camptocamp.com>
117+
118+
Other credits
119+
-------------
120+
121+
The migration of this module from 17.0 to 18.0 was financially supported
122+
by Camptocamp.
123+
124+
Maintainers
125+
-----------
126+
127+
This module is maintained by the OCA.
128+
129+
.. image:: https://odoo-community.org/logo.png
130+
:alt: Odoo Community Association
131+
:target: https://odoo-community.org
132+
133+
OCA, or the Odoo Community Association, is a nonprofit organization whose
134+
mission is to support the collaborative development of Odoo features and
135+
promote its widespread use.
136+
137+
This module is part of the `OCA/connector <https://github.com/OCA/connector/tree/18.0/component_event>`_ project on GitHub.
138+
139+
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

component_event/__init__.py

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from . import core
2+
from . import components
3+
from . import models
4+
5+
# allow public API 'from odoo.addons.component_event import skip_if'
6+
from .components.event import skip_if # noqa

component_event/__manifest__.py

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Copyright 2019 Camptocamp SA
2+
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html)
3+
4+
{
5+
"name": "Components Events",
6+
"version": "18.0.1.0.0",
7+
"author": "Camptocamp," "Odoo Community Association (OCA)",
8+
"website": "https://github.com/OCA/connector",
9+
"license": "LGPL-3",
10+
"category": "Generic Modules",
11+
"depends": ["component"],
12+
"external_dependencies": {"python": ["cachetools"]},
13+
"data": [],
14+
"installable": True,
15+
}
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import event

0 commit comments

Comments
 (0)