[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.
This commit is contained in:
Denis Ledoux 2014-10-23 14:12:39 +02:00
parent 562272d9a0
commit 8521e701fa
1 changed files with 7 additions and 3 deletions

View File

@ -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