I've been maintaining and extending an Odoo installation. Often I need to override or monkeypatch certain methods (that can't be inherited) in order to achieve the desired result.
What do you think is the best way to keep the changes maintainable?
So far there are two ways the changes are pushed in production:
- Creating a new module and overriding the method completely in a separate repo -> pushing+deploying git repo to production.
- Changing only the the code needed in local Odoo git repo, committing -> pushing+deploying git repo to production.
The problem rises when upstream code changes and breaks the override (either when minor changes happen upstream or major version upgrades).
In the first case if the method signature is the same the overridden method keeps getting called even if the content of the original method changed completely.
In the second case if there are major changes the merge/rebase fails when pulling from upstream.
Lastly there are cases when other in-house modules depend on the overridden method to function properly.
Never never do monkey patch (except for tests). Always try to call super with an if condition or putting your code after it.
Remember that stack trace is built in odoo by module sequences (see manifiest file).
Our structure is in one repo:
Our standard is:
Hint: CD/CI is made by one addons 'test' that depends on the addons installed on prod. So just marking that addon to be tested, tests are triggered with our desired setup.