-
-
Notifications
You must be signed in to change notification settings - Fork 448
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
Proposal: versionless branches #334
Comments
I don't see this, as each version has very different functional and technical code, so maintaining a module compatible for all versions is almost impossible... |
That would be nice indeeed in areas where Odoo is relatively stable. There would be some hurdles though. A few thoughts:
Perhaps we could experiment before 12 by enabling the master branch for some repos and see what the impact would be on the various toolchains. |
@sbidoul making a functional change on the module means to check that change on all the supported versions. That's something simply not feasible. |
It is feasible for some modules. I do it for mis builder for instance. Many modules in accounting and server-tools would work unchanged from 9 to 11. Testing across versions is more work for maintainers, that's for sure. But with the current situation we have features or fixes appearing randomly in any version and not being ported. People get bitten by that. So there is a cost too. So this idea is certainly not trivial to implement and is not applicable everywhere, but I would not dismiss it as impossible right away. |
OK, I prefer not to do that, but if the whole maintainers of something like mis_builder decides to try this approach... Everything is built around the whole version numbers, so first thing to deal is with that (the MQT check, branch name for testing, etc...). |
@sbidoul you nailed it! I think those would be the real problems, since for Python the thing is solved. Even if the addon is extremely different (Python-side), the code could even look like: if odoo.release.version < "14.0":
from . import models_13_0
else:
from . import models So the real problem is the JS, manifest and data files.
I'm not sure but I think that you can set the keys you want in the manifest. Another thing would be if they are or not processed by Odoo. We can add a decorator to That would be just the least dirty workaround in case Odoo doesn't add support for such feature, but I think they will like it and add it if a proper PR is sent to master.
I think the So you can do: <data>
<!-- Only for Odoo 12.0 -->
<data version_min="12.0" version_max="12.0">
<record>...</record>
</data>
<!-- Only for Odoo >= 13.0 -->
<data version_min="13.0">
<record>...</record>
</data>
<!-- Common stuff -->
<record>...</record>
</data>
This case would fall under the same as the above one: <data>
<data version_min="14.0">
<template id="assets_common" inherit_id="web.assets_common">
<xpath expr=".">
<link rel="stylesheet"
href="/module/static/src/css/module_name_14_0.css"/>
<script type="text/javascript"
src="/module/static/src/js/module_name_14_0.js"/>
</xpath>
</template>
</data>
</data>
Some changes would be needed here too indeed. Let me ping @moylop260 who is one of the biggest experts on MQT I think. Do you think this point would be too difficult? So it seems we are 2 small PRs away from being able to do all of this. IMHO it would be a huge step forward on OCA's maintainability! Thanks everyone! |
In order to make possible to implement a different workflow on downstream addon maintenance teams, as explained in OCA/maintainer-tools#334, Odoo needs to support version-specific code. This can be currently done in Python by checking `odoo.release.version_info` and in JS by using the `/web/webclient/version_info` controller. However, when dealing with data files, we were out of luck. With this patch: - A new cached helper is found in JS sessions, that lazy-caches version info once per session, which will make version-specific assertions a pleasure in JS. - A new attribute `versions` is supported in `<odoo>`, `<openerp>` and `<data>` elements within XML data files, that allows the programmer to specify a version spec that makes that data section be omitted when Odoo version doesn't match it. - A new `overrides` key is supported in the `__manifest__.py` file, which has the form of a dict, where keys are version specs, and values are dicts that will directly override the addon base manifest. So, for instance, to declare an addon to be available only until version 13.0 of Odoo, put this in the manifest: ```python { ... "installable": False, "overrides": { ":13": { "installable": True, } } } ```
After upstream discussion, it's clear that this one is a lost battle. 🙁 Our only chance is to stop supporting official fork and only support OCB, which I feel is another lost battle. I hope some day someone provides a solution that fixes the problems outlined in odoo/odoo#25371 (comment), at least I did all I could. |
After the initial deception, I have been thinking more on the subject, and we still can do this downstream! 💡 Of course, it will not be as cool as if odoo/odoo#25371 were merged, but still doable and not extremely ugly. We'd need a new module to serve as base for others. After thinking it for a while, I think we could call it The module should add something like this pseudocode: class Sicekick(models.AbstractModel):
_name='sidekick'
@api.model
def version_load(self, version_spec, data_file):
... This would allow dependent modules to do this: <data>
<function model="sidekick" name="version_load">
<value>11.0:</value>
<value>/views/res_partner_v11.xml</value>
</function>
</data> It would also define the needed JS controllers to make client-side version-specific code easier. The idea could be good for even providing some useful boilerplate helpers, such as The good part of this approach is that it would be 100% in the community's hands, and it would need no hacks - since calling functions in data files is standard and supported since forever - (although, if any hack is needed, it should be in that addon and not in submodules), and it could grow to not only the version-specific code, but other things as well. The bad part is that all data files wouldn't be listed in the manifest; only the cross-version ones. Now about how this would affect OCA's workflow, because I think that's another matter that we have to address. I see that many people is worried about maintainability of this approach, even calling it "crazy"; however, I find quite crazier current workflow, where source code is maintained separately for different versions. Implementing this would mean taking some new decisions and embracing new guidelines. Examples:
Of course, more things would need to change:
I think a good approach would be to have a testing playground in one or 2 repos. I.e. web & website, where I'm a PSC. Move it to this behavior for 1 year, and then after 1 year, with the real world experience, decide if we prolongate the playground, we move all to this system, or we restore web and website to 1-branch-per-version as they are now. This implies a big change, both technically and mentally. The benefit is clear to me, but I know haters gonna hate, so I won't personally reopen this. If somebody else feels like this should be done, and wants to help, please express yourself. I won't continue fighting everyone by myself. |
This approach can be partially applied, while keeping current structure of repositories.
So, I make a PR to 9.0, then it's merged, me or a robot move the code to v10 and then I update the code according to existing comments without thinking about it much. For python and maybe js it can be easily automated by checking odoo version. For xml this requires updates in odoo framework. |
@yajo just some feedback from repo where I am PFC (storage, search engine) Did you experiment your approach on some repo ? |
Milestone (Odoo version)
Upcoming 12.0+
Module(s)
all
Current workflow
Actually we have to maintain separate branches for all Odoo versions. This involves a big work about migrating addons from version n to version n+1, and when patches land in several supported versions, we have to open several PRs with several revisions, etc.
Proposed workflow
IMHO we should start from next Odoo version to avoid affecting current workflow, the upcoming 12.0, and start a new
master
branch in each repo, that will keep the addons from now on, no matter the Odoo version.From that version, the usual Pythonic workarounds to work with several versions of packages should start to happen. Example:
Migration scripts can either be into folders like
migrations/12.0.1.2.0
or likemigrations/1.2.0
, depending on if the migration affects the Odoo release upgrade, or the addon itself upgrade.Travis jobs could be triggered against all supported versions at once by defining its matrix.
Unit tests can make use of
skipIf
andskipUnless
decorators if they belong to specific odoo versions.When adding support for newer versions, those should be considered the default addon version, and old-specific stuff should land in blocks such as:
IMHO this would be a big leap forward in the maintainability of OCA addons. After all, we maintain addons, not Odoo itself (except for OCB, of course).
The text was updated successfully, but these errors were encountered: