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 define_settings method #49

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

Conversation

guewen
Copy link
Contributor

@guewen guewen commented Jan 14, 2020

In 13.0, the method ResConfigSettings.execute() [0] reset odoo env after
installing/uninstalling addons, after this, computed fields misbehave
(for instance, after a record creation, they would return an empty value
or a CacheMiss)

In 13.0, we can call set_values() which does what we want, before this
version, we have to keep calling execute() (which doesn't have the
mentioned issue) because it sets the default values and the groups.

[0] https://github.com/odoo/odoo/blob/054d4bc6bc219bcc6b0a64265e8d7e9c7423dbc8/odoo/addons/base/models/res_config.py#L633-L637

In 13.0, the method ResConfigSettings.execute() [0] reset odoo env after
installing/uninstalling addons, after this, computed fields misbehave
(for instance, after a record creation, they would return an empty value
or a CacheMiss)

In 13.0, we can call set_values() which does what we want, before this
version, we have to keep calling execute() (which doesn't have the
mentioned issue) because it sets the default values and the groups.

[0] https://github.com/odoo/odoo/blob/054d4bc6bc219bcc6b0a64265e8d7e9c7423dbc8/odoo/addons/base/models/res_config.py#L633-L637
# In 13.0, execute calls set_values(), then takes care of
# install/uninstall. execute() resets the env which breaks
# computed fields afterwards, so do not call it.
model.create(values).set_values()
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure if some projects don't rely on it to install modules 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

They shouldn't ;)
And for < 13.0, the behavior doesn't change, so not too much risk I guess. Anyway, it's broken in 13.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants