-
-
Notifications
You must be signed in to change notification settings - Fork 8
[16.0][IMP] Scan multiple branches on a specific repository, allowing the collect of migration data on specific modules #95
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
Changes from all commits
27fa57b
8f853e1
bff345e
1798200
7cb50d3
a5af0a3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,28 +16,34 @@ class OdooProject(models.Model): | |
| active = fields.Boolean(default=True) | ||
| repository_id = fields.Many2one( | ||
| comodel_name="odoo.repository", | ||
| ondelete="restrict", | ||
| string="Repository", | ||
| domain=[ | ||
| ("clone_branch_id", "!=", False), | ||
| ("specific", "=", True), | ||
| ("odoo_version_id", "!=", False), | ||
| ], | ||
| domain=[("specific", "=", True)], | ||
| store=True, | ||
| index=True, | ||
| help=( | ||
| "Repository is optional. " | ||
| "Repository this project is based on (optional). " | ||
| "You can start to build/simulate a project without repository " | ||
| "to get some figures." | ||
| ), | ||
| ) | ||
| available_odoo_version_ids = fields.One2many( | ||
| comodel_name="odoo.branch", | ||
| compute="_compute_available_odoo_version_ids", | ||
| string="Available Odoo Versions", | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what does it mean ?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is a technical field to list the available Odoo versions that have been scanned in this repository. It is used by
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If your project is not linked to a repository, all Odoo versions are legit, you can select the one you want.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. so if this project is linked to a repository containing branches: "master", "main", "staging", "feat/123", "feat/125"... "feat/9999" What is the gain ?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To not make mistake, the user creating the project in your
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And your branch |
||
| ) | ||
| odoo_version_id = fields.Many2one( | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is it in production version ?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, I still didn't have time to separate the notion of "Odoo project" and "Odoo project instance". For now,
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With #98 , having one project is enough for me, at the moment. |
||
| comodel_name="odoo.branch", | ||
| ondelete="restrict", | ||
| string="Odoo Version", | ||
| domain=[("odoo_version", "=", True)], | ||
| required=True, | ||
| compute="_compute_odoo_version_id", | ||
| store=True, | ||
| readonly=False, | ||
| index=True, | ||
| ) | ||
| repository_branch_id = fields.Many2one( | ||
| comodel_name="odoo.repository.branch", | ||
| string="Repository / Branch", | ||
| compute="_compute_repository_branch_id", | ||
| store=True, | ||
| index=True, | ||
| ) | ||
| project_module_ids = fields.One2many( | ||
| comodel_name="odoo.project.module", | ||
|
|
@@ -74,10 +80,22 @@ class OdooProject(models.Model): | |
| ) | ||
|
|
||
| @api.depends("repository_id") | ||
| def _compute_odoo_version_id(self): | ||
| def _compute_available_odoo_version_ids(self): | ||
| all_versions = self.env["odoo.branch"]._get_all_odoo_versions() | ||
| for rec in self: | ||
| rec.available_odoo_version_ids = all_versions | ||
| if rec.repository_id: | ||
| rec.odoo_version_id = rec.repository_id.odoo_version_id | ||
| rec.available_odoo_version_ids = rec.repository_id.branch_ids.branch_id | ||
|
|
||
| @api.depends("repository_id", "odoo_version_id") | ||
| def _compute_repository_branch_id(self): | ||
| for rec in self: | ||
| rec.repository_branch_id = False | ||
| if not rec.repository_id or not rec.odoo_version_id: | ||
| continue | ||
| rec.repository_branch_id = rec.repository_id.branch_ids.filtered( | ||
| lambda rb: rb.branch_id == rec.odoo_version_id | ||
| ) | ||
|
|
||
| @api.depends("project_module_ids.module_id") | ||
| def _compute_module_ids(self): | ||
|
|
@@ -90,11 +108,11 @@ def _compute_modules_count(self): | |
| rec.modules_count = len(rec.project_module_ids) | ||
|
|
||
| @api.depends( | ||
| "repository_id.branch_ids.module_ids", "project_module_ids.module_branch_id" | ||
| "repository_branch_id.module_ids", "project_module_ids.module_branch_id" | ||
| ) | ||
| def _compute_module_not_installed_ids(self): | ||
| for rec in self: | ||
| all_module_ids = set(rec.repository_id.branch_ids.module_ids.ids) | ||
| all_module_ids = set(rec.repository_branch_id.module_ids.ids) | ||
| installed_module_ids = set(rec.project_module_ids.module_branch_id.ids) | ||
| rec.module_not_installed_ids = list(all_module_ids - installed_module_ids) | ||
|
|
||
|
|
@@ -145,12 +163,12 @@ def action_find_unknown_modules(self): | |
| module.action_find_pr_url() | ||
|
|
||
| def _get_repositories_to_scan(self): | ||
| """Returnt the repositories to scan.""" | ||
| """Return the repositories to scan.""" | ||
| domain = self.env["odoo.repository"]._cron_scanner_domain() | ||
| return self.project_module_ids.repository_id.filtered_domain(domain) | ||
|
|
||
| def _get_branches_to_scan(self): | ||
| """Return the branches to scan.""" | ||
| """Return the branches/versions to scan.""" | ||
| return self.project_module_ids.repository_branch_id.branch_id | ||
|
|
||
| def action_scan(self, force=False): | ||
|
|
@@ -163,7 +181,7 @@ def action_scan(self, force=False): | |
| branches = self._get_branches_to_scan() | ||
| if branches: | ||
| repositories.action_scan( | ||
| branches=branches.mapped("name"), force=force, raise_exc=False | ||
| branch_ids=branches.ids, force=force, raise_exc=False | ||
| ) | ||
| # Scan the underlying project repository itself | ||
| self.repository_id.action_scan(force=force, raise_exc=True) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Specifichere is not clear.In my case I have repositories:
And :
./local-src--> i don't plan scan it.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Specific is for repositories that are hosting modules specific to a project, and they could not follow the branch naming convention (14.0, 15.0, 16.0, ...).
In your case, the
(gitlab)/the-projectis the specific one. Maybeakretion/private-repo-for-just-one-projectas well, I can't say.But as soon as a module could be re-used by any project simply by including the repo as a submodule, it should be qualified as generic (
specific = False). It doesn't matter if this repository is private or public.In your example,
oca/sale-workflow,shopinvader/odoo-shopinvader,forgeFlow/stock-rmaandakretion/ak-cloud-france-oiare generic repositories containing generic modules, shared between several Odoo implementations, and following Odoo branches naming convention.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
still unclear to me.
akretion/manufacture (fork of oca/manufacture) contains generic modules and follow only partially odoo branches namming convention.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"follow only partially odoo branches naming convention" => because you have dev branches there you mean. But such branches should not be scanned IMO, because the goal of such short-lifespan branches is to be merged in the main ones (16.0, 18.0...).
Specific repositories == Odoo projects repositories, they host the Odoo project, and could contain modules only tied to this project (not shared to other projects), like
{customer}_sale. If you create a module that could be re-used by another project, you probably want to host it in a generic repository designed for that (OCA, or an internal one).One thing we do not want is to configure every branches on every repositories, so with generic repositories (e.g. OCA, shopinvader...) we scan all
odoo.branchavailable, while in specific repositories (often linked to a project, which exists in only 1 Odoo version, max 2 if you are currently migrating it), you probably usemain/masteras your production branch, and this one represents e.g. a16.0version (whenspecific = True, you can enter manually yourodoo.repository.branchrecords to specify that).TL;DR:
specific=False(generic), branches scanned are the availableodoo.branchrecordsspecific=True(i.e. projects), branches to scan are configured manuallyIt's a convention based on what exists, but of course if you have a generic repository where we name branches
v16/v17/v18this pattern doesn't work anymore and would need some updates.Beside that, a specific module (so a module scanned in a specific repository) won't have the highest priority when it comes to find modules/dependencies here and there. E.g. you have a project A repo with specific module named
m, and a project B repo with specific module also namedm(it's possible because they are specific repos), if later a module is scanned elsewhere (in any other repo other than A or B), having a dependency againstm, it won't find it on purpose, as a specific module can have reverse dependencies only in its own repository where it is hosted.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we could split these two notions in two separate fields:
scan_default_branchesto define if branches have to be scanned based onodoo.branch(Odoo naming convention) or based on user input with specific branch names (masteretc)specificto ensure its modules will have its reverse dependencies in the same repo, so they cannot be used in other repo/projectRight now both are mixed 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah ah ! if only !
I plan to scan them one way or another. We have so many PR waiting (or closed!) because of external factors or individuals.
We have also projects still in 14.0, we target publishing in OCA 18.0 and keep a back-port up-to-date.
I've made a proto few months ago, but it's far from working. Here is the big picture:
From the project page, instead of copy /pasting the module list, I copy paste our "spec.yaml", it's the gitaggretor file with shorter syntax and a module list.
The module list is then used to create symbolic links in a directory in the addon_path.
For instance:
Will transform to:
and is piped into gitaggregator.
So with this input, I create "forked repos":
Fork=FalseForked=oca/manufactureAnd I create akretion/manufacture#18.0-bom-configurable branch.
This branch contains the module mrp_bom_configurable for 18.0
I don't oca-scan this branch. So I get only minimum information.
But it's good enough for
Specifc module have low priority. -> yes ! We have so many "custom_reports" modules 😮💨
So, to recap the behaviors are:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I understand better your workflow there. So splitting the current
specificfield in two withscan_default_branches+specificwill make sense there, because even on your fork I guess you don't want to scan all the branches of this fork, but only a bunch of them containing strategic WIP module(s) like18.0-bom-configurable.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hparfr I added a new flag
manual_branches(that is set toTrueduring the upgrade ifspecificwas set). You can now configure your own branches while keeping modules generic.If you want to give the priority to modules hosted in such branch (long running development branches) when resolving dependencies you can set a higher priority/sequence to the repo. For now there is no possibility to choose which module version has to be included in a project if several are available.