Skip to content
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

[16.0][MIG] component_event: Migration to 16.0 #443

Merged
merged 65 commits into from
Feb 2, 2023

Conversation

asierneiradev
Copy link
Contributor

@asierneiradev asierneiradev commented Oct 4, 2022

#440

Dependency :

@oca-clabot
Copy link

Hey @asierneiradev, thank you for your Pull Request.

It looks like some users haven't signed our Contributor License Agreement, yet.
You can read and sign our full Contributor License Agreement here: https://odoo-community.org/page/cla
Here is a list of the users:

Appreciation of efforts,
OCA CLAbot

@asierneiradev asierneiradev mentioned this pull request Oct 10, 2022
6 tasks
@flotho
Copy link
Member

flotho commented Jan 6, 2023

Hi,
Thanks for the job done.
Any chance to rebase because component module is available in main 16.0

@asierneiradev asierneiradev force-pushed the 16.0-mig-component_event branch 2 times, most recently from 9ca5f9a to 2ce0309 Compare January 9, 2023 06:13
@asierneiradev
Copy link
Contributor Author

Hi @flotho !

Rebase done on the 16.0 branch.

Regards, and thank you very much

@flotho
Copy link
Member

flotho commented Jan 9, 2023

with pleasure, I'm actually testing your 2 PR for a reboot of OCA/infrastructure#18

@asierneiradev
Copy link
Contributor Author

Good afternoon @flotho ,
what is the condition of this PR?
thank you very much

guewen and others added 20 commits January 30, 2023 15:55
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
@asierneiradev
Copy link
Contributor Author

Hi @sbidoul @simahawk ,

Do you think it would be ready to merge?
Thank you very much

Copy link
Sponsor Contributor

@lmignon lmignon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @asierneiradev LGTM (Code review)

@lmignon
Copy link
Sponsor Contributor

lmignon commented Feb 1, 2023

/ocabot migrate component_event

@OCA-git-bot
Copy link
Contributor

Hi @lmignon. Your command failed:

Invalid command: migrate.

Ocabot commands

  • ocabot merge major|minor|patch|nobump
  • ocabot rebase
  • ocabot migration {MODULE_NAME}

More information

@lmignon
Copy link
Sponsor Contributor

lmignon commented Feb 1, 2023

/ocabot migration component_event

@OCA-git-bot OCA-git-bot added this to the 16.0 milestone Feb 1, 2023
Copy link
Contributor

@simahawk simahawk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LG

@simahawk
Copy link
Contributor

simahawk commented Feb 2, 2023

/ocabot merge nonump

@OCA-git-bot
Copy link
Contributor

Hi @simahawk. Your command failed:

Invalid options for command merge: nonump.

Ocabot commands

  • ocabot merge major|minor|patch|nobump
  • ocabot rebase
  • ocabot migration {MODULE_NAME}

More information

@simahawk
Copy link
Contributor

simahawk commented Feb 2, 2023

/ocabot merge nobump

@OCA-git-bot
Copy link
Contributor

On my way to merge this fine PR!
Prepared branch 16.0-ocabot-merge-pr-443-by-simahawk-bump-nobump, awaiting test results.

@OCA-git-bot OCA-git-bot merged commit 49dc3c4 into OCA:16.0 Feb 2, 2023
@OCA-git-bot
Copy link
Contributor

Congratulations, your PR was merged at fecfea7. Thanks a lot for contributing to OCA. ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet