Replies: 6 comments
-
I have started to work on this and it is starting to work. Usually the file odoo.cfg is not committed (at least for us). But it would be good to commit the information related to custom openupgrade_renamed_modules and openupgrade_merged_modules. I am planning to read a new configuration Then, a file stored at openupgrade-config-path will be added to the repository of the project and could contain all the specific custom configurations for Please, let me know you thoughts. |
Beta Was this translation helpful? Give feedback.
-
Could you show the code ? Or better to make a PR ? |
Beta Was this translation helpful? Give feedback.
-
I did exactly as you suggested @legalsylvain . |
Beta Was this translation helpful? Give feedback.
-
Here is the code I am adding to load the custom config +++ b/openupgrade_scripts/apriori.py
@@ -1,9 +1,42 @@
+import logging
+
+import configparser as ConfigParser
+
+import odoo
+
+def load_custom_config():
+ openupgrade_config_path = odoo.tools.config.misc.get("openupgrade").get("config_path")
+ res = {}
+ if openupgrade_config_path:
+ logging.info("load_custom_config from %s: ", openupgrade_config_path)
+ p = ConfigParser.RawConfigParser()
+ try:
+ p.read([openupgrade_config_path])
+ for sec in p.sections():
+ res.setdefault(sec, {})
+ for (name, value) in p.items(sec):
+ if value=='True' or value=='true':
+ value = True
+ if value=='False' or value=='false':
+ value = False
+ res[sec][name] = value
+ except IOError:
+ pass
+ except ConfigParser.NoSectionError:
+ pass
+ else:
+ logging.info("load_custom_config, openupgrade_config_path not set")
+
+ return res
+
+custom_config = load_custom_config()
+ and then something like this: +def _get_custom_rename_modules():
+ renamed_modules = custom_config.get("renamed_modules", {})
+ return renamed_modules
-}
+renamed_modules = _renamed_modules | _get_custom_rename_modules() I will create a clean PR later today. |
Beta Was this translation helpful? Give feedback.
-
Here is the PR: |
Beta Was this translation helpful? Give feedback.
-
Related discussion #3231 |
Beta Was this translation helpful? Give feedback.
-
Today, it is needed to change the code of the apriori.py in the OpenUpgrade repo which encourages to do more project specific work in OpenUpgrade repo which will also discourage contributions back to OCA.
A nice way to handle this case should probably be documented in
https://oca.github.io/OpenUpgrade/devfaq.html
Below is an answer from @legalsylvain on this topic initially reported here: jcdrubay#3
I faced the same question several times in the past. Each time I solved with a custom branch of openupgrade with a commit adding custom GRAP changes. Not the better, but it works.
If we want to allow the possibility to add custom rename / merge it should not be done in a pre-migration script of a custom module in my opinion. Two reasons :
openupgrade_framework
, once inupgrade_analysis
. If custom values are set in a custom modules, analysis will be wrong.komit_base
module in your addons path.So for me, the single solution I see is to add in the
apriori.py
file, something like :And in the
odoo.cfg
modulesBeta Was this translation helpful? Give feedback.
All reactions