[FIX] account: frequent tax undeterministic result
- Create a db with account installed (and a random loca) - Run the test "test_quick_edit_total_amount" => The test may fail (undeterministically), especially the first time The reason is that we don't have an order in "_get_frequent_account_and_taxes" So, if we have the same number of lines with the same account and with a tax or without one, we can not guarantee which tax is considered the most frequent. We now define the order by saying that we should take the taxes into account, so lines with taxes take precedence on lines without Linked to runbot error 23385 closes odoo/odoo#130326 X-original-commit: bdb21983371fb62b01275471e8ca7099219e1053 Signed-off-by: Brice Bartoletti (bib) <bib@odoo.com>
This commit is contained in:
@@ -2793,7 +2793,7 @@ class AccountMove(models.Model):
|
||||
SELECT account_move_line__account_id.id AS account_id,
|
||||
account_move_line__account_id.code,
|
||||
account_move_line.id,
|
||||
ARRAY_AGG(tax_rel.account_tax_id) AS taxes
|
||||
ARRAY_AGG(tax_rel.account_tax_id) FILTER (WHERE tax_rel.account_tax_id IS NOT NULL) AS taxes
|
||||
FROM {from_clause}
|
||||
LEFT JOIN account_move_line_account_tax_rel tax_rel ON account_move_line.id = tax_rel.account_move_line_id
|
||||
WHERE {where_clause}
|
||||
@@ -2801,7 +2801,7 @@ class AccountMove(models.Model):
|
||||
account_move_line.id
|
||||
) AS foo
|
||||
GROUP BY foo.account_id, foo.code, foo.taxes
|
||||
ORDER BY COUNT(foo.id) DESC, foo.code
|
||||
ORDER BY COUNT(foo.id) DESC, foo.code, taxes ASC NULLS LAST
|
||||
LIMIT 1
|
||||
""", params)
|
||||
return self._cr.fetchone() or (0, False, False)
|
||||
|
||||
Reference in New Issue
Block a user