2015-10-13 72 views
1

我在Odoo中設置網站樣式的選定屬性有點麻煩。odoo如何設置網站模板中的選定屬性

我有一些基礎模型中的數據,它顯示在窗體中的表格中。行顯示正確,但選擇字段的值未正確設置。它始終顯示選擇列表中的第一個值,而不是模型中保存的值。

<t t-foreach="quote_lines" t-as="quote_line">    
    <tr> 
     <td> 
      <!-- public categories for a selection field --> 
      <select t-attf-name="supplier_{{quote_line.line}}"> 
      <t t-foreach="categories" t-as="c"> 
       <t t-if="c.name==quote_line.supplier"><option t-field="c.name" selected="selected" /></t> 
       <t t-if="c.name!=quote_line.supplier"><option t-field="c.name" /></t> 
      </t> 
      </select> 
     </td> 
     .... 
    </tr> 
    </t> 

表單被加載到odoo中並顯示正常 - 除了-tag忽略了我選擇的屬性。當我查看生成的html時,select/option值被設置,只是這個屬性被忽略。

任何提示我做錯了或只是看不到?

回答

2

嘗試使用selected="True"

而且,看看website_sale如何做的國家:

   <div t-attf-class="form-group #{error.get('shipping_country_id') and 'has-error' or ''} col-lg-6"> 
        <label class="control-label" for="shipping_country_id">Country</label> 
        <select name="shipping_country_id" class="form-control" t-att-disabled=" 'disabled' if shipping_id &gt;= 0 else ''"> 
         <option value="">Country...</option> 
         <t t-foreach="countries or []" t-as="country"> 
          <option t-att-value="country.id" t-att-selected="country.id == checkout.get('shipping_country_id')"><t t-esc="country.name"/></option> 
         </t> 
        </select> 
       </div> 

https://github.com/odoo/odoo/blob/9.0/addons/website_sale/views/templates.xml#L1072-L1080

+0

THX ...我檢查了一下,改變了線路: \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t <選項叔ATT值= 「c.name」 T-ATT-選擇=「C .name == quote_line.supplier「> \t 現在就像一種魅力.... – Helmut

相關問題