summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXavier Morel <xmo@odoo.com>2017-05-15 16:37:07 +0200
committerOlivier Dony <odo@openerp.com>2017-08-19 02:34:22 +0200
commit25df2352f51e8622c1d709695b4784379747653d (patch)
treee8a4bac23aed3935b7c1f48254d397f25a8c1002
parenta4ada695e17871b27ece6baabe9abe639cf6d93f (diff)
[FIX] P3: / has become 'real division' in all cases
-rw-r--r--addons/website_event_track/views/event_track_templates.xml2
-rw-r--r--addons/website_forum/controllers/main.py5
-rw-r--r--addons/website_sale/controllers/main.py14
-rw-r--r--odoo/addons/base/tests/test_api.py2
-rw-r--r--odoo/tools/image.py11
5 files changed, 16 insertions, 18 deletions
diff --git a/addons/website_event_track/views/event_track_templates.xml b/addons/website_event_track/views/event_track_templates.xml
index c8282180215..14eee014c6f 100644
--- a/addons/website_event_track/views/event_track_templates.xml
+++ b/addons/website_event_track/views/event_track_templates.xml
@@ -15,7 +15,7 @@
<h2 class="text-center mb32">Our Sponsors</h2>
</section>
<div class="row">
- <div t-attf-class="col-md-#{(len(event.sponsor_ids) > 6) and 2 or (12/ len(event.sponsor_ids))} text-center mb16 oe_sponsor" t-foreach="event.sponsor_ids" t-as="sponsor">
+ <div t-attf-class="col-md-#{(len(event.sponsor_ids) > 6) and 2 or (12 // len(event.sponsor_ids))} text-center mb16 oe_sponsor" t-foreach="event.sponsor_ids" t-as="sponsor">
<t t-if="sponsor.url">
<a t-att-href="sponsor.url" style="position: relative; display: inline-block;">
<span t-field="sponsor.image_medium"
diff --git a/addons/website_forum/controllers/main.py b/addons/website_forum/controllers/main.py
index acb3ff377fe..703cf517374 100644
--- a/addons/website_forum/controllers/main.py
+++ b/addons/website_forum/controllers/main.py
@@ -1,6 +1,5 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
-
import base64
import json
import lxml
@@ -547,9 +546,9 @@ class WebsiteForum(http.Controller):
pager = request.website.pager(url="/forum/%s/users" % slug(forum), total=tag_count, page=page, step=step, scope=30)
user_obj = User.sudo().search([('karma', '>', 1), ('website_published', '=', True)], limit=step, offset=pager['offset'], order='karma DESC')
# put the users in block of 3 to display them as a table
- users = [[] for i in range(len(user_obj) / 3 + 1)]
+ users = [[] for i in range(len(user_obj) // 3 + 1)]
for index, user in enumerate(user_obj):
- users[index / 3].append(user)
+ users[index // 3].append(user)
searches['users'] = 'True'
values = self._prepare_forum_values(forum=forum, searches=searches)
diff --git a/addons/website_sale/controllers/main.py b/addons/website_sale/controllers/main.py
index 8f02d4a0117..51462df1de7 100644
--- a/addons/website_sale/controllers/main.py
+++ b/addons/website_sale/controllers/main.py
@@ -53,28 +53,28 @@ class TableCompute(object):
x = y = 1
pos = minpos
- while not self._check_place(pos % PPR, pos / PPR, x, y):
+ while not self._check_place(pos % PPR, pos // PPR, x, y):
pos += 1
# 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:
+ if index >= ppg and ((pos + 1.0) // PPR) > maxy:
break
if x == 1 and y == 1: # simple heuristic for CPU optimization
- minpos = pos / PPR
+ minpos = pos // PPR
for y2 in range(y):
for x2 in range(x):
- self.table[(pos / PPR) + y2][(pos % PPR) + x2] = False
- self.table[pos / PPR][pos % PPR] = {
+ self.table[(pos // PPR) + y2][(pos % PPR) + x2] = False
+ self.table[pos // PPR][pos % PPR] = {
'product': p, 'x': x, 'y': y,
'class': " ".join(x.html_class for x in p.website_style_ids if x.html_class)
}
if index <= ppg:
- maxy = max(maxy, y + (pos / PPR))
+ maxy = max(maxy, y + (pos // PPR))
index += 1
# Format table according to HTML needs
@@ -910,7 +910,7 @@ class WebsiteSale(http.Controller):
@http.route(['/shop/get_unit_price'], type='json', auth="public", methods=['POST'], website=True)
def get_unit_price(self, product_ids, add_qty, **kw):
products = request.env['product.product'].with_context({'quantity': add_qty}).browse(product_ids)
- return {product.id: product.website_price / add_qty for product in products}
+ return {product.id: product.website_price // add_qty for product in products}
# ------------------------------------------------------
# Edit
diff --git a/odoo/addons/base/tests/test_api.py b/odoo/addons/base/tests/test_api.py
index 55cf1ff26b5..ad2dd1f0e85 100644
--- a/odoo/addons/base/tests/test_api.py
+++ b/odoo/addons/base/tests/test_api.py
@@ -482,7 +482,7 @@ class TestAPI(common.TransactionCase):
ps = self.env['res.partner'].search([])
# sort by model order
- qs = ps[:len(ps) / 2] + ps[len(ps) / 2:]
+ qs = ps[:len(ps) // 2] + ps[len(ps) // 2:]
self.assertEqual(qs.sorted().ids, ps.ids)
# sort by name, with a function or a field name
diff --git a/odoo/tools/image.py b/odoo/tools/image.py
index d6dd1488aba..791d1a978d3 100644
--- a/odoo/tools/image.py
+++ b/odoo/tools/image.py
@@ -1,6 +1,5 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
-
try:
import cStringIO as StringIO
except ImportError:
@@ -102,7 +101,7 @@ def image_resize_and_sharpen(image, size, preserve_aspect_ratio=False, factor=2.
resized_image = sharpener.enhance(factor)
# create a transparent image for background and paste the image on it
image = Image.new('RGBA', size, (255, 255, 255, 0))
- image.paste(resized_image, ((size[0] - resized_image.size[0]) / 2, (size[1] - resized_image.size[1]) / 2))
+ image.paste(resized_image, ((size[0] - resized_image.size[0]) // 2, (size[1] - resized_image.size[1]) // 2))
if image.mode != origin_mode:
image = image.convert(origin_mode)
return image
@@ -181,17 +180,17 @@ def crop_image(data, type='top', ratio=False, thumbnail_ratio=None, image_format
if ratio:
w_ratio, h_ratio = ratio
- new_h = (w * h_ratio) / w_ratio
+ new_h = (w * h_ratio) // w_ratio
new_w = w
if new_h > h:
new_h = h
- new_w = (h * w_ratio) / h_ratio
+ new_w = (h * w_ratio) // h_ratio
if type == "top":
cropped_image = image_stream.crop((0, 0, new_w, new_h))
cropped_image.save(output_stream, format=image_format)
elif type == "center":
- cropped_image = image_stream.crop(((w - new_w) / 2, (h - new_h) / 2, (w + new_w) / 2, (h + new_h) / 2))
+ cropped_image = image_stream.crop(((w - new_w) // 2, (h - new_h) // 2, (w + new_w) // 2, (h + new_h) // 2))
cropped_image.save(output_stream, format=image_format)
elif type == "bottom":
cropped_image = image_stream.crop((0, h - new_h, new_w, h))
@@ -201,7 +200,7 @@ def crop_image(data, type='top', ratio=False, thumbnail_ratio=None, image_format
# TDE FIXME: should not have a ratio, makes no sense -> should have maximum width (std: 64; 256 px)
if thumbnail_ratio:
thumb_image = Image.open(StringIO.StringIO(output_stream.getvalue()))
- thumb_image.thumbnail((new_w / thumbnail_ratio, new_h / thumbnail_ratio), Image.ANTIALIAS)
+ thumb_image.thumbnail((new_w // thumbnail_ratio, new_h // thumbnail_ratio), Image.ANTIALIAS)
thumb_image.save(output_stream, image_format)
return output_stream.getvalue().encode('base64')