diff options
| author | Victor Feyens <vfe@odoo.com> | 2020-09-02 08:57:39 +0000 |
|---|---|---|
| committer | Victor Feyens <vfe@odoo.com> | 2020-09-03 08:40:37 +0000 |
| commit | 710705b64c0134a5b568d998d0a3eb0df0f541c0 (patch) | |
| tree | aaa976bd813ef4119cb556239f97489efeb3a39c /addons/website | |
| parent | 310fb4b7c5e2a6205b59de76356f14c3d562cee9 (diff) | |
[IMP] base,website*: do not store country flags.
1) Avoid the storage of all country flags as ir_attachment (230+
ir_attachment in a new db) to reduce the filestore of databases.
The country flags are nearly static and not expected to be modified on
Odoo instances.
This change is based on the new "image_url" widget logic (see previous commits).
2) Extend the flag coverage for countries
Add the missing country flags & specify a mapping to provide flags
for overseas administrated countries/territories.
Diffstat (limited to 'addons/website')
| -rw-r--r-- | addons/website/models/website_visitor.py | 2 | ||||
| -rw-r--r-- | addons/website/tests/test_performance.py | 2 | ||||
| -rw-r--r-- | addons/website/views/website_visitor_views.xml | 18 |
3 files changed, 12 insertions, 10 deletions
diff --git a/addons/website/models/website_visitor.py b/addons/website/models/website_visitor.py index ca54d20d883..b4eccd5264e 100644 --- a/addons/website/models/website_visitor.py +++ b/addons/website/models/website_visitor.py @@ -38,7 +38,7 @@ class WebsiteVisitor(models.Model): # localisation and info country_id = fields.Many2one('res.country', 'Country', readonly=True) - country_flag = fields.Binary(related="country_id.image", string="Country Flag") + country_flag = fields.Char(related="country_id.image_url", string="Country Flag") lang_id = fields.Many2one('res.lang', string='Language', help="Language from the website when visitor has been created") timezone = fields.Selection(_tz_get, string='Timezone') email = fields.Char(string='Email', compute='_compute_email_phone') diff --git a/addons/website/tests/test_performance.py b/addons/website/tests/test_performance.py index 466167b436f..48763dc75b9 100644 --- a/addons/website/tests/test_performance.py +++ b/addons/website/tests/test_performance.py @@ -33,8 +33,6 @@ class UtilPerf(HttpCase): class TestStandardPerformance(UtilPerf): def test_10_perf_sql_img_controller(self): self.authenticate('demo', 'demo') - url = '/web/image/res.country/4/image' - self.assertEqual(self._get_url_hot_query(url), 4) url = '/web/image/res.users/2/image_256' self.assertEqual(self._get_url_hot_query(url), 8) diff --git a/addons/website/views/website_visitor_views.xml b/addons/website/views/website_visitor_views.xml index 9ec67f4503f..6a07151fd66 100644 --- a/addons/website/views/website_visitor_views.xml +++ b/addons/website/views/website_visitor_views.xml @@ -82,6 +82,7 @@ <kanban class="o_wvisitor_kanban" sample="1"> <field name="id"/> <field name="country_id"/> + <field name="country_flag"/> <field name="email"/> <field name="is_connected"/> <field name="display_name"/> @@ -109,10 +110,10 @@ <span class="fa fa-circle text-success" t-if="record.is_connected.raw_value" aria-label="Online" title="Online"/> <span class="fa fa-circle text-danger" t-else="" aria-label="Offline" title="Offline"/> </div> - <div> - <img t-if="record.country_id.raw_value" - t-att-src="kanban_image('res.country', 'image', record.country_id.raw_value)" - class="o_country_flag" alt="Country"/> + <!-- Double check is necessary for sample view (or error image are shown) --> + <div t-if="record.country_id.raw_value and record.country_flag.raw_value"> + <img t-att-src="record.country_flag.raw_value" + class="o_country_flag" alt="Country"/> </div> </div> </div> @@ -147,7 +148,8 @@ </div> <strong> <img t-if="record.country_id.raw_value" - t-att-src="kanban_image('res.country', 'image', record.country_id.raw_value)" class="o_country_flag" alt="Country"/> + t-att-src="record.country_flag.raw_value" + class="o_country_flag" alt="Country"/> <field name="display_name"/> </strong> <div class="mb-2">Active <field name="time_since_last_action"/></div> @@ -196,7 +198,9 @@ <field name="visitor_page_count" widget="statinfo" string="Page views"/> </button> </div> - <div class="float-right" attrs="{'invisible': [('country_id', '=', False)]}"><field name="country_flag" widget="image" options='{"size": [32, 32]}'/></div> + <div class="float-right" attrs="{'invisible': [('country_id', '=', False)]}"> + <field name="country_flag" widget="image_url" options='{"size": [32, 32]}'/> + </div> <div class="oe_title"> <h1><field name="display_name"/></h1> </div> @@ -227,7 +231,7 @@ <field name="arch" type="xml"> <tree string="Web Visitors" decoration-success="is_connected" decoration-danger="not is_connected" sample="1"> <!--TODO DBE : Handle no_label in treeview--> - <field name="country_flag" widget="image" options='{"size": [20, 20]}' string=" "/> + <field name="country_flag" widget="image_url" options='{"size": [20, 20]}' string=" "/> <field name="display_name"/> <field name="create_date"/> <field name="last_connection_datetime"/> |
