-
-
Notifications
You must be signed in to change notification settings - Fork 454
19.0 mig component event #509
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Sanazzzmi
wants to merge
84
commits into
OCA:19.0
Choose a base branch
from
Sanazzzmi:19.0-mig-component_event
base: 19.0
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Proposing a new API based on components for the events
Because they can have different addons
So we don't need to iterate on the listeners to find the events each time the event is triggered. * rename producer -> collecter, which is more accurate regarding what it does * rename the trigger function 'fire' -> 'notify', just a matter of preference here :) * add a CollectedEvents class so we don't modify the state of the collecter and we don't mix responsibilities
* Add documentation * Add a few more test cases * Prevent using component lookup methods from an EventWorkContext when there is no collection, but allow to switch to a WorkContext with collection * Increase cache size (should be measured at some point...) * Fix a few issues with collection being an empty model being False-ish, so added comparisons with None * Add abstract Component with the base events (on_record_create, on_record_write, on_record_unlink)
We return an empty list of events so nothing is triggered
Tests using odoo transactions must run post install, because during the install the registry is not ready, so the components aren't neither.
For consistency, this is where components should go (as for models, views, ...)
Checking that the odoo registry is ready is not working: in tests, the events are not working because they are run just before the odoo registry is set to ready.
I'm not sure it is good actually. If you inherit from it for only one of the method, the other methods will listen be executed for doing nothing, but that's still a useless call of method...
It's not really usable: if we inherit from it and implement only one method, the others will be called without effect, waste of resources
It takes a condition which skip the event when evaluated to True.
A new base listener for the connector adds a default condition based on
self.env.context.get('connector_no_export'). Every export event listener
should be decorated with:
@skip_if(lambda self, *args, **kwargs: self.no_connector_export)
Otherwise we can't read the record
It the previous commit, @lmignon added the possibility to load all components of an addon in a Component Registry. This commit takes benefit of this feature to simplify the existing tests and to add a base test case for the Connector (that loads all components of 'component', 'component_event', 'connector'). It can be used in implementations using the connector.
It is unused, and depends on the model on which we call it
The cache entries for events were including instance of the components, hence, they included the work instance / odoo environment. Only the component class and the events it provides are new cached, the instances of components being instanciated when needed. Reported on: OCA/connector-magento#255 (comment)
* Document the events that have already been implemented to BaseModel
* Sphinx crashes with a recursion error when trying to document Models fields. Remove the fields from the documentation altogether, they didn't bring much value anyway * Gone through all the API pages and removed many useless autodoc with a mix of __all__, :exclude-members: or by defining more precisely what we want with :autoclass:, :autoatttribute:, ... or simply removing them * Changed the order of a few autodocs by putting the most useful classes/functions first * Improved a few docstrings
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate. Translation: connector-16.0/connector-16.0-component_event Translate-URL: https://translation.odoo-community.org/projects/connector-16-0/connector-16-0-component_event/
Currently translated at 100.0% (1 of 1 strings) Translation: connector-16.0/connector-16.0-component_event Translate-URL: https://translation.odoo-community.org/projects/connector-16-0/connector-16-0-component_event/es/
Currently translated at 100.0% (1 of 1 strings) Translation: connector-17.0/connector-17.0-component_event Translate-URL: https://translation.odoo-community.org/projects/connector-17-0/connector-17-0-component_event/it/
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Migrate component event to 19.0