-
Notifications
You must be signed in to change notification settings - Fork 24.8k
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] account: include user company in currency mapping #171605
Conversation
@@ -56,6 +56,8 @@ def _get_query_currency_table(self, company_ids, conversion_date): | |||
if companies == user_company: | |||
currency_rates = {user_company.currency_id.id: 1.0} | |||
else: | |||
if user_company not in companies: | |||
companies = companies | user_company |
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.
companies = companies | user_company | |
companies |= user_company |
When the current user is the system user, which happens during install and upgrades, the env company is possibly not included with the companies given to _get_query_currency_table, this can lead to a KeyError when fetching the rate for said company.
8a95269
to
a20e712
Compare
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.
If this is called during upgrade, doesn't it mean that it is for something stored in the database, and therefore should not depend on the user's context's company, but on the company of the records being updated?
Not really, the instances when it was called during upgrade is when the record rules were updated and those are not company dependent. That's why it also happens during the installation of a module. To be more specific, the failure happens when the |
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.
Thanks for the explanation
@robodoo r+
When the current user is the system user, which happens during install and upgrades, the env company is possibly not included with the companies given to _get_query_currency_table, this can lead to a KeyError when fetching the rate for said company. closes odoo#171605 Signed-off-by: William André (wan) <wan@odoo.com>
When the current user is the system user, which happens during install and upgrades, the env company is possibly not included with the companies given to _get_query_currency_table, this can lead to a KeyError when fetching the rate for said company. closes odoo#171605 Signed-off-by: William André (wan) <wan@odoo.com>
When the current user is the system user, which happens during install and upgrades, the env company is possibly not included with the companies given to _get_query_currency_table, this can lead to a KeyError when fetching the rate for said company. closes odoo#171605 Signed-off-by: William André (wan) <wan@odoo.com>
Description of the issue/feature this PR addresses:
When the current user is the system user, which happens during install and upgrades, the env company is possibly not included with the companies given to
_get_query_currency_table
, this can lead to a KeyError when fetching the rate for said company.Current behavior before PR:
Steps to reproduce:
_get_query_currency_table
)Same behavior on upgrade if purchase is already installed and the company linked to the system user is deactivated and has a different currency than the active companies.
Desired behavior after PR is merged:
I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr