From 8521e701fae4ebe3ae35ef714cbfe916a215bd36 Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Thu, 23 Oct 2014 14:12:39 +0200 Subject: [PATCH] [FIX] website_sale: right number of products in the page The goal is to fill the page with at least 20 products and to fill all grid lines Thus, the page should be filled with products until there are 20 products and all lines of the grid are full. --- addons/website_sale/controllers/main.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/addons/website_sale/controllers/main.py b/addons/website_sale/controllers/main.py index 060370b..df3ab9b 100644 --- a/addons/website_sale/controllers/main.py +++ b/addons/website_sale/controllers/main.py @@ -37,14 +37,18 @@ class table_compute(object): for p in products: x = min(max(p.website_size_x, 1), PPR) y = min(max(p.website_size_y, 1), PPR) - if index>PPG: + if index>=PPG: x = y = 1 pos = minpos while not self._check_place(pos%PPR, pos/PPR, x, y): pos += 1 - - if index>PPG and (pos/PPR)>maxy: + # if 21st products (index 20) and the last line is full (PPR products in it), break + # (pos + 1.0) / PPR is the line where the product would be inserted + # maxy is the number of existing lines + # + 1.0 is because pos begins at 0, thus pos 20 is actually the 21st block + # and to force python to not round the division operation + if index >= PPG and ((pos + 1.0) / PPR) > maxy: break if x==1 and y==1: # simple heuristic for CPU optimization -- 1.7.10.4