Skip to content
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

[FIX] models: do no allow voiding a required fields #164712

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

william-andre
Copy link
Contributor

Display a nice error instead of a SQL error
It could make sense in some cases to be able to void a field in order to recompute the the default value, but that should only happen in onchange

@robodoo
Copy link
Contributor

robodoo commented May 7, 2024

Pull request status dashboard.

@C3POdoo C3POdoo requested review from a team, rco-odoo and HydrionBurst and removed request for a team May 7, 2024 11:20
@@ -310,23 +310,6 @@ def test_mail_mail_send_exceptions_origin(self):
self.assertEqual(notification.failure_type, 'mail_from_missing')
self.assertEqual(notification.notification_status, 'exception')

# MailServer.send_email(): _prepare_email_message: unexpected ASCII / Malformed 'Return-Path' or 'From' address
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't remove it, the purpose is to check malformed email_from, it should still be tested.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What would the expected behavior be?
Right now, it will fail on self.mail_alias_domain.bounce_alias = False
But: before, if you did a self.env.flush_all(), it would go 💥
The test is not realistic, it only works mid-transaction, so not when receiving emails.

Copy link
Contributor

Choose a reason for hiding this comment

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

The purpose is not to test bounce_alias = False, it is to test malformed email_from. I think the alias reset was just a trick during the test, don't have much time to dive into it but maybe you can try simply removing alias domains completely, should not try to use them.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Got it: I fixed it by forcing the bounce to be the same value as email_from (using with_context(domain_bounce_address=email_from))

@Feyensv
Copy link
Contributor

Feyensv commented May 7, 2024

As it seems to be only a nice to have improvement, why do you target stable ?
Considering all the changes you have to do on the side, it doesn't seem like it's a safe change for stable 🤔

Copy link
Member

@rco-odoo rco-odoo left a comment

Choose a reason for hiding this comment

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

Changing exception types is changing the API, so this is clearly not acceptable on a stable branch. The proof being that you broke existing tests.

That being said, the error message is indeed much more informative about what's wrong with the values. Moreover, without this change, the error is triggered when the update is flushed, instead of when the value is assigned, which makes debugging more complex.

I suggest to:

  • make a branch for master;
  • add some specific tests on the feature itself;
  • cover the case of create(), write() and stored field assignment (in compute).

@C3POdoo C3POdoo added the RD research & development, internal work label May 7, 2024
@william-andre william-andre force-pushed the 17.0-require-required-fields-wan branch from e9831df to cc82929 Compare May 7, 2024 12:44
@william-andre william-andre changed the base branch from 17.0 to master May 7, 2024 12:44
@william-andre william-andre force-pushed the 17.0-require-required-fields-wan branch 4 times, most recently from 41a6f2e to d2217ba Compare May 7, 2024 16:30
Display a nice error instead of a SQL error
It could make sense in some cases to be able to void a field in order to
recompute the the default value, but that should only happen in
`onchange`
@william-andre william-andre force-pushed the 17.0-require-required-fields-wan branch from d2217ba to 3a12711 Compare May 7, 2024 16:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
RD research & development, internal work
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants