From 2105eacc3e38ca4dcf37fff6ff4b10cdb90c84e8 Mon Sep 17 00:00:00 2001 From: Lionel Sausin Date: Thu, 26 Nov 2015 16:21:20 +0100 Subject: [PATCH] Explain intent of pending_quants and simplify loop condition As suggested by @oihane --- stock_quant_merge/models/stock.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/stock_quant_merge/models/stock.py b/stock_quant_merge/models/stock.py index 27bcaa71b..5c506abb8 100644 --- a/stock_quant_merge/models/stock.py +++ b/stock_quant_merge/models/stock.py @@ -24,10 +24,10 @@ class StockQuant(models.Model): @api.multi def merge_stock_quants(self): - pending_quants = self.filtered(lambda x: True) - for quant2merge in self: - if (quant2merge in pending_quants and - not quant2merge.reservation_id): + # Get a copy of the recorset + pending_quants = self.browse(self.ids) + for quant2merge in self.filtered(lambda x: not x.reservation_id): + if quant2merge in pending_quants: quants = self.search(self._mergeable_domain()) cont = 1 cost = quant2merge.cost