Problem using svg content in QWeb Template

Bug #1240593 reported by Carlos Vásquez (ClearCorp)
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Odoo Web (MOVED TO GITHUB)
New
Undecided
Unassigned

Bug Description

I'm creating a new OpenERP web module that displays various svg on it. I really don't no if this is a precise problem from the QWeb engine or from the OpenERP web framework itself.

The problem is that the svg content in a QWeb template isn't deplayed. This is the xml code that I'm using in the template :

<templates>
    <t t-name="scada_web.main_svg">
        <svg xmlns="http://www.w3.org/2000/svg" version="1.1">
            <circle cx="100" cy="50" r="40" stroke="black" stroke-width="2" fill="red" />
        </svg>
    </t>
</templates>

This simple doesn't work. The svg is not deplayed when i call the template from widget. This is kind of weird because if we see the source code of the web framework, the svg is correctly in the code.

 The only way that works with QWeb is If I call the svg in a object, embed or image tag, like this:

<templates>
    <t t-name="test_web.circle_svg">
        <object id="circle" data="/test_web/static/src/svg/circle.svg" type="image/svg+xml"></object>
    </t>
</templates>

At the end, I was able to display the svg but without using the QWeb, this was made by appending the raw code of svg in the "this.$el" variable of the wiget instance but it could be much better to make this with QWeb.

Revision history for this message
Carlos Vásquez (ClearCorp) (cv.clearcorp) wrote :

This problem affects version 7.0

Revision history for this message
dkrush (d-krushinsky) wrote :

I have the same issue.

I did some examination and it appears that OpenERP 'decorates' the svg-related tags.
For example, this fragment in the template:

<svg width='300px' height='600px' viewBox='0 -1.5 5 3' preserveAspectRatio='xMidYMid meet' xmlns='http://www.w3.org/2000/svg' version='1.1' xmlns:xlink='http://www.w3.org/1999/xlink'>
 <path fill='none' stroke='blue' stroke-width='0.1' d='M0 0 l1 1 1,-2 1,2 1,-2 1,2'/>
</svg>

appears in browser like this:

<ns0:svg xmlns:ns0="http://www.w3.org/2000/svg" height="600px" preserveaspectratio="xMidYMid meet" version="1.1" viewbox="0 -1.5 5 3" width="300px">
 <ns0:path d="M0 0 l1 1 1,-2 1,2 1,-2 1,2" fill="none" stroke="blue" stroke-width="0.1"></ns0:path>
</ns0:svg>

Any idea why this 'ns0' pops up?
If you edit the page after it's loaded in the browser - svg shows up.

Revision history for this message
dkrush (d-krushinsky) wrote :

without 'xmlns' and 'xmlns:xlink' attributes it seems to work

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.