2011-10-06 53 views
3

我有一個小問題。我目前工作的一個模塊要求我插入一組字段和一個樹形視圖,當數據輸入到表單中時,這些視圖會更新。立即在openerp one2many列表中使用表單和樹視圖

<field name="lines" widget="one2many_list" colspan="4" nolabel="1"> 
    <tree> 
     <field name="product_id"/> 
     <field name="product_qty"/>         
    </tree> 
    <form> 
     <field name="product_id"/> 
     <field name="product_qty"/> 
    </form> 
</field> 

以上是從我的觀點片段,是有可能導致上述和樹視圖的形式查看在在同一個頁面。

對於實例

==============

表單域

樹視圖

這樣無需點擊新記錄圖標我可以將記錄添加到樹視圖並從上面顯示的表單中保存它們。

請指教。

謝謝!

回答

3

我想你是問有沒有辦法在樹視圖中添加或編輯記錄,而不必爲每條記錄彈出一個窗口。

某些視圖具有可以在適當位置編輯的樹視圖。我能想到的一個例子是產品屏幕上的供應商價目表。另一個是在會計部分通過移動編碼的條目。如果你看看源代碼,你可能會弄清楚它們是如何做到的。

+1

前往addons-> product-> product_view。xml,然後在'product_supplierinfo_form_view'窗體視圖中有供應商價目表的樹視圖,在該樹視圖中可以找到'editable =「bottom」'。 –

1

這只是一個想法,但也許這個設計可以解決你的問題。 如果你有很多的「產品線」的「命令」對象:

  1. 上使用PARENT_ID
  2. 的「產品線」創建窗體「產品線」鏈接到自己創建一個many2many場帶有product_id和product_qty的對象
  3. 基於many2many字段添加到表單樹列表。

這會做詭計嗎?

4

在樹形視圖中有一個屬性叫做'editable'。您可以使用編輯=「頂」或可編輯=「底部」

<field name="lines" widget="one2many_list" colspan="4" nolabel="1"> 
    <tree editable='bottom'> 
     <field name="product_id"/> 
     <field name="product_qty"/>         
    </tree> 
    <form> 
     <field name="product_id"/> 
     <field name="product_qty"/> 
    </form> 
</field> 
1

首先,你將創建類似父窗體域的域one2many:

 class parent_temp(osv.osv) 
      _name='parent.temp' 
      _columns={ 
       'name' : fields.char('Parent Note',size=32), 
       'temp_ids' : fields.one2many('temp.check', 'temp_id','temp note'), 
        } 

     class temp_check(osv.osv) 
      _name='temp.check 
      _columns={ 
        'name':fields.char('temp',size=32), 
        'temp_id':fields.many2one('parent.temp','temp note'), 
        } 

好吧,這是PY聲明,現在我們將創建更新樹的二維視圖:

 #form view 
     <form string="Temp Notes"> 
      <field name='name'/> #parent field 
      <field colspan="4" name="temp_ids" nolabel="1"> 
        <tree string="Notes" editable="top"> 
         """ 
          write field here which u want to show in tree view 
          """ 
          <field name='name'/> #child field 
        </tree> 
     </field> 
     </form> 

     #here editable option top or bottom 
+0

我有相同的體系結構,除了我的第一個類繼承另一個類....代碼不適用於我。你能幫忙嗎? – dirtyhandsphp

1

您可以根據您的需求使用此結構。

<field name='selected_tea_workers_line_ids' nolabel='1'> 
<tree string='List' readonly='1'> 
<field name='tea_line_worker_id' invisible="0" /> 
<field name='worker_id' /> 
<field name='is_selected' /> 
</tree> 
</field> 

但是任何人都知道如何爲該子字段設置值的編碼。