mirror of
https://github.com/bringout/oca-technical.git
synced 2026-04-18 18:32:03 +02:00
Initial commit: OCA Technical packages (595 packages)
This commit is contained in:
commit
2cc02aac6e
24950 changed files with 2318079 additions and 0 deletions
|
|
@ -0,0 +1 @@
|
|||
* Guewen Baconnier <guewen.baconnier@camptocamp.com>
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
This module implements an event system (`Observer pattern`_) and is a
|
||||
base block for the Connector Framework. It can be used without
|
||||
using the full Connector though. It is built upon the ``component`` module.
|
||||
|
||||
Documentation: http://odoo-connector.com/
|
||||
|
||||
.. _Observer pattern: https://en.wikipedia.org/wiki/Observer_pattern
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
.. [ 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
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
As a developer, you have access to a events system. You can find the
|
||||
documentation in the code or on http://odoo-connector.com
|
||||
|
||||
In a nutshell, you can create trigger events::
|
||||
|
||||
class Base(models.AbstractModel):
|
||||
_inherit = 'base'
|
||||
|
||||
@api.model
|
||||
def create(self, vals):
|
||||
record = super(Base, self).create(vals)
|
||||
self._event('on_record_create').notify(record, fields=vals.keys())
|
||||
return record
|
||||
|
||||
And subscribe listeners to the events::
|
||||
|
||||
from odoo.addons.component.core import Component
|
||||
from odoo.addons.component_event import skip_if
|
||||
|
||||
class MagentoListener(Component):
|
||||
_name = 'magento.event.listener'
|
||||
_inherit = 'base.connector.listener'
|
||||
|
||||
@skip_if(lambda self, record, **kwargs: self.no_connector_export(record))
|
||||
def on_record_create(self, record, fields=None):
|
||||
""" Called when a record is created """
|
||||
record.with_delay().export_record(fields=fields)
|
||||
|
||||
|
||||
This module triggers 3 events:
|
||||
|
||||
* ``on_record_create(record, fields=None)``
|
||||
* ``on_record_write(record, fields=None)``
|
||||
* ``on_record_unlink(record)``
|
||||
Loading…
Add table
Add a link
Reference in a new issue