Before this commit, when adding a new grid item in a grid by using the "Add Elements" option, if the page was scrolled such that the top of the grid was not visible, this new grid item may not always be visible. This is annoying as the user could add an element and not see where it appeared and would therefore need to look for it. This commit fixes this by making the page scroll to the added grid item if more than half of it is not visible. A test is also added. Steps to reproduce: - Drop the "Text-Image" snippet and enough snippets under it to have a scrollbar. - Toggle the "Text-Image" snippet to grid mode. - Scroll the page so the top of the grid is not visible. - Add a new "Button" with the "Add Elements" option. => The button is not visible. task-3616138 closes odoo/odoo#161159 X-original-commit: 50766b74196b3cdc5ac83d7962873f4fffa4c9f6 Signed-off-by: Guillaume Dieleman (gdi) <gdi@odoo.com> Signed-off-by: Soukéina Bojabza (sobo) <sobo@odoo.com>
28 lines
1.0 KiB
Python
28 lines
1.0 KiB
Python
# -*- coding: utf-8 -*-
|
|
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
|
|
|
import base64
|
|
|
|
import odoo.tests
|
|
from odoo.tests.common import HOST
|
|
from odoo.tools import config
|
|
|
|
@odoo.tests.common.tagged('post_install', '-at_install')
|
|
class TestWebsiteGridLayout(odoo.tests.HttpCase):
|
|
|
|
def test_01_replace_grid_image(self):
|
|
IrAttachment = self.env['ir.attachment']
|
|
base = "http://%s:%s" % (HOST, config['http_port'])
|
|
req = self.opener.get(base + '/web/image/website.s_banner_default_image')
|
|
IrAttachment.create({
|
|
'public': True,
|
|
'name': 's_banner_default_image.jpg',
|
|
'type': 'binary',
|
|
'res_model': 'ir_ui_view',
|
|
'datas': base64.b64encode(req.content),
|
|
})
|
|
self.start_tour(self.env['website'].get_client_action_url('/'), 'website_replace_grid_image', login="admin")
|
|
|
|
def test_02_scroll_to_new_grid_item(self):
|
|
self.start_tour(self.env['website'].get_client_action_url('/'), 'scroll_to_new_grid_item', login='admin')
|