diff --git a/component/README.rst b/component/README.rst index a80c0d1ef..b2bce6de8 100644 --- a/component/README.rst +++ b/component/README.rst @@ -17,25 +17,26 @@ Components :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/16.0/component + :target: https://github.com/OCA/connector/tree/17.0/component :alt: OCA/connector .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png - :target: https://translation.odoo-community.org/projects/connector-16-0/connector-16-0-component + :target: https://translation.odoo-community.org/projects/connector-17-0/connector-17-0-component :alt: Translate me on Weblate .. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png - :target: https://runboat.odoo-community.org/builds?repo=OCA/connector&target_branch=16.0 + :target: https://runboat.odoo-community.org/builds?repo=OCA/connector&target_branch=17.0 :alt: Try me on Runboat |badge1| |badge2| |badge3| |badge4| |badge5| -This module implements a component system and is a base block for the Connector -Framework. It can be used without using the full Connector though. +This module implements a component system and is a base block for the +Connector Framework. It can be used without using the full Connector +though. Documentation: http://odoo-connector.com/ -You may also want to check the `Introduction to Odoo Components`_ by @guewen. - -.. _Introduction to Odoo Components: https://dev.to/guewen/introduction-to-odoo-components-bn0 +You may also want to check the `Introduction to Odoo +Components `__ +by @guewen. **Table of contents** @@ -48,73 +49,65 @@ Usage As a developer, you have access to a component system. You can find the documentation in the code or on http://odoo-connector.com -In a nutshell, you can create components:: +In a nutshell, you can create components: +:: - from odoo.addons.component.core import Component + from odoo.addons.component.core import Component - class MagentoPartnerAdapter(Component): - _name = 'magento.partner.adapter' - _inherit = 'magento.adapter' + class MagentoPartnerAdapter(Component): + _name = 'magento.partner.adapter' + _inherit = 'magento.adapter' - _usage = 'backend.adapter' - _collection = 'magento.backend' - _apply_on = ['res.partner'] + _usage = 'backend.adapter' + _collection = 'magento.backend' + _apply_on = ['res.partner'] And later, find the component you need at runtime (dynamic dispatch at -component level):: +component level): - def run(self, external_id): - backend_adapter = self.component(usage='backend.adapter') - external_data = backend_adapter.read(external_id) +:: + def run(self, external_id): + backend_adapter = self.component(usage='backend.adapter') + external_data = backend_adapter.read(external_id) -In order for tests using components to work, you will need to use the base -class provided by `odoo.addons.component.tests.common`: +In order for tests using components to work, you will need to use the +base class provided by \`odoo.addons.component.tests.common\`: -* `TransactionComponentCase` +- TransactionComponentCase -There are also some specific base classes for testing the component registry, -using the ComponentRegistryCase as a base class. See the docstrings in -`tests/common.py`. +There are also some specific base classes for testing the component +registry, using the ComponentRegistryCase as a base class. See the +docstrings in tests/common.py. 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. ] - 16.0.1.0.0 (2022-10-04) -~~~~~~~~~~~~~~~~~~~~~~~ +----------------------- -* [MIGRATION] from 15.0 +- [MIGRATION] from 15.0 15.0.1.0.0 (2021-11-25) -~~~~~~~~~~~~~~~~~~~~~~~ +----------------------- -* [MIGRATION] from 14.0 +- [MIGRATION] from 14.0 14.0.1.0.0 (2020-10-22) -~~~~~~~~~~~~~~~~~~~~~~~ +----------------------- -* [MIGRATION] from 13.0 +- [MIGRATION] from 13.0 13.0.1.0.0 (2019-10-23) -~~~~~~~~~~~~~~~~~~~~~~~ +----------------------- -* [MIGRATION] from 12.0 +- [MIGRATION] from 12.0 12.0.1.0.0 (2018-10-02) -~~~~~~~~~~~~~~~~~~~~~~~ +----------------------- -* [MIGRATION] from 11.0 branched at rev. 324e006 +- [MIGRATION] from 11.0 branched at rev. 324e006 Bug Tracker =========== @@ -122,7 +115,7 @@ Bug Tracker Bugs are tracked on `GitHub Issues `_. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us to smash it by providing a detailed and welcomed -`feedback `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -130,19 +123,19 @@ Credits ======= Authors -~~~~~~~ +------- * Camptocamp Contributors -~~~~~~~~~~~~ +------------ -* Guewen Baconnier -* Laurent Mignon -* Simone Orsi +- Guewen Baconnier +- Laurent Mignon +- Simone Orsi Maintainers -~~~~~~~~~~~ +----------- This module is maintained by the OCA. @@ -162,6 +155,6 @@ Current `maintainer `__: |maintainer-guewen| -This module is part of the `OCA/connector `_ project on GitHub. +This module is part of the `OCA/connector `_ project on GitHub. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/component/core.py b/component/core.py index aa4cb5250..9bc4c6f46 100644 --- a/component/core.py +++ b/component/core.py @@ -333,9 +333,9 @@ def component_by_name(self, name, model_name=None): and work_model not in component_class.apply_on_models ): if len(component_class.apply_on_models) == 1: - hint_models = "'{}'".format(component_class.apply_on_models[0]) + hint_models = f"'{component_class.apply_on_models[0]}'" else: - hint_models = "".format(component_class.apply_on_models) + hint_models = f"" raise NoComponentError( "Component with name '%s' can't be used for model '%s'.\n" "Hint: you might want to use: " @@ -473,7 +473,7 @@ def many_components(self, usage=None, model_name=None, **kw): return [comp(work_context) for comp in component_classes] def __str__(self): - return "WorkContext({}, {})".format(self.model_name, repr(self.collection)) + return f"WorkContext({self.model_name}, {repr(self.collection)})" __repr__ = __str__ diff --git a/component/pyproject.toml b/component/pyproject.toml new file mode 100644 index 000000000..4231d0ccc --- /dev/null +++ b/component/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/component/readme/CONTRIBUTORS.md b/component/readme/CONTRIBUTORS.md new file mode 100644 index 000000000..6e153f77b --- /dev/null +++ b/component/readme/CONTRIBUTORS.md @@ -0,0 +1,3 @@ +- Guewen Baconnier \<\> +- Laurent Mignon \<\> +- Simone Orsi \<\> diff --git a/component/readme/CONTRIBUTORS.rst b/component/readme/CONTRIBUTORS.rst deleted file mode 100644 index 60d861306..000000000 --- a/component/readme/CONTRIBUTORS.rst +++ /dev/null @@ -1,3 +0,0 @@ -* Guewen Baconnier -* Laurent Mignon -* Simone Orsi diff --git a/component/readme/DESCRIPTION.md b/component/readme/DESCRIPTION.md new file mode 100644 index 000000000..8ac7a8552 --- /dev/null +++ b/component/readme/DESCRIPTION.md @@ -0,0 +1,9 @@ +This module implements a component system and is a base block for the +Connector Framework. It can be used without using the full Connector +though. + +Documentation: + +You may also want to check the [Introduction to Odoo +Components](https://dev.to/guewen/introduction-to-odoo-components-bn0) +by @guewen. diff --git a/component/readme/DESCRIPTION.rst b/component/readme/DESCRIPTION.rst deleted file mode 100644 index 8db4b890c..000000000 --- a/component/readme/DESCRIPTION.rst +++ /dev/null @@ -1,8 +0,0 @@ -This module implements a component system and is a base block for the Connector -Framework. It can be used without using the full Connector though. - -Documentation: http://odoo-connector.com/ - -You may also want to check the `Introduction to Odoo Components`_ by @guewen. - -.. _Introduction to Odoo Components: https://dev.to/guewen/introduction-to-odoo-components-bn0 diff --git a/component/readme/HISTORY.md b/component/readme/HISTORY.md new file mode 100644 index 000000000..e98452fda --- /dev/null +++ b/component/readme/HISTORY.md @@ -0,0 +1,19 @@ +## 16.0.1.0.0 (2022-10-04) + +- \[MIGRATION\] from 15.0 + +## 15.0.1.0.0 (2021-11-25) + +- \[MIGRATION\] from 14.0 + +## 14.0.1.0.0 (2020-10-22) + +- \[MIGRATION\] from 13.0 + +## 13.0.1.0.0 (2019-10-23) + +- \[MIGRATION\] from 12.0 + +## 12.0.1.0.0 (2018-10-02) + +- \[MIGRATION\] from 11.0 branched at rev. 324e006 diff --git a/component/readme/HISTORY.rst b/component/readme/HISTORY.rst deleted file mode 100644 index 525b15566..000000000 --- a/component/readme/HISTORY.rst +++ /dev/null @@ -1,34 +0,0 @@ -.. [ 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. ] - -16.0.1.0.0 (2022-10-04) -~~~~~~~~~~~~~~~~~~~~~~~ - -* [MIGRATION] from 15.0 - -15.0.1.0.0 (2021-11-25) -~~~~~~~~~~~~~~~~~~~~~~~ - -* [MIGRATION] from 14.0 - -14.0.1.0.0 (2020-10-22) -~~~~~~~~~~~~~~~~~~~~~~~ - -* [MIGRATION] from 13.0 - -13.0.1.0.0 (2019-10-23) -~~~~~~~~~~~~~~~~~~~~~~~ - -* [MIGRATION] from 12.0 - -12.0.1.0.0 (2018-10-02) -~~~~~~~~~~~~~~~~~~~~~~~ - -* [MIGRATION] from 11.0 branched at rev. 324e006 diff --git a/component/readme/USAGE.md b/component/readme/USAGE.md new file mode 100644 index 000000000..92816e93e --- /dev/null +++ b/component/readme/USAGE.md @@ -0,0 +1,30 @@ +As a developer, you have access to a component system. You can find the +documentation in the code or on + +In a nutshell, you can create components: + + from odoo.addons.component.core import Component + + class MagentoPartnerAdapter(Component): + _name = 'magento.partner.adapter' + _inherit = 'magento.adapter' + + _usage = 'backend.adapter' + _collection = 'magento.backend' + _apply_on = ['res.partner'] + +And later, find the component you need at runtime (dynamic dispatch at +component level): + + def run(self, external_id): + backend_adapter = self.component(usage='backend.adapter') + external_data = backend_adapter.read(external_id) + +In order for tests using components to work, you will need to use the +base class provided by \`odoo.addons.component.tests.common\`: + +- TransactionComponentCase + +There are also some specific base classes for testing the component +registry, using the ComponentRegistryCase as a base class. See the +docstrings in tests/common.py. diff --git a/component/readme/USAGE.rst b/component/readme/USAGE.rst deleted file mode 100644 index 896fdb547..000000000 --- a/component/readme/USAGE.rst +++ /dev/null @@ -1,32 +0,0 @@ -As a developer, you have access to a component system. You can find the -documentation in the code or on http://odoo-connector.com - -In a nutshell, you can create components:: - - - from odoo.addons.component.core import Component - - class MagentoPartnerAdapter(Component): - _name = 'magento.partner.adapter' - _inherit = 'magento.adapter' - - _usage = 'backend.adapter' - _collection = 'magento.backend' - _apply_on = ['res.partner'] - -And later, find the component you need at runtime (dynamic dispatch at -component level):: - - def run(self, external_id): - backend_adapter = self.component(usage='backend.adapter') - external_data = backend_adapter.read(external_id) - - -In order for tests using components to work, you will need to use the base -class provided by `odoo.addons.component.tests.common`: - -* `TransactionComponentCase` - -There are also some specific base classes for testing the component registry, -using the ComponentRegistryCase as a base class. See the docstrings in -`tests/common.py`. diff --git a/component/static/description/index.html b/component/static/description/index.html index 125b00762..10a694620 100644 --- a/component/static/description/index.html +++ b/component/static/description/index.html @@ -369,11 +369,14 @@

Components

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! source digest: sha256:460c927ffe0fe97c01fdc7decac3df3b2b01700e16dc071eef0c9d2765ba0b1e !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> -

Production/Stable License: LGPL-3 OCA/connector Translate me on Weblate Try me on Runboat

-

This module implements a component system and is a base block for the Connector -Framework. It can be used without using the full Connector though.

+

Production/Stable License: LGPL-3 OCA/connector Translate me on Weblate Try me on Runboat

+

This module implements a component system and is a base block for the +Connector Framework. It can be used without using the full Connector +though.

Documentation: http://odoo-connector.com/

-

You may also want to check the Introduction to Odoo Components by @guewen.

+

You may also want to check the Introduction to Odoo +Components +by @guewen.

Table of contents

    @@ -418,26 +421,17 @@

    Usage

    backend_adapter = self.component(usage='backend.adapter') external_data = backend_adapter.read(external_id) -

    In order for tests using components to work, you will need to use the base -class provided by odoo.addons.component.tests.common:

    +

    In order for tests using components to work, you will need to use the +base class provided by `odoo.addons.component.tests.common`:

      -
    • TransactionComponentCase
    • +
    • TransactionComponentCase
    -

    There are also some specific base classes for testing the component registry, -using the ComponentRegistryCase as a base class. See the docstrings in -tests/common.py.

    +

    There are also some specific base classes for testing the component +registry, using the ComponentRegistryCase as a base class. See the +docstrings in tests/common.py.

Changelog

-

16.0.1.0.0 (2022-10-04)

    @@ -474,7 +468,7 @@

    Bug Tracker

    Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us to smash it by providing a detailed and welcomed -feedback.

    +feedback.

    Do not contact contributors directly about support or help with technical issues.

@@ -502,7 +496,7 @@

Maintainers

promote its widespread use.

Current maintainer:

guewen

-

This module is part of the OCA/connector project on GitHub.

+

This module is part of the OCA/connector project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

diff --git a/component/tests/test_component.py b/component/tests/test_component.py index 04322c5b4..69f168957 100644 --- a/component/tests/test_component.py +++ b/component/tests/test_component.py @@ -161,6 +161,7 @@ def test_component_by_usage_other_model_env(self): def test_component_error_several(self): """Use component(usage=...) when more than one generic component match""" + # we create 1 new Component with _usage 'for.test', in the same # collection and no _apply_on, and we remove the _apply_on of component # 1 so they are generic components for a collection @@ -188,6 +189,7 @@ class Component1(Component): def test_component_error_several_same_model(self): """Use component(usage=...) when more than one component match a model""" + # we create a new Component with _usage 'for.test', in the same # collection and no _apply_on class Component3(Component): @@ -208,6 +210,7 @@ class Component3(Component): def test_component_specific_model(self): """Use component(usage=...) when more than one component match but only one for the specific model""" + # we create a new Component with _usage 'for.test', in the same # collection and no _apply_on. This is a generic component for the # collection @@ -234,6 +237,7 @@ class Component3(Component): def test_component_specific_collection(self): """Use component(usage=...) when more than one component match but only one for the specific collection""" + # we create a new Component with _usage 'for.test', without collection # and no _apply_on class Component3(Component): @@ -257,6 +261,7 @@ class Component3(Component): def test_component_specific_collection_specific_model(self): """Use component(usage=...) when more than one component match but only one for the specific model and collection""" + # we create a new Component with _usage 'for.test', without collection # and no _apply_on. This is a component generic for all collections and # models diff --git a/component/tests/test_lookup.py b/component/tests/test_lookup.py index a92e44544..082ee68e9 100644 --- a/component/tests/test_lookup.py +++ b/component/tests/test_lookup.py @@ -32,6 +32,7 @@ def tearDown(self): def test_lookup_collection(self): """Lookup components of a collection""" + # we register 2 components in foobar and one in other class Foo(Component): _name = "foo" diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 000000000..d3dfeea70 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +# generated from manifests external_dependencies +cachetools