Skip to content

Commit

Permalink
Merge pull request #4418 from grap/16.0-FIX-point_of_sale-fast-popula…
Browse files Browse the repository at this point in the history
…te-access-token

[16.0][OU-FIX] point_of_sale: improve pre-migration execution, replacing n SQL requests n=len(pos_orders) by 1 SQL request
  • Loading branch information
pedrobaeza authored Apr 29, 2024
2 parents 0ba2932 + 0de2e0e commit b222441
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 b222441

Please sign in to comment.