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] account: ensure non empty VALUES in query #162043

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

Commits on Apr 16, 2024

  1. [FIX] account: ensure non empty VALUES in query

    When the companies of system user are all archived we get an invalid SQL
    syntax on the output of `_from`. For normal users having their
    company_id archived is not a standard flow, but system user (Odoo Bot)
    is an archived user, thus it can be associated to an archived company
    (usually the id=1 one).
    
    The invalid query is necessary during the installation of some modules.
    This operation runs as system user.
    
    Steps reproduce:
    1. On a clean DB with just account installed, add an extra company.
    2. Archive company 1 (after switching admin/demo/portal to comp2)
    3. Set allowed companies of system user to just company 1
    4. Try to install gamification_sale_crm
    
    The validation of the domain in for gamification records fail due to the
    invalid query.
    
    Compare:
    ```
    >>> self.env['res.currency']._get_query_currency_table(self.env.companies.ids, fields.Date.today())
    '(VALUES ) AS currency_table(company_id, rate, precision)'
    >>> self.env['res.currency']._get_query_currency_table((self.env.companies | self.env.company).ids, fields.Date.today())
    '(VALUES (1, 1.0, 2)) AS currency_table(company_id, rate, precision)'
    ```
    
    Setting:
    ```
    >>> self.env.user
    res.users(1,)
    >>> self.env.company
    res.company(1,)
    >>> self.env.company.active
    False
    >>> self.env.user.with_context(active_test=False).company_ids
    res.company(1,)
    ```
    aj-fuentes committed Apr 16, 2024
    Configuration menu
    Copy the full SHA
    e362b72 View commit details
    Browse the repository at this point in the history