summaryrefslogtreecommitdiff
path: root/addons/web_editor/controllers/main.py
diff options
context:
space:
mode:
authorRomain Derie <rde@odoo.com>2018-08-16 17:57:53 +0200
committerJeremy Kersten <jke@odoo.com>2018-08-31 16:37:45 +0200
commit47b00c5d533d8ab5e5f259a1e6b62b44343b49f4 (patch)
tree89ad0f1c8bc3965694e1c2c2c78b615c4f16c854 /addons/web_editor/controllers/main.py
parent9b1d1d57286c044129cfb7a004c5e6c1ae345077 (diff)
[FIX] base,website,web_editor: handle key field on ir.ui.view for multi website
With multi-websites, we expect qweb views to have a key set as it is the key that is used to find duplicates (two views with same keys are duplicate, the one with a website_id set is more specific than the one without a website_id) Thus, 5ff87e803967 sort on key in order to find the most suitable one. It would crash if a qweb view is created without a key (False) as it can't sort `bool` and `str`. This commit: - Adds a generated key to scss views - Adds an SQL constraint to avoid QWeb views without a `key` - Generates a random key when creating a QWeb view without a `key` - Handle False key in `filter_duplicate()` by extracting views with False key before sorting, and then adding these views to the recordset Note: We also want the key to be editable as it is now an important field with multiwebsite. Thus, we removed the readonly on this field. + fix python tests as we now force key on qweb views with sql constraint + pep8
Diffstat (limited to 'addons/web_editor/controllers/main.py')
-rw-r--r--addons/web_editor/controllers/main.py2
1 files changed, 2 insertions, 0 deletions
diff --git a/addons/web_editor/controllers/main.py b/addons/web_editor/controllers/main.py
index 7dbc3415f21..02d46a7d7bd 100644
--- a/addons/web_editor/controllers/main.py
+++ b/addons/web_editor/controllers/main.py
@@ -7,6 +7,7 @@ import logging
import os
import re
import time
+import uuid
import werkzeug.wrappers
from PIL import Image, ImageFont, ImageDraw
from lxml import etree, html
@@ -412,6 +413,7 @@ class Web_Editor(http.Controller):
view_to_xpath = IrUiView.get_related_views(bundle_xmlid, bundles=True).filtered(lambda v: v.arch.find(url) >= 0)
IrUiView.create(dict(
name = custom_url,
+ key='web_editor.scss_%s' % str(uuid.uuid4())[:6],
mode = "extension",
inherit_id = view_to_xpath.id,
arch = """