Hello,
I have an environment with multiple databases.
For 1 of those databases I ran into some error and tried to replicated on a new clean database.
Using the shell:./odoo-bin shell -d EMPTYtest -c ../odoo.conf
I ran the following code:
Result on new database doesn't make a join to account.journal
>>> import odoo
>>> from odoo.osv import expression
>>> rec = self.env['account.move.line'].browse()
>>> e = expression.expression([], rec)
>>> e = expression.expression([('display_type', 'not in', ('line_section', 'line_note')),('move_id.state', '!=', 'cancel'),('company_id', '=', 1),('date', '<=', '2021-12-31'),('date', '>=', '2021-01-01'),('partner_id', 'in', [14]),('move_id.state', '=', 'posted'),'!','&','&','&',('credit', '=', 0.0),('debit', '=', 0.0),('amount_currency', '!=', 0.0),('journal_id.id', 'in', [4]),('account_id.internal_type', 'in', ['receivable', 'payable'])], rec)
µ>>> e = expression.expression([('display_type', 'not in', ('line_section', 'line_note')),('move_id.state', '!=', 'cancel'),('company_id', '=', 1),('date', '<=', '2021-12-31'),('date', '>=', '2021-01-01'),('partner_id', 'in', [14]),('move_id.state', '=', 'posted'),'!','&','&','&',('credit', '=', 0.0),('debit', '=', 0.0),('amount_currency', '!=', 0.0),('journal_id.id', 'in', [4]),('account_id.internal_type', 'in', ['receivable', 'payable'])], rec)
>>> e.get_tables()
['"account_move" as "account_move_line__move_id"', '"account_move_line"']
>>> e = expression.expression([('display_type', 'not in', ('line_section', 'line_note')),('move_id.state', '!=', 'cancel'),('company_id', 'in', [1]),('date', '<=', '2021-12-31'),('date', '>=', '2021-01-01'),('partner_id', 'in', [5327]),('move_id.state', '=', 'posted'),'!','&','&','&',('credit', '=', 0.0),('debit', '=', 0.0),('amount_currency', '!=', 0.0),('journal_id.id', 'in', [4]),('account_id.internal_type', 'in', ['receivable', 'payable'])], rec)
>>> e.get_tables()
['"account_move" as "account_move_line__move_id"', '"account_move_line"']
Result of the database where i had the issue (an extra join is made to account.journal)
e = expression.expression([('display_type', 'not in', ('line_section', 'line_note')),('move_id.state', '!=', 'cancel'),('company_id', 'in', [1]),('date', '<=', '2021-12-31'),('date', '>=', '2021-01-01'),('partner_id', 'in', [5327]),('move_id.state', '=', 'posted'),'!','&','&','&',('credit', '=', 0.0),('debit', '=', 0.0),('amount_currency', '!=', 0.0),('journal_id.id', 'in', [4]),('account_id.internal_type', 'in', ['receivable', 'payable'])],rec)
>>> e.get_tables()
['"account_move" as "account_move_line__move_id"', '"account_journal" as "account_move_line__journal_id"', '"account_move_line"']
>>> e = expression.expression([('display_type', 'not in', ('line_section', 'line_note')),('move_id.state', '!=', 'cancel'),('company_id', '=', 1),('date', '<=', '2021-12-31'),('date', '>=', '2021-01-01'),('partner_id', 'in', [14]),('move_id.state', '=', 'posted'),'!','&','&','&',('credit', '=', 0.0),('debit', '=', 0.0),('amount_currency', '!=', 0.0),('journal_id.id', 'in', [4]),('account_id.internal_type', 'in', ['receivable', 'payable'])],rec)
>>> e.get_tables()
['"account_move" as "account_move_line__move_id"', '"account_journal" as "account_move_line__journal_id"', '"account_move_line"']
How can it that running some basic odoo code results in a different outcome depending on the database?
Environment: Odoo 13: enterprise (pull from github 13/07/2021)
Question related to pull request:
https://github.com/odoo/enterprise/pull/19585