Skip to content

Conversation

@StefanRijnhart
Copy link
Member

@StefanRijnhart StefanRijnhart commented Oct 5, 2022

Odoo 14 introduced the widescale usage of computed fields with readonly=False. In that case, the compute method functions as a record specfic default method that can also be used to compute a value some time after the initial creation of the record.

In the OpenUpgrade analysis files, these fields would be misrepresented as computed fields rather than fields with a default function. This change fixes that. See OCA/OpenUpgrade#3587 for the result.

image

@StefanRijnhart StefanRijnhart added this to the 15.0 milestone Oct 5, 2022
@OCA-git-bot
Copy link
Contributor

Hi @legalsylvain,
some modules you are maintaining are being modified, check this out!

@pedrobaeza
Copy link
Member

pedrobaeza commented Oct 6, 2022

For new fields,I think it's interesting to know that they are compute / stored (like a default). For existing fields, not sure if being put if any change of a field may trigger a recomputation of this field.

@StefanRijnhart
Copy link
Member Author

@pedrobaeza that implies you'd want to see the depends in the OpenUpgrade analysis. Are there examples where that is actually relevant when developing migration scripts?

@pedrobaeza
Copy link
Member

Not really. It's like the default. When a new field is present, and it has a default, we put in the analysis file that it has default. You go to the definition to see which default is and if it serves. The same can apply to the computed writable: it can put: has compute, and if you want to see which value it will take (or want to disable as very heavy), you see the code and decide, but not having this information will make an immediate "Nothing to do", where it's not.

@StefanRijnhart
Copy link
Member Author

StefanRijnhart commented Oct 10, 2022

@pedrobaeza not sure I understand, but let's recap.

Before this PR, it is reported for a new, required field if it has a default attribute and whether that is a literal or a function. This is key req_default in the analysis.

It is also reported if a field that did not have a default has a default in the new version or the other way around (as per OCA/OpenUpgrade@4e60a82, discussion in OCA/OpenUpgrade#1204 ). This is key default in the analysis.

What this PR changes, is that for a new, required field that has a compute method, it will show the name of that compute method in the analysis.

I think the discussion in #1204 was not very clear. I don't think it's very interesting if anything changes wrt. the default or compute method of an existing read/write field.

Instead, I do think it is interesting to see for new, non-required field the same information about any kind of default. So my proposal would be extend this PR to

Is this in line with what you had in mind?

-- edit -- actually, the default for required fields was already reported for existing and new fields, so we'll keep it that way.
-- edit 2 -- no it wasn't and we'll keep it that way.

@StefanRijnhart StefanRijnhart force-pushed the fix/15.0/openupgrade_analysis/compute_readwrite branch 4 times, most recently from 8186713 to c35b563 Compare October 11, 2022 13:53
StefanRijnhart added a commit to StefanRijnhart/OpenUpgrade that referenced this pull request Oct 11, 2022
…ted fields

Odoo 14 introduced the widescale usage of computed fields with readonly=False.
In that case, the compute method functions as a default that can also be used
to compute a value some time *after* the initial creation of the record.

In the OpenUpgrade analysis files, these fields would be misrepresented as
computed fields rather than fields with a default function. This change fixes
that.
@StefanRijnhart
Copy link
Member Author

@pedrobaeza my refactoring is done. The 'default' key is now merged into the 'hasdefault' key and it can have two values: default or compute. That is to say that for new fields, it is shown if there is a default method or a compute method. Note that static values (e.g. default=True) are wrapped in a lambda function by the Odoo framework and cannot be distinguished from default methods anymore.

The information is not shown for deleted fields anymore as I think this is useless noise, and as for changes with existing fields in the previous version, this was not shown and it is still not shown as I still think this information is only useful for new fields.

I've already included this change in the initialization of 16.0 (OCA/OpenUpgrade#3583), but you can inspect the change in the analysis more easily in the 15.0 analysis update here: OCA/OpenUpgrade#3587.

Let me know if we are on the same line.

Copy link
Contributor

@MiquelRForgeFlow MiquelRForgeFlow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it retro-compatible with previous versions, right?

@pedrobaeza
Copy link
Member

Checked the result on OU:

/ocabot merge major

@OCA-git-bot
Copy link
Contributor

On my way to merge this fine PR!
Prepared branch 15.0-ocabot-merge-pr-2416-by-pedrobaeza-bump-major, awaiting test results.

OCA-git-bot added a commit that referenced this pull request Oct 19, 2022
Signed-off-by pedrobaeza
@OCA-git-bot
Copy link
Contributor

@pedrobaeza your merge command was aborted due to failed check(s), which you can inspect on this commit of 15.0-ocabot-merge-pr-2416-by-pedrobaeza-bump-major.

After fixing the problem, you can re-issue a merge command. Please refrain from merging manually as it will most probably make the target branch red.

@pedrobaeza
Copy link
Member

It seems there's a problem with letsencrypt module due to a new LE policy:

 acme.messages.Error: urn:ietf:params:acme:error:rejectedIdentifier :: The server will not issue certificates for the identifier :: Error creating new order :: Cannot issue for "*.example.com": The ACME server refuses to issue a certificate for this domain name, because it is forbidden by policy

@NL66278 you are the migrator to this version. Can you please check? Maybe we should disable tests for now?

@NL66278
Copy link
Contributor

NL66278 commented Oct 19, 2022

@pedrobaeza I did a mostly technical migration, not being really an expert on the intricacies of letsencrypt. As far as I can see it is the acme client complaining about a generic domain that the certificates in the request are requested for. I have some hesitancy just disabling the tests... Although that would maybe be the most easy option.

@pedrobaeza
Copy link
Member

Let's try again to see if it's a transient question:

/ocabot merge major

@OCA-git-bot
Copy link
Contributor

This PR looks fantastic, let's merge it!
Prepared branch 15.0-ocabot-merge-pr-2416-by-pedrobaeza-bump-major, awaiting test results.

OCA-git-bot added a commit that referenced this pull request Oct 19, 2022
Signed-off-by pedrobaeza
@OCA-git-bot
Copy link
Contributor

@pedrobaeza your merge command was aborted due to failed check(s), which you can inspect on this commit of 15.0-ocabot-merge-pr-2416-by-pedrobaeza-bump-major.

After fixing the problem, you can re-issue a merge command. Please refrain from merging manually as it will most probably make the target branch red.

@MiquelRForgeFlow
Copy link
Contributor

Maybe the acme library version has to be restricted 🤔

@StefanRijnhart
Copy link
Member Author

@MiquelRForgeFlow it is not entirely backwards compatible, in the sense that we need one more backport: #2431

@StefanRijnhart
Copy link
Member Author

This fixes the letsencrypt tests, for now: #2432

@pedrobaeza
Copy link
Member

/ocabot merge major

@OCA-git-bot
Copy link
Contributor

Hey, thanks for contributing! Proceeding to merge this for you.
Prepared branch 15.0-ocabot-merge-pr-2416-by-pedrobaeza-bump-major, awaiting test results.

@OCA-git-bot OCA-git-bot merged commit e6b665d into OCA:15.0 Oct 19, 2022
@OCA-git-bot
Copy link
Contributor

Congratulations, your PR was merged at 0cad19c. Thanks a lot for contributing to OCA. ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants