Search code examples
pythonpython-2.7odooodoo-8

Accounting settings cannot be changed in Odoo 8


I need to modify an option of the accounting configuration (menu Accounting > Configuration > Accounting).

As you know, those options belong to a Transient Model named account.config.settings, which inherits from res.config.settings.

The problem is that even if I modify no option and click on Apply, Odoo begins loading forever. I put the log in debug_sql mode, and I realised that after clicking on Apply, Odoo starts to make thousands of SQL queries, and that is the reason why it does not stop loading.

I made a database backup and restored it in a newer instance of Odoo 8. In this instance, when I click on Apply, Odoo makes several SQL queries but not so much as in the other instance, so it works perfectly.

My conclusion was that the problem could be in the instance code (not in the database), so I looked for all the modules inheriting from account.config.settings and updated their repositories to go back to the same commits as the wrong instance (with git checkout xxx).

Afterwards I was expecting the newer instance to start failing when clicking on Apply, but it remains working OK.

So I am running out of ideas. I am thinking about running the backup database in the newer instance just to change the option I need, and after that restoring it again in the older instance, but I prefer to avoid that since I think it is a bit risky.

Any ideas? What more can I try to find out the problem?


Solution

  • Finally I found out the guilty module. It was account_due_list from the repository account-payment of the Odoo Community Association. The commit which fixes the problem is https://github.com/OCA/account-payment/commit/d7a09399982c80bb0f9465c44b9dc2a2b17e557a#diff-57131fd364915a56cbf8696d74e19478, merged on September the 22nd in 2016. Its title, "check if currency id not changed per company, remove it from create values".

    The computed field maturity_residual depended on company_id.currency_id. This dependency has to be removed due to be the cause of the whole problem. It triggered thousands of SQL queries which made Odoo be loading forever.

    Old and wrong code

    @api.depends('date_maturity', 'debit', 'credit', 'reconcile_id',
                 'reconcile_partial_id', 'account_id.reconcile',
                 'amount_currency', 'reconcile_partial_id.line_partial_ids',
                 'currency_id', 'company_id.currency_id')
                 'currency_id')
    def _maturity_residual(self):
       ...
    

    New and right code

    @api.depends('date_maturity', 'debit', 'credit', 'reconcile_id',
                 'reconcile_partial_id', 'account_id.reconcile',
                 'amount_currency', 'reconcile_partial_id.line_partial_ids',
                 'currency_id')
    def _maturity_residual(self):
       ...
    

    I found very risky to update repositories to the latest version due to what @CZoellner exactly says, sometimes there are weird commits which can destroy some database data. So, these are the consequences of not doing that.