Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
160 commits
Select commit Hold shift + click to select a range
802230c
Add 'odoo_repository'
Aug 28, 2023
b59fc62
odoo_repository: add settings panel
Oct 10, 2023
863aacd
Add 'odoo_addons_analyzer' package
Nov 2, 2023
acf0841
New data model 'odoo.project.module'
Nov 3, 2023
118c0bf
Apply pre-commit
Nov 3, 2023
4020ba1
odoo_repository: sync data from main node
Oct 10, 2023
d9d9793
odoo_repository: sort on 'sequence' for 'odoo.repository'
Nov 4, 2023
78ee83f
odoo_repository: update 'unmerged_pr' filter label
Nov 8, 2023
bd58aa7
BaseScanner: rename '_get_commit_of_git_tree' method to '_get_last_co…
Nov 19, 2023
5642bd2
MigrationScanner: check is scanning the module is relevant
Nov 19, 2023
a87a0c0
MigrationScanner: no need to fetch branches
Nov 19, 2023
2d55712
odoo_repository_migration: fix sync data from main node
Nov 22, 2023
5c0b4f1
odoo_repository: remove ORM cache from '_get_module'
Nov 23, 2023
e619295
odoo_repository: limit the scan/force-scan to selected branches
Nov 26, 2023
23084da
odoo_repository: limit main node data fetch to selected branches
Nov 30, 2023
82944c1
odoo_repository: ability to scan a branch on demand
Nov 30, 2023
8805126
odoo_repository: improve branch form view
Nov 30, 2023
6697c66
BaseScanner: fix '_get_commits_of_git_tree' to work without commit range
Nov 26, 2023
a9cf7e4
BaseScanner: improve '_get_commits_of_git_tree'
Feb 24, 2024
68767ce
odoo_repository: test lib.scanner.BaseScanner
Apr 15, 2024
013da1c
odoo_repository: automatically sort 'odoo.branch' records which are O…
Feb 24, 2024
e1df78c
odoo_repository: fix force scan of project/specific branches
Apr 8, 2024
4a563cd
odoo_repository: test lib.scanner.RepositoryScanner
Apr 16, 2024
8a76485
odoo_repository: raise error if no branches configured when scanning
Apr 17, 2024
bf8bff8
odoo_repository: configure git if no config file exists
Apr 17, 2024
b0c6a77
BaseScanner: apply git configuration at repository level
Apr 18, 2024
3fa6573
odoo_repository: test repository scan
Apr 19, 2024
265a049
BaseScanner: remove hardcoded SSH key path
Apr 19, 2024
c76cbf9
odoo_repository: always link scanned module to highest priority repos…
Apr 19, 2024
26c5f7f
RepositoryScanner: push module versions to Odoo
Nov 26, 2023
6187f19
odoo_repository: add module version data model
Nov 26, 2023
888c543
odoo_repository: import scanned module versions
Nov 26, 2023
231be28
odoo_repository: compute module URL to ease its browsing in upstream …
Apr 18, 2024
effa0f5
odoo_repository: import module versions from main node
Dec 1, 2023
4b3569d
odoo_project_migration: list migration scripts to consider for a give…
Apr 19, 2024
9d36c57
BaseScanner: ensure to clean up local repository before checkout
Apr 22, 2024
a914255
odoo_repository: auto-archive odoo.repository.branch records
Apr 24, 2024
37d2449
odoo_repository: fix 'odoo.repository.action_scan' to not override 'b…
Apr 25, 2024
f2baf93
MigrationScanner: store 'oca_port' cache in repositories data folder
Apr 25, 2024
46ba42e
odoo_repository: handle git authentication with tokens
May 2, 2024
8a970ce
odoo_repository: handle blacklisted modules
May 10, 2024
c59b989
odoo_repository: add odoo/enterprise repository (archived by default)
May 10, 2024
4163ce8
odoo_repository: provide common addons_path
May 10, 2024
0a2c04c
odoo_repository: handle module removed from a repository branch
May 23, 2024
064dade
odoo_repository: fix singleton error in 'action_scan' method
May 23, 2024
a887fb8
odoo_repository: fix module removal
Jun 13, 2024
c886176
odoo_repository: do not set repo type always required
Jun 14, 2024
2349954
odoo_repository: add dependency levels of modules
Jul 12, 2024
ed61c26
BaseScanner: workaround FS errors when cloning repositories
Jul 31, 2024
02fc90e
odoo_repository: add option to workaround FS errors
Jul 31, 2024
28a9b8c
odoo_repository: fix, enable 'test_odoo_repository_scan'
Aug 1, 2024
cf6d260
BaseScanner: always use remote URL provided by Odoo
Aug 20, 2024
f6aa490
odoo_repository: list recursive dependencies from module form
Aug 20, 2024
21a9077
odoo_repository: remove readonly modifiers on 'odoo.repository' form
Aug 20, 2024
6efc615
Scanner: do not raise an error if a branch doesn't exist
Aug 23, 2024
00d4057
Scanner: do not clone/fetch blobs
Aug 23, 2024
24d3620
Scanner: disable some git GC features
Aug 26, 2024
28ee679
odoo_repository: fix access right on 'odoo.module.branch.version'
Aug 26, 2024
d18795a
Scanner: remove dangling 'git' process
Aug 26, 2024
8f8a792
odoo_repository: use 'queue_job__no_delay' ctx key in tests
Aug 26, 2024
c65911e
BaseScanner: revert changes in '_fetch'
Aug 28, 2024
f8cad90
BaseScanner: fix 'scan' method ('res' not defined)
Sep 12, 2024
009f0b0
odoo_repository: add odoo/design-themes repository
Sep 18, 2024
5126683
BaseScanner: fix '_get_last_fetched_commit' and '_checkout_branch'
Sep 18, 2024
d19a00e
BaseScanner: fix handling of ambiguous branches
Sep 18, 2024
18fe2d0
BaseScanner: fix _checkout_branch
Sep 20, 2024
407684f
odoo_repository: imp. 'odoo.module.branch' tree view
Sep 20, 2024
2921858
BaseScanner: fix _checkout_branch
Sep 20, 2024
725c58c
odoo_repository: split RepositoryScanner jobs in smaller jobs
Sep 22, 2024
718a265
odoo_repository_migration: split MigrationScanner jobs in smaller jobs
Sep 23, 2024
d60f979
BaseScanner: fix git config safe.directory
Sep 25, 2024
0f67567
odoo_repository: fix _detect_modules_to_scan_on_branch if no jobs
Oct 11, 2024
2438444
BaseScanner: improve clone IO performance
Oct 17, 2024
76a14a9
odoo_repository: add User and Manager user groups
Oct 17, 2024
d8c7fdb
odoo_repository: add OCA/stock-weighing repository
Oct 18, 2024
4817d6e
BaseScanner: do not raise if a branch is not found when cloning
Oct 21, 2024
4d6ea13
odoo_repository: update app icon + clean up static/description folder
Oct 24, 2024
17ffcbb
odoo_repository: limit scan of repo to selected weekdays
Oct 28, 2024
88ed8ae
odoo_repository: add 'button_box' div on repository form
Oct 18, 2024
7f3cd45
odoo_repository: option to force cloned repository name
Oct 29, 2024
1e86867
[REF] Allow same module name across different repositories
Oct 18, 2024
37c3426
odoo_repository_*: rename some filters
Oct 31, 2024
f9d5798
MigrationScanner: upgrade oca-port
Sep 26, 2024
d0753ae
fixup! MigrationScanner: upgrade oca-port
Nov 13, 2024
34f6e67
odoo_repository: add new OCA repositories
Nov 19, 2024
2dfac36
odoo_repository[_migration]: fix access to 'ir.config_parameter'
Nov 19, 2024
0732937
odoo_repository_migration: add tests on 'migration_scan' flag
Nov 19, 2024
171de7d
odoo_repository: align tests with last version of oca-port
Nov 19, 2024
8ede420
odoo_repository: do not create dependencies and versions from install…
Nov 21, 2024
526eb12
MigrationScanner: fix TypeError
Nov 21, 2024
a40b9a4
odoo_repository_migration: fix migration data computation
Dec 9, 2024
7580903
odoo_repository: add new OCA logistics repositories
Mar 7, 2025
e6947bd
BaseScanner: improve helper methods to work on other remotes than 'or…
Mar 13, 2025
b25e22e
odoo_repository_migration: support migration scan between two reposit…
Mar 13, 2025
56affd2
MigrationScanner: support module renaming
Apr 11, 2025
7a8c147
odoo_repository: give write access on module branch for managers
Apr 11, 2025
eed9445
odoo_repository: add new OCA stock-logistics-putaway repository
May 6, 2025
c08ba05
odoo_repository: new field '<odoo.module.branch>.full_path'
May 28, 2025
6ab8d72
odoo_repository: add new OCA shopfloor-app repository
Jun 3, 2025
dfc9d71
odoo_repository: add new OCA bank-payment-alternative repository
hparfr Jun 20, 2025
79cbcf2
[FIX] odoo-addons-analyzer: ignore symlinks
Jun 24, 2025
086b542
odoo_repository: scan multiple branches of a repository
May 28, 2025
b923cee
fixup! odoo_repository: scan multiple branches of a specific (project…
Jul 7, 2025
3338f29
BaseScanner: fix '_get_module_paths' method if tree path we are looki…
Jul 7, 2025
d35086b
odoo_repository: add new OCA sale-blanket repository
Jul 8, 2025
bd3cad5
odoo_repository: fix '_find' method if no repository
Jul 8, 2025
b68fd0a
[FIX] odoo-addons-analyzer: skip file in case of parsing error
Aug 28, 2025
fb01e7a
[FIX] odoo_repository: remove all specific modules when removing spec…
Sep 12, 2025
e30f2fc
[IMP] odoo_repository: add a pivot view for 'Modules' menu entry
Sep 12, 2025
b0272ed
[IMP] odoo_repository: add a graph view in a 'Module Analysis' report…
Sep 12, 2025
c4e207f
odoo_repository: add '<odoo.branch>.next_id' field
Sep 14, 2025
29de03f
odoo_repository: add '<odoo.module.branch>.branch_sequence' field
Sep 14, 2025
62a3ba3
odoo_repository: add a root menu 'Data' to host all collected generic…
Sep 14, 2025
f6e4220
Add 'odoo_project_changelog' module
Jun 7, 2024
3646c6b
[IMP] odoo_repository: switch to 'odoo-addons-parser' package
Oct 23, 2025
6afdfb4
[UPD] README.rst
OCA-git-bot Dec 3, 2025
bdbdb4d
[FIX] odoo_repository: add 'base' dependency by default on scanned mo…
Dec 8, 2025
befd54b
[UPD] README.rst
OCA-git-bot Dec 8, 2025
093540e
[IMP] odoo_repository: update README
Dec 3, 2025
0e26c50
[UPD] README.rst
OCA-git-bot Dec 8, 2025
092bfa9
[FIX] odoo_repository_migration: trigger a fetch if module not found …
Dec 8, 2025
f1c00e8
[BOT] post-merge updates
OCA-git-bot Dec 8, 2025
a25c094
[FIX] odoo_repository: put repository fields readonly when some modul…
Dec 10, 2025
2b8a752
[BOT] post-merge updates
OCA-git-bot Dec 10, 2025
5dbc1f6
[FIX] odoo_repository: prevent duplicated module versions
Dec 10, 2025
bd230ed
[BOT] post-merge updates
OCA-git-bot Dec 10, 2025
7f28133
[FIX] odoo_repository: followup, add 'base' dependency by default on …
Jan 9, 2026
66d6297
[BOT] post-merge updates
OCA-git-bot Jan 11, 2026
c3b6ec1
Update all modules manifest and README with new repo info
Jan 17, 2026
df6090b
[BOT] post-merge updates
OCA-git-bot Jan 17, 2026
4f16f7a
[IMP] odoo_repository: pre-commit auto fixes
sebalix Feb 1, 2026
010a41a
[IMP] odoo_repository: pre-commit fixes
sebalix Feb 1, 2026
64e114d
[MIG] odoo_repository: Migration to 18.0
sebalix Feb 1, 2026
fa55d0e
[FIX] odoo_repository: remove dangling 'git' process when running tests
sebalix Feb 1, 2026
6c379b1
[UPD] Update odoo_repository.pot
Feb 4, 2026
5ded7ed
[BOT] post-merge updates
OCA-git-bot Feb 4, 2026
4b4079e
Added translation using Weblate (Italian)
mymage Feb 10, 2026
649b15a
[IMP] odoo_repository: sync OCA repositories
sebalix Feb 16, 2026
ac01c37
[UPD] Update odoo_repository.pot
Feb 22, 2026
96a717e
[BOT] post-merge updates
OCA-git-bot Feb 22, 2026
5463989
Update translation files
weblate Feb 22, 2026
f4552fd
[IMP] odoo_repository: replace oca-port dependency in tests
sebalix Feb 22, 2026
bfeb670
[BOT] post-merge updates
OCA-git-bot Feb 24, 2026
7b658c1
[IMP] odoo_repository: generate git repository in setUpClass
sebalix Feb 26, 2026
c7cdb18
[FIX] odoo_repository: fix '_get_recursive_dependencies' method
sebalix Feb 24, 2026
b2f70e4
[FIX] odoo_repository: fix tests cleanup and remove unused code
sebalix Mar 1, 2026
016a6ca
[BOT] post-merge updates
OCA-git-bot Mar 1, 2026
723b441
[DEL] explicit commits, they are not allowed in queue jobs
thomaspaulb Mar 24, 2026
7d2fb66
[BOT] post-merge updates
OCA-git-bot Mar 27, 2026
f3d2a84
[FIX] odoo_repository: tests, apply git config in repository
sebalix Mar 30, 2026
5f0cdf3
[FIX] odoo_repository: move setUp content to setUpClass
sebalix Apr 10, 2026
eb38b14
[BOT] post-merge updates
OCA-git-bot Apr 10, 2026
815fbd6
[IMP] odoo_repository: add <odoo.branch>.previous_id field
sebalix May 27, 2026
95bebf0
[UPD] Update odoo_repository.pot
Jun 13, 2026
b6ba9ad
[BOT] post-merge updates
OCA-git-bot Jun 13, 2026
c1c5f8b
Update translation files
weblate Jun 13, 2026
d6fb9b2
[MIG] odoo_repository: Migration to 19.0
alan196 Jul 29, 2026
b189a42
[FIX] odoo_repository: wait for GitHub API rate limit reset
alan196 Aug 5, 2026
435c8ac
[FIX] odoo_repository: scan of modules with a list as manifest author
alan196 Aug 5, 2026
f8b1c7e
[FIX] odoo_repository: do not fail scan on module code analysis error
alan196 Aug 5, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 90 additions & 0 deletions odoo_repository/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
.. image:: https://odoo-community.org/readme-banner-image
:target: https://odoo-community.org/get-involved?utm_source=readme
:alt: Odoo Community Association

========
Odoo MCA
========

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:71e3b6009a205241f59db8ab094782861157f514480a57b630abc8e1a10c8d92
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/license-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fmodule--composition--analysis-lightgray.png?logo=github
:target: https://github.com/OCA/module-composition-analysis/tree/19.0/odoo_repository
:alt: OCA/module-composition-analysis
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/module-composition-analysis-19-0/module-composition-analysis-19-0-odoo_repository
: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/module-composition-analysis&target_branch=19.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

Base module to host data collected from Odoo repositories.

It allows you to:

- declare the Odoo versions (last 3 versions by default)
- declare repositories containing modules (Odoo repositories included by
default, and OCA ones are synced automatically)
- scan these repositories to collect modules informations per Odoo
version

**Table of contents**

.. contents::
:local:

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/module-composition-analysis/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 <https://github.com/OCA/module-composition-analysis/issues/new?body=module:%20odoo_repository%0Aversion:%2019.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

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

Credits
=======

Authors
-------

* Camptocamp

Contributors
------------

- Camptocamp

- Sébastien Alix <seb@usr-src.org>

Maintainers
-----------

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

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.

This module is part of the `OCA/module-composition-analysis <https://github.com/OCA/module-composition-analysis/tree/19.0/odoo_repository>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
3 changes: 3 additions & 0 deletions odoo_repository/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from . import models
from . import components
from . import controllers
63 changes: 63 additions & 0 deletions odoo_repository/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Copyright 2023 Camptocamp SA
# Copyright 2026 Sébastien Alix
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)
{
"name": "Odoo MCA",
"summary": "Base module to host data collected from Odoo repositories.",
"version": "19.0.1.0.0",
"category": "Tools",
"author": "Camptocamp, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/module-composition-analysis",
"data": [
"security/res_groups.xml",
"security/ir.model.access.csv",
"data/ir_cron.xml",
"data/odoo_module.xml",
"data/odoo_repository_org.xml",
"data/odoo_repository_addons_path.xml",
"data/odoo_repository.xml",
"data/odoo_branch.xml",
"data/queue_job.xml",
"data/odoo_mca_backend.xml",
"data/ir_config_parameter.xml",
"views/menu.xml",
"views/authentication_token.xml",
"views/ssh_key.xml",
"views/odoo_author.xml",
"views/odoo_branch.xml",
"views/odoo_license.xml",
"views/odoo_maintainer.xml",
"views/odoo_module.xml",
"views/odoo_module_branch.xml",
"views/odoo_module_category.xml",
"views/odoo_module_dev_status.xml",
"views/odoo_python_dependency.xml",
"views/odoo_repository.xml",
"views/odoo_repository_addons_path.xml",
"views/odoo_repository_branch.xml",
"views/odoo_repository_org.xml",
"views/res_config_settings.xml",
],
"installable": True,
"application": True,
"depends": [
# core
"base_sparse_field",
# OCA/server-tools
"base_time_window",
# OCA/queue
"queue_job",
# OCA/connector
"component",
],
"external_dependencies": {
"python": [
"gitpython",
"odoo-addons-parser",
"pyyaml",
# TODO to publish
# "odoo-repository-scanner"
],
},
"license": "AGPL-3",
}
1 change: 1 addition & 0 deletions odoo_repository/components/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import oca_repository_synchronizer
225 changes: 225 additions & 0 deletions odoo_repository/components/oca_repository_synchronizer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,225 @@
# Copyright 2026 Sébastien Alix
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)

import logging

import requests
import yaml

from odoo import Command

from odoo.addons.component.core import Component
from odoo.addons.queue_job.exception import RetryableJobError

from ..utils import github

_logger = logging.getLogger(__name__)


class OCARepositorySynchronizer(Component):
"""Component for synchronizing OCA repositories from GitHub configuration.

This component is syncing the list of OCA repositories in local database
from https://github.com/OCA/repo-maintainer-conf repository.
It creates new repositories, updates existing ones, and archive those
no longer declared in the OCA configuration.
"""

_name = "oca.repository.synchronizer"
_collection = "odoo.mca.backend"
_usage = "oca.repository.synchronizer"

github_conf_api_url = "repos/OCA/repo-maintainer-conf/contents/conf/repo"

def _get_oca_repo_blacklist(self):
"""Get OCA repository blacklist from configuration parameter.

Returns:
list: List of repository names to skip during synchronization
"""
param_value = (
self.env["ir.config_parameter"]
.sudo()
.get_param("odoo_repository.oca_repo_blacklist", default="")
)
return [repo.strip() for repo in param_value.split(",") if repo.strip()]

def run(self):
"""Execute OCA repository synchronization.

Fetches repository configurations from OCA/repo-maintainer-conf,
parses the YAML files, and synchronizes the local repository database by:
- Creating new repositories that exist in OCA config but not locally
- Updating existing repositories with any changes
- Archiving repositories that no longer exist in OCA config
"""
try:
# Fetch YAML configurations from GitHub
repo_configs = self._fetch_oca_repo_configurations()
# Parse and extract repository data
current_repos = self._parse_oca_repo_configurations(repo_configs)
# Sync repositories (create/update/archive)
stats = self._sync_oca_repositories(current_repos)
_logger.info("OCA repository sync completed: %s", stats)
return stats
except github.GitHubRateLimitError as e:
# Postpone the job until the rate limit is reset, without
# increasing its retry counter
raise RetryableJobError(
"GitHub API rate limit reached, waiting for reset",
seconds=e.retry_after,
ignore_retry=True,
) from e
except Exception as e:
raise RetryableJobError("Failed to fetch OCA repositories") from e

def _fetch_oca_repo_configurations(self):
"""Fetch OCA repository configurations from GitHub.

Returns:
dict: Repository configurations keyed by filename
"""
try:
# Get list of files in conf/repo directory
files = github.request(self.work.env, self.github_conf_api_url)
repo_configs = {}
for file_info in files:
if file_info["name"].endswith(".yml"):
# Fetch the actual YAML content
download_url = file_info["download_url"]
response = requests.get(download_url, timeout=30)
response.raise_for_status()
repo_configs[file_info["name"]] = response.text
return repo_configs
except Exception as e:
_logger.error("Failed to fetch OCA repo configurations: %s", str(e))
raise

def _parse_oca_repo_configurations(self, repo_configs: dict):
"""Parse YAML configurations and extract OCA repository data.

Args:
repo_configs: Dict of filename -> YAML content

Returns:
dict: Repository data keyed by repository name, only including
repositories with non-empty branches
"""
current_repos = {}
for filename, yaml_content in repo_configs.items():
try:
# Parse YAML content
data = yaml.safe_load(yaml_content)
if not data:
continue
# Process each repository in the YAML file
for repo_name, repo_config in data.items():
# Get blacklist from backend configuration
blacklist = self._get_oca_repo_blacklist()
if repo_name in blacklist:
_logger.info("Skipping import of OCA repository %s", repo_name)
continue
# Skip repositories with default_branch = 'master' or 'main'
# These are not hosting Odoo modules
default_branch = repo_config.get("default_branch", "")
if default_branch in ["master", "main"]:
_logger.info(
"Skipping OCA repository %s "
"(default_branch=%s, not hosting Odoo modules)",
repo_name,
default_branch,
)
continue
# Only include repositories with branches.
# Others repositories are probably not hosting Odoo modules.
branches = repo_config.get("branches", [])
if not branches:
continue
# Construct repository URLs
repo_url = f"https://github.com/OCA/{repo_name}" # noqa: E231
current_repos[repo_name] = {
"name": repo_name,
"repo_url": repo_url,
"clone_url": repo_url,
"repo_type": "github",
}
except yaml.YAMLError as e:
_logger.warning("Failed to parse YAML file %s: %s", filename, str(e))
continue
except Exception as e:
_logger.warning("Error processing file %s: %s", filename, str(e))
continue
return current_repos

def _sync_oca_repositories(self, current_repos):
"""Synchronize OCA repositories with current configuration.

Args:
current_repos: Dict of repository data from OCA configuration

Returns:
dict: Statistics about created/updated/archived repositories
"""
stats = {"created": 0, "updated": 0, "archived": 0}
env = self.work.env
# Get OCA organization
oca_org = env.ref(
"odoo_repository.odoo_repository_org_oca", raise_if_not_found=False
)
if not oca_org:
_logger.warning("OCA organization not found in database")
return stats
# Get existing OCA repositories
odoo_repository = env["odoo.repository"]
existing_repos = odoo_repository.with_context(active_test=False).search(
[("org_id", "=", oca_org.id)]
)
# Process current repositories
for repo_name, repo_data in current_repos.items():
# Check if repository already exists
repo = existing_repos.filtered(
lambda r, repo_name=repo_name: r.name == repo_name
)
if repo:
# Update existing repository
update_vals = self._prepare_oca_repository_update_vals(repo_data)
# Only update if values have changed
if any(repo[field] != update_vals[field] for field in update_vals):
repo.write(update_vals)
stats["updated"] += 1
else:
# Create new repository
create_vals = self._prepare_oca_repository_create_vals(repo_data)
odoo_repository.create(create_vals)
stats["created"] += 1
# Archive repositories that no longer exist in configuration
for repo in existing_repos:
if repo.name not in current_repos and repo.active:
repo.active = repo.to_scan = False
stats["archived"] += 1
return stats

def _prepare_oca_repository_update_vals(self, repo_data):
return {
"repo_url": repo_data["repo_url"],
"clone_url": repo_data["clone_url"],
"repo_type": repo_data["repo_type"],
"active": True,
}

def _prepare_oca_repository_create_vals(self, repo_data):
oca_org = self.work.env.ref("odoo_repository.odoo_repository_org_oca")
addons_path_community = self.work.env.ref(
"odoo_repository.odoo_repository_addons_path_community"
)
return {
"org_id": oca_org.id,
"name": repo_data["name"],
"repo_url": repo_data["repo_url"],
"clone_url": repo_data["clone_url"],
"repo_type": repo_data["repo_type"],
"active": True,
"sequence": 200,
"to_scan": True, # Enable scanning by default
"addons_path_ids": [Command.link(addons_path_community.id)],
}
1 change: 1 addition & 0 deletions odoo_repository/controllers/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import main
Loading
Loading