[REM] base: removing slow partner cycle search dead code
Description:
Since 54857ec409 , the results of the
expensive recursive CTE on `res.partner` were never used. So the query
doesn't do anything at all, besides slowing down the whole process
for minutes on databases with a large volume of `res.partner` entries.
Fix:
Removing the dead code
Reference:
task-3601394
closes odoo/odoo#142914
X-original-commit: 29223533f625d579e424bdc133d0cfc472946b6b
Signed-off-by: Rémy Voet (ryv) <ryv@odoo.com>
Signed-off-by: Piryns Victor (pivi) <pivi@odoo.com>
This commit is contained in:
@@ -154,22 +154,6 @@ class MergePartnerAutomatic(models.TransientModel):
|
||||
with mute_logger('odoo.sql_db'), self._cr.savepoint():
|
||||
query = 'UPDATE "%(table)s" SET "%(column)s" = %%s WHERE "%(column)s" IN %%s' % query_dic
|
||||
self._cr.execute(query, (dst_partner.id, tuple(src_partners.ids),))
|
||||
|
||||
# handle the recursivity with parent relation
|
||||
if column == Partner._parent_name and table == 'res_partner':
|
||||
query = """
|
||||
WITH RECURSIVE cycle(id, parent_id) AS (
|
||||
SELECT id, parent_id FROM res_partner
|
||||
UNION
|
||||
SELECT cycle.id, res_partner.parent_id
|
||||
FROM res_partner, cycle
|
||||
WHERE res_partner.id = cycle.parent_id AND
|
||||
cycle.id != cycle.parent_id
|
||||
)
|
||||
SELECT id FROM cycle WHERE id = parent_id AND id = %s
|
||||
"""
|
||||
self._cr.execute(query, (dst_partner.id,))
|
||||
# NOTE JEM : shouldn't we fetch the data ?
|
||||
except psycopg2.Error:
|
||||
# updating fails, most likely due to a violated unique constraint
|
||||
# keeping record with nonexistent partner_id is useless, better delete it
|
||||
|
||||
Reference in New Issue
Block a user