Skip to content

Commit

Permalink
[OU-FIX] point_of_sale: improve pre-migration execution, replacing n …
Browse files Browse the repository at this point in the history
…SQL requests n=len(pos_orders) by 1 SQL request
  • Loading branch information
legalsylvain committed Apr 26, 2024
1 parent 0ba2932 commit 0de2e0e
Showing 1 changed file with 3 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# SPDX-FileCopyrightText: 2024 Tecnativa - Pedro M. Baeza
# SPDX-License-Identifier: AGPL-3.0-or-later
import uuid

from openupgradelib import openupgrade

Expand All @@ -10,12 +9,9 @@ def _assign_pos_order_token(env):
env,
[("access_token", "pos.order", "pos_order", "char", False, "point_of_sale")],
)
env.cr.execute("SELECT id FROM pos_order")
for row in env.cr.fetchall():
env.cr.execute(
"UPDATE pos_order SET access_token = %s WHERE id = %s",
(str(uuid.uuid4()), row[0]),
)
openupgrade.logged_query(
env.cr, "UPDATE pos_order SET access_token = gen_random_uuid();"
)


@openupgrade.migrate()
Expand Down

0 comments on commit 0de2e0e

Please sign in to comment.