-
-
Notifications
You must be signed in to change notification settings - Fork 711
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
[15.0][OU] Add domain field list #3892
base: 15.0
Are you sure you want to change the base?
Conversation
This list of domain fields is used from openupgradelib to be updated on renaming fields.
Hi @legalsylvain, @StefanRijnhart, |
@pedrobaeza It is ready for review |
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.
Hi. @ernestotejeda. Thanks for the improvment.
However, I think that there is something wrong in the general design.
openupgrade_scripts.pre-migration.migrate() -> openupgradelib.rename_fields() -> openupgradelib.update_domain_fields() -> openupgrade_framework.domain_fields
That makes openupgrade -> openupgradelib -> openupgrade that is not good.
That settings doesn't have to be in the openupgrade_framework module. The objective of this module is to contains odoo patches.
Not sure to understand all the algorithm, but I think that we should :
- add extra optional values in the
field_spec
args of openpugradelib.rename_fields() - and set all the tuples in each according pre-migration scripts. (
base_automation
,coupon
, etc...)
What do you think ?
CC : @StefanRijnhart
It's not an easy design decision, and it has been well though, but there's no good one. The problem We have some fields that represents a domain, both on Odoo core (like When a field is renamed between versions, if one of these domains contain such field, it will give error the next time the domain is used. We have an openupgradelib method What we want is to be able to have dynamically adjusted these domains with the new field name for avoiding "post-migration runtime" errors and needing to manually change each of them. Current solution Maintain a list of static mappings of model, domain field and field referencing the model per version, and use it each time Pros
Cons
|
Hi @pedrobaeza. Thanks a lot for the explanation. The need is totally legit, and your argument makes senses. Indeed, having a fields. (*) : If doing a migration inside the same version, for this to work requires to have the module openupgrade_framework in your path. CC : @StefanRijnhart |
Note: you won't have any error, but you won't benefit either from this feature not having |
how about recording the fields having been renamed in some global variable (or a table?) and postprocessing the domain fields in end_migration? And shouldn't it be possible to detect those fields by searching for widget="domain" in all views? |
We have already talked internally about both options:
|
Hi. Thinking again I think that the current file (openupgrade_framework/domain_fields.py) in V15 should be moved in openupgradelib, in openupgradelib/domain_fields_150.py. Pro :
Cons :
it's the least disturbing design I can think of. |
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.
1. I will express my point of view:
That settings doesn't have to be in the openupgrade_framework module. The objective of this module is to contains odoo patches.
I fully agree with this.
Maintain a list of static mappings of model, domain field and field referencing the model per version, and use it each time
rename_fields
is invoked.
I agree.
I think that the current file (openupgrade_framework/domain_fields.py) in V15 should be moved in openupgradelib, in openupgradelib/domain_fields_150.py
I don't agree.
2. I propose the following solution:
In openupgrade_scripts
, the same way we have apriori.py
, we should have another domain_fields.py
. Then, the same way in pre-migration of base
we call the apriori.py
, we should call the domain_fields.py
in the code whenever we are calling rename_fields
. Here is an example (taken from project
in v15):
from odoo.addons.openupgrade_scripts.domain_fields import domain_fields
openupgrade.rename_fields(
env,
[
("project.task", "project_task", "dependency_task_ids", "depend_on_ids"),
("project.task", "project_task", "depending_task_ids", "dependent_ids"),
],
domain_fields=domain_fields
)
where domain_fields
is an optional parameter in rename_fields
.
3. Comparison
Pro: All previous pros.
Cons: No cons.
What do you all think of this?
Sorry @MiquelRForgeFlow, but I don't see why putting in openupgrade_scripts instead of openupgrade_framework solves the problem I mentioned. Specially the C point. Could you explain how the design you proposee will work in a case of an update between same release. (minor update) ?
Thanks ! |
The same way you say putting in
Easy-peasy. In these cases, you only have to modify the script by adding the parameter 🤷♂️: openupgrade.rename_fields(env, field_renames, domain_fields=domain_fields) Of course, you may argue that this implies to do a lot of PRs in order to adapt to this logic and than doing that it's too much work. And I would say, yes, it's work, but we can begin by doing it only in the important cases and not exhaustively. We do PRs near everyday and having to do a limited bit more shouldn't discourage us. Clearly it's not a retroactive feature, so any |
Hi @MiquelRForgeFlow. sorry if I misspoke. I don't think the solution I'm proposing (openupgradelib) has only advantages. You're right, there are points where it's less good. 1) Is it the good place ?
2) Easy to Contribute
3) Circular dependency
4) Works retroactively
5) Easy to develop
6) Deployment changes on minor update (inside the same Odoo release)
7) Deployment changes on major update (between 2 major odoo releases)
|
@legalsylvain the chosen solution is the best minimizing the cons and favoring the contribution, as everything is contained in one file. The circular dependency you mention is relative, as this will work if the import can't be done, so we need to unblock this. You are not proposing a viable solution, nor contributing code to it. We have spent a lot of hours designing this for all to benefit from it. Let's merge this as a first solution for a non solved problem, and if there can be future improvements (on our part trying this or on any other contributor part), let's accept it. |
Hi @pedrobaeza.
could you elaborate ? I propose to have a file in openupgradelib, and you propose to change a file in openupgrade project. That's the same complexity.
could you elaborate ?
As soon as we are agree with the design, i can make a PR against OCA/openupgradelib#319 I'm open to discuss, but I didn't received any counter argument for a month and a half, and now you ask to merge this PR. I don't get it. If my proposal is not clear, we can do an online meeting. Kind regards. |
I think that such solution is worst than the current one:
About your points:
So seeing pros and cons, I still go with the current solution. |
Hi @pedrobaeza. Thanks for your answer. |
this one is same with |
I don't get your question, Nguyễn |
I mean that |
Yes, it can be another improvement, but it's out of scope of this one. |
OK thanks |
Add a list of domain fields that will be used by openupgradelib to update domain fields when renaming fields. OCA/openupgradelib#319
This list must be maintained manually since there seems to be no way to know when a Char field is used to store a domain and when it is not. This list should also be adapted and included in other versions.