Skip to content

Commit

Permalink
Merge pull request #419 from OCA/14.0
Browse files Browse the repository at this point in the history
Syncing from upstream OCA/connector (14.0)
  • Loading branch information
bt-admin authored Sep 5, 2024
2 parents b5a7b0a + 389db3b commit 1f3c047
Show file tree
Hide file tree
Showing 22 changed files with 135 additions and 38 deletions.
9 changes: 5 additions & 4 deletions .copier-answers.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Do NOT update manually; changes here will be overwritten by Copier
_commit: v1.14.2
_commit: v1.24
_src_path: gh:oca/oca-addons-repo-template
ci: GitHub
dependency_installation_mode: PIP
convert_readme_fragments_to_markdown: false
generate_requirements_txt: true
github_check_license: true
github_ci_extra_env: {}
Expand All @@ -11,6 +11,7 @@ github_enable_makepot: true
github_enable_stale_action: true
github_enforce_dev_status_compatibility: true
include_wkhtmltopdf: false
odoo_test_flavor: Both
odoo_version: 14.0
org_name: Odoo Community Association (OCA)
org_slug: OCA
Expand All @@ -19,6 +20,6 @@ repo_description: 'TODO: add repo description.'
repo_name: connector
repo_slug: connector
repo_website: https://github.com/OCA/connector
travis_apt_packages: []
travis_apt_sources: []
use_pyproject_toml: false
use_ruff: false

1 change: 1 addition & 0 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ globals:
odoo: readonly
openerp: readonly
owl: readonly
luxon: readonly

# Styling is handled by Prettier, so we only need to enable AST rules;
# see https://github.com/OCA/maintainer-quality-tools/pull/618#issuecomment-558576890
Expand Down
13 changes: 12 additions & 1 deletion .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ jobs:
pre-commit:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: actions/setup-python@v2
with:
python-version: "3.11"
- name: Get python version
run: echo "PY=$(python -VV | sha256sum | cut -d' ' -f1)" >> $GITHUB_ENV
- uses: actions/cache@v1
Expand All @@ -25,6 +27,15 @@ jobs:
run: pip install pre-commit
- name: Run pre-commit
run: pre-commit run --all-files --show-diff-on-failure --color=always
env:
# Consider valid a PR that changes README fragments but doesn't
# change the README.rst file itself. It's not really a problem
# because the bot will update it anyway after merge. This way, we
# lower the barrier for functional contributors that want to fix the
# readme fragments, while still letting developers get README
# auto-generated (which also helps functionals when using runboat).
# DOCS https://pre-commit.com/#temporarily-disabling-hooks
SKIP: oca-gen-addon-readme
- name: Check that all files generated by pre-commit are in git
run: |
newfiles="$(git ls-files --others --exclude-from=.gitignore)"
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/stale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Stale PRs and issues policy
uses: actions/stale@v4
uses: actions/stale@v9
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
# General settings.
Expand Down Expand Up @@ -48,7 +48,7 @@ jobs:
# * Issues that are pending more information
# * Except Issues marked as "no stale"
- name: Needs more information stale issues policy
uses: actions/stale@v4
uses: actions/stale@v9
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
ascending: true
Expand Down
10 changes: 6 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
runs-on: ubuntu-latest
name: Detect unreleased dependencies
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- run: |
for reqfile in requirements.txt test-requirements.txt ; do
if [ -f ${reqfile} ] ; then
Expand All @@ -36,10 +36,10 @@ jobs:
matrix:
include:
- container: ghcr.io/oca/oca-ci/py3.6-odoo14.0:latest
makepot: "true"
name: test with Odoo
- container: ghcr.io/oca/oca-ci/py3.6-ocb14.0:latest
name: test with OCB
makepot: "true"
services:
postgres:
image: postgres:9.6
Expand All @@ -50,7 +50,7 @@ jobs:
ports:
- 5432:5432
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
persist-credentials: false
- name: Install addons and dependencies
Expand All @@ -63,7 +63,9 @@ jobs:
run: oca_init_test_database
- name: Run tests
run: oca_run_tests
- uses: codecov/codecov-action@v1
- uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
- name: Update .pot files
run: oca_export_and_push_pot https://x-access-token:${{ secrets.GIT_PUSH_TOKEN }}@github.com/${{ github.repository }}
if: ${{ matrix.makepot == 'true' && github.event_name == 'push' && github.repository_owner == 'OCA' }}
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ __pycache__/
*.py[cod]
/.venv
/.pytest_cache
/.ruff_cache

# C extensions
*.so
Expand All @@ -24,6 +25,15 @@ var/
*.egg
*.eggs

# Debian packages
*.deb

# Redhat packages
*.rpm

# MacOS packages
*.dmg

# Installer logs
pip-log.txt
pip-delete-this-directory.txt
Expand Down
2 changes: 2 additions & 0 deletions .oca_hooks.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[MESSAGES_CONTROL]
disable=xml-deprecated-data-node,xml-deprecated-tree-attribute
25 changes: 23 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,16 @@ exclude: |
/static/(src/)?lib/|
# Repos using Sphinx to generate docs don't need prettying
^docs/_templates/.*\.html$|
# Don't bother non-technical authors with formatting issues in docs
readme/.*\.(rst|md)$|
# Ignore build and dist directories in addons
/build/|/dist/|
# Ignore test files in addons
/tests/samples/.*|
# You don't usually want a bot to modify your legal texts
(LICENSE.*|COPYING.*)
(LICENSE.*|COPYING.*)|
# Ignore manual docs
connector/doc/*
default_language_version:
python: python3
node: "14.13.0"
Expand All @@ -33,12 +41,25 @@ repos:
language: fail
files: '[a-zA-Z0-9_]*/i18n/en\.po$'
- repo: https://github.com/oca/maintainer-tools
rev: ab1d7f6
rev: d5fab7ee87fceee858a3d01048c78a548974d935
hooks:
# update the NOT INSTALLABLE ADDONS section above
- id: oca-update-pre-commit-excluded-addons
- id: oca-fix-manifest-website
args: ["https://github.com/OCA/connector"]
- id: oca-gen-addon-readme
args:
- --addons-dir=.
- --branch=14.0
- --org-name=OCA
- --repo-name=connector
- --if-source-changed
- --keep-source-digest
- repo: https://github.com/OCA/odoo-pre-commit-hooks
rev: v0.0.25
hooks:
- id: oca-checks-odoo-module
- id: oca-checks-po
- repo: https://github.com/myint/autoflake
rev: v1.4
hooks:
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ Available addons
----------------
addon | version | maintainers | summary
--- | --- | --- | ---
[component](component/) | 14.0.1.1.2 | [![guewen](https://github.com/guewen.png?size=30px)](https://github.com/guewen) | Add capabilities to register and use decoupled components, as an alternative to model classes
[component_event](component_event/) | 14.0.1.0.3 | | Components Events
[component](component/) | 14.0.1.2.0 | [![guewen](https://github.com/guewen.png?size=30px)](https://github.com/guewen) | Add capabilities to register and use decoupled components, as an alternative to model classes
[component_event](component_event/) | 14.0.1.0.4 | | Components Events
[connector](connector/) | 14.0.1.1.4 | | Connector
[connector_base_product](connector_base_product/) | 14.0.1.0.0 | | Connector Base Product
[test_component](test_component/) | 14.0.1.0.0 | [![guewen](https://github.com/guewen.png?size=30px)](https://github.com/guewen) | Automated tests for Components, do not install.
Expand Down
3 changes: 2 additions & 1 deletion component/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Components
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:3251c1cf71974719f9678b155285942a7f94e2d963de4da64ed75dc7c9e1adfc
!! source digest: sha256:9e4ce3ea4266b28f0324ec340591b784dd81396e410296d4bf9ae8f9fe376b28
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Production%2FStable-green.png
Expand Down Expand Up @@ -130,6 +130,7 @@ Contributors

* Guewen Baconnier <[email protected]>
* Laurent Mignon <[email protected]>
* Simone Orsi <[email protected]>

Maintainers
~~~~~~~~~~~
Expand Down
2 changes: 1 addition & 1 deletion component/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"name": "Components",
"summary": "Add capabilities to register and use decoupled components,"
" as an alternative to model classes",
"version": "14.0.1.1.2",
"version": "14.0.1.2.0",
"author": "Camptocamp," "Odoo Community Association (OCA)",
"website": "https://github.com/OCA/connector",
"license": "LGPL-3",
Expand Down
13 changes: 8 additions & 5 deletions component/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from odoo import models
from odoo.tools import LastOrderedSet, OrderedSet

from .exception import NoComponentError, SeveralComponentError
from .exception import NoComponentError, RegistryNotReadyError, SeveralComponentError

_logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -252,14 +252,17 @@ def __init__(
dbname = self.env.cr.dbname
try:
self.components_registry = _component_databases[dbname]
except KeyError:
_logger.error(
except KeyError as exc:
msg = (
"No component registry for database %s. "
"Probably because the Odoo registry has not been built "
"yet.",
"yet."
)
_logger.error(
msg,
dbname,
)
raise
raise RegistryNotReadyError(msg) from exc
self._propagate_kwargs = ["collection", "model_name", "components_registry"]
for attr_name, value in kwargs.items():
setattr(self, attr_name, value)
Expand Down
4 changes: 4 additions & 0 deletions component/exception.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,7 @@ class NoComponentError(ComponentException):

class SeveralComponentError(ComponentException):
"""More than one component have been found"""


class RegistryNotReadyError(ComponentException):
"""Component registry not ready yet for given DB."""
1 change: 1 addition & 0 deletions component/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
* Guewen Baconnier <[email protected]>
* Laurent Mignon <[email protected]>
* Simone Orsi <[email protected]>
15 changes: 9 additions & 6 deletions component/static/description/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
Expand All @@ -9,10 +8,11 @@

/*
:Author: David Goodger ([email protected])
:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $
:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $
:Copyright: This stylesheet has been placed in the public domain.
Default cascading style sheet for the HTML output of Docutils.
Despite the name, some widely supported CSS2 features are used.
See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
customize this style sheet.
Expand Down Expand Up @@ -275,7 +275,7 @@
margin-left: 2em ;
margin-right: 2em }

pre.code .ln { color: grey; } /* line numbers */
pre.code .ln { color: gray; } /* line numbers */
pre.code, code { background-color: #eeeeee }
pre.code .comment, code .comment { color: #5C6576 }
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
Expand All @@ -301,7 +301,7 @@
span.pre {
white-space: pre }

span.problematic {
span.problematic, pre.problematic {
color: red }

span.section-subtitle {
Expand Down Expand Up @@ -367,7 +367,7 @@ <h1 class="title">Components</h1>
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:3251c1cf71974719f9678b155285942a7f94e2d963de4da64ed75dc7c9e1adfc
!! source digest: sha256:9e4ce3ea4266b28f0324ec340591b784dd81396e410296d4bf9ae8f9fe376b28
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Production/Stable" src="https://img.shields.io/badge/maturity-Production%2FStable-green.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/licence-LGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/connector/tree/14.0/component"><img alt="OCA/connector" src="https://img.shields.io/badge/github-OCA%2Fconnector-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/connector-14-0/connector-14-0-component"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/connector&amp;target_branch=14.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>This module implements a component system and is a base block for the Connector
Expand Down Expand Up @@ -477,12 +477,15 @@ <h2><a class="toc-backref" href="#toc-entry-9">Contributors</a></h2>
<ul class="simple">
<li>Guewen Baconnier &lt;<a class="reference external" href="mailto:guewen.baconnier&#64;camptocamp.com">guewen.baconnier&#64;camptocamp.com</a>&gt;</li>
<li>Laurent Mignon &lt;<a class="reference external" href="mailto:laurent.mignon&#64;acsone.eu">laurent.mignon&#64;acsone.eu</a>&gt;</li>
<li>Simone Orsi &lt;<a class="reference external" href="mailto:simone.orsi&#64;camptocamp.com">simone.orsi&#64;camptocamp.com</a>&gt;</li>
</ul>
</div>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#toc-entry-10">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
<a class="reference external image-reference" href="https://odoo-community.org">
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
</a>
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.</p>
Expand Down
1 change: 1 addition & 0 deletions component/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
from . import test_component
from . import test_lookup
from . import test_work_on
from . import test_utils
20 changes: 20 additions & 0 deletions component/tests/test_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright 2023 Camptocamp SA
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html)

from unittest import mock

from odoo.addons.component.utils import is_component_registry_ready

from .common import TransactionComponentRegistryCase


class TestUtils(TransactionComponentRegistryCase):
def test_registry_ready(self):
path = "odoo.addons.component.utils.get_component_registry"
with mock.patch(path) as mocked:
mocked.return_value = None
self.assertFalse(is_component_registry_ready(self.env.cr.dbname))
self._setup_registry(self)
mocked.return_value = self.comp_registry
self.assertTrue(is_component_registry_ready(self.env.cr.dbname))
self._teardown_registry(self)
14 changes: 14 additions & 0 deletions component/utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Copyright 2023 Camptocamp SA
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html)

from .core import _component_databases


def get_component_registry(dbname):
return _component_databases.get(dbname)


def is_component_registry_ready(dbname):
"""Return True if the registry is ready to be used."""
comp_registry = get_component_registry(dbname)
return comp_registry.ready if comp_registry else False
2 changes: 1 addition & 1 deletion component_event/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Components Events
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:7c81fb5d20758cde6818ec935cdc9d6c3add8fd33a8a36c58cf83541375413fb
!! source digest: sha256:de1e8576f3deb72993535826d37a69c1b899bd9102f87eb6f8ac5190d5e93944
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
Expand Down
2 changes: 1 addition & 1 deletion component_event/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

{
"name": "Components Events",
"version": "14.0.1.0.3",
"version": "14.0.1.0.4",
"author": "Camptocamp," "Odoo Community Association (OCA)",
"website": "https://github.com/OCA/connector",
"license": "LGPL-3",
Expand Down
Loading

0 comments on commit 1f3c047

Please sign in to comment.