Skip to content

Fix define_settings method - #49

Open
guewen wants to merge 1 commit into
camptocamp:masterfrom
guewen:fix-define-settings
Open

Fix define_settings method#49
guewen wants to merge 1 commit into
camptocamp:masterfrom
guewen:fix-define-settings

Conversation

@guewen

@guewen guewen commented Jan 14, 2020

Copy link
Copy Markdown

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
Comment thread anthem/lyrics/settings.py
# 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
Copy Markdown
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
Copy Markdown
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