Browse Source
[IMP][8.0][web_dashboard_tile] Refactor (see changes in description) (#476)
pull/495/head
[IMP][8.0][web_dashboard_tile] Refactor (see changes in description) (#476)
pull/495/head
Iván Todorovich
8 years ago
committed by
Pedro M. Baeza
11 changed files with 360 additions and 130 deletions
-
29web_dashboard_tile/README.rst
-
2web_dashboard_tile/__openerp__.py
-
4web_dashboard_tile/demo/tile_tile.yml
-
13web_dashboard_tile/migrations/8.0.3.0/post-migration.py
-
233web_dashboard_tile/models/tile_tile.py
-
11web_dashboard_tile/security/rules.xml
-
41web_dashboard_tile/static/src/css/tile.css
-
BINweb_dashboard_tile/static/src/img/screenshot_dashboard.png
-
6web_dashboard_tile/tests/__init__.py
-
52web_dashboard_tile/tests/test_tile.py
-
85web_dashboard_tile/views/tile.xml
@ -0,0 +1,13 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
# © 2016 Iván Todorovich <ivan.todorovich@gmail.com> |
||||
|
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html |
||||
|
|
||||
|
|
||||
|
def migrate(cr, version): |
||||
|
if version is None: |
||||
|
return |
||||
|
|
||||
|
# Rename old fields |
||||
|
cr.execute("""UPDATE tile_tile SET primary_function = 'count'""") |
||||
|
cr.execute("""UPDATE tile_tile SET secondary_function = field_function""") |
||||
|
cr.execute("""UPDATE tile_tile SET secondary_field_id = field_id""") |
Before Width: 796 | Height: 162 | Size: 45 KiB After Width: 771 | Height: 155 | Size: 20 KiB |
@ -0,0 +1,6 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
# © 2016 Antonio Espinosa - <antonio.espinosa@tecnativa.com> |
||||
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
||||
|
# flake8: noqa |
||||
|
|
||||
|
from . import test_tile |
@ -0,0 +1,52 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
# © 2016 Antonio Espinosa - <antonio.espinosa@tecnativa.com> |
||||
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
||||
|
|
||||
|
from openerp.tests.common import TransactionCase |
||||
|
|
||||
|
|
||||
|
class TestTile(TransactionCase): |
||||
|
def test_tile(self): |
||||
|
tile_obj = self.env['tile.tile'] |
||||
|
model_id = self.env['ir.model'].search([ |
||||
|
('model', '=', 'tile.tile')]) |
||||
|
field_id = self.env['ir.model.fields'].search([ |
||||
|
('model_id', '=', model_id.id), |
||||
|
('name', '=', 'sequence')]) |
||||
|
self.tile1 = tile_obj.create({ |
||||
|
'name': 'Count / Sum', |
||||
|
'sequence': 1, |
||||
|
'model_id': model_id.id, |
||||
|
'domain': "[('model_id', '=', %d)]" % model_id.id, |
||||
|
'secondary_function': 'sum', |
||||
|
'secondary_field_id': field_id.id}) |
||||
|
self.tile2 = tile_obj.create({ |
||||
|
'name': 'Min / Max', |
||||
|
'sequence': 2, |
||||
|
'model_id': model_id.id, |
||||
|
'domain': "[('model_id', '=', %d)]" % model_id.id, |
||||
|
'primary_function': 'min', |
||||
|
'primary_field_id': field_id.id, |
||||
|
'secondary_function': 'max', |
||||
|
'secondary_field_id': field_id.id}) |
||||
|
self.tile3 = tile_obj.create({ |
||||
|
'name': 'Avg / Median', |
||||
|
'sequence': 3, |
||||
|
'model_id': model_id.id, |
||||
|
'domain': "[('model_id', '=', %d)]" % model_id.id, |
||||
|
'primary_function': 'avg', |
||||
|
'primary_field_id': field_id.id, |
||||
|
'secondary_function': 'median', |
||||
|
'secondary_field_id': field_id.id}) |
||||
|
# count |
||||
|
self.assertEqual(self.tile1.primary_value, '3') |
||||
|
# sum |
||||
|
self.assertEqual(self.tile1.secondary_value, '6') |
||||
|
# min |
||||
|
self.assertEqual(self.tile2.primary_value, '1') |
||||
|
# max |
||||
|
self.assertEqual(self.tile2.secondary_value, '3') |
||||
|
# average |
||||
|
self.assertEqual(self.tile3.primary_value, '2') |
||||
|
# median |
||||
|
self.assertEqual(self.tile3.secondary_value, '2.0') |
Write
Preview
Loading…
Cancel
Save
Reference in new issue