Skip to content

Commit

Permalink
Merge PR #1500 into 16.0
Browse files Browse the repository at this point in the history
Signed-off-by simahawk
  • Loading branch information
shopinvader-git-bot committed Feb 13, 2024
2 parents 0e68206 + f56d281 commit 9ce393e
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions shopinvader_api_cart/routers/cart.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,20 +188,19 @@ def _apply_transactions(self, cart, transactions: list[CartTransaction]):
transactions=transactions
)
update_cmds = []
with self.env.norecompute():
# prefetch all products
self.env["product.product"].browse(transactions_by_product_id.keys())
# here we avoid that each on change on a line trigger all the
# recompute methods on the SO. These methods will be triggered
# by the orm into the 'write' process
for product_id, trxs in transactions_by_product_id.items():
line = cart._get_cart_line(product_id)
if line:
cmd = self._apply_transactions_on_existing_cart_line(line, trxs)
else:
cmd = self._apply_transactions_creating_new_cart_line(cart, trxs)
if cmd:
update_cmds.append(cmd)
# prefetch all products
self.env["product.product"].browse(transactions_by_product_id.keys())
# here we avoid that each on change on a line trigger all the
# recompute methods on the SO. These methods will be triggered
# by the orm into the 'write' process
for product_id, trxs in transactions_by_product_id.items():
line = cart._get_cart_line(product_id)
if line:
cmd = self._apply_transactions_on_existing_cart_line(line, trxs)
else:
cmd = self._apply_transactions_creating_new_cart_line(cart, trxs)
if cmd:
update_cmds.append(cmd)
all_transaction_uuids = transaction_uuids = [
str(t.uuid) for t in transactions if t.uuid
]
Expand Down

0 comments on commit 9ce393e

Please sign in to comment.