Как читать переменную Qweb в javascript (Odoo11)

У меня такой код:

 <t groups="website_sale.group_website_multi_image">
  <t t-set="variant_img" t-value="any(product.mapped('product_variant_ids.image_variant'))"/>
  <t t-set="image_ids" t-value="product.product_image_ids"/>
  <div id="o-carousel-product" class="carousel slide" data-ride="carousel" data-interval="0">
    <div class="carousel-outer">
      <div class="carousel-inner">
        <div t-if="variant_img" class="item active" itemprop="image" t-field="product.product_variant_id.image" t-options="{'widget': 'image', 'class': 'product_detail_img js_variant_img', 'alt-field': 'name', 'zoom': 'image', 'unique': product['__last_update'] + (product.product_variant_id['__last_update'] or '')}"/>
    <ol class="carousel-indicators" t-if="len(image_ids) or variant_img">
      <li data-target="#o-carousel-product" t-att-data-slide-to="1 if variant_img else 0" t-att-class="'' if variant_img else 'active'">
        <img class="img img-responsive" t-attf-src="/website/image/product.template/{{product.id}}/image/90x90" t-att-alt="product.name"/>
      </li>
      <t t-if="len(image_ids)" t-foreach="image_ids" t-as="pimg">
        <li data-target="#o-carousel-product" t-att-data-slide-to="pimg_index + (variant_img and 2 or 1)">
          <img class="img img-responsive" t-attf-src="/website/image/product.image/{{pimg.id}}/image/90x90" t-att-alt="pimg.name"/>
        </li>
      </t>
    </ol>
  </div>
</t>
<script language="javascript" type="text/javascript">

    <MY SCRIPT>

</script>

внутри тега 'script' мне нужно прочитать одну из переменных qweb, мне нужен {{product.id}}, чтобы загрузить динамический путь в javascript.

Вариантов перепробовала много:

var WRProdId ="{{product.id}}";

также:

<input type="hidden" id="Current360Product" name="Current360Product" value="{{product.id }}"/> 

<script language="javascript" type="text/javascript"> 
var WRProdId = document.getElementById("Current360Product").value;

но {{product.id}} никогда не интерпретируется

Как я могу это прочитать?


person Filippo Scifo    schedule 06.06.2018    source источник
comment
Что ты пробовал?   -  person ADreNaLiNe-DJ    schedule 07.06.2018
comment
Вариантов перепробовал много: var WRProdId = {{product.id}}; также ‹тип ввода = скрытый идентификатор = Current360Product name = Current360Product value = {{product.id}} /› ‹язык сценария = javascript type = text / javascript› var WRProdId = document.getElementById (Current360Product) .value; но {{product.id}} никогда не интерпретируется   -  person Filippo Scifo    schedule 07.06.2018
comment
Пожалуйста, добавьте это к своему вопросу, отредактировав его;)   -  person ADreNaLiNe-DJ    schedule 07.06.2018


Ответы (2)


Решение такое:

var WRProdId = <t t-esc="product.id"/>;
person Filippo Scifo    schedule 07.06.2018

Решение такое:

var WRProdId = "<t t-esc="product.id"/>";
person Amin Hosseinzade Fardnia    schedule 27.08.2019