Use SQL query to deactivate lot. #048200

This commit is contained in:
Albert Cervera i Areny 2021-11-18 18:50:04 +01:00
parent f1c8c9fabc
commit 3233a9617a

View file

@ -64,7 +64,13 @@ class Lot(DeactivableMixin, metaclass=PoolMeta):
lots = cls.search(domain)
logging.getLogger(cls.__name__).info("Deactivating %s lots", len(lots))
if lots:
cls.write(lots, {'active': False})
# Use SQL update as now the sled date may be required and we want
# to be able to deactivate anyway.
table = cls.__table__()
query = table.update([table.active], [False], where=table.id.in_([
x.id for x in lots]))
cursor = Transaction().connection.cursor()
cursor.execute(*query)
class Move(metaclass=PoolMeta):