2012-11-20 3 views
0

다른 트리 테이블 안에 트리 테이블이 있습니다. 편집 할 때 중첩 테이블이 셀 내부에 올바르게 표시됩니다. 그러나 값을 볼 때 셀에 쉼표로 구분 된 ID 만 있습니다 (중첩 테이블 대신). 보기 모드에서 셀에 표나 최소한 형식이 지정된 값을 표시하려면 어떻게합니까?트리에서 one2many 값 표시

중첩 테이블 :

<record id="view_mrp_repair_line_item_tree" model="ir.ui.view"> 
    <field name="name">mrp.repair.line.item.tree</field> 
    <field name="model">mrp.repair.line.item</field> 
    <field name="type">tree</field> 
    <field name="arch" type="xml"> 
     <tree string="Repair line items" editable="bottom"> 
      <field name="description" /> 
      <field name="price" /> 
     </tree> 
    </field> 
</record> 

부모 테이블 : 중첩 된 테이블에서

<field colspan="4" mode="tree" name="operations" nolabel="1" widget="one2many_list"> 
    <tree string="Operations" editable="bottom"> 
     ... 
     <field name="items" context="{'default_repair_line_id':active_id}" widget="one2many_list" /> 
    </tree> 
</field> 

모델 :

class mrp_repair_line_item(osv.osv): 
    _name = 'mrp.repair.line.item' 

    _columns = { 
     'repair_line_id': fields.many2one('mrp.repair.line', 'Repair Line', required=True), 
     'description': fields.char('Description', required=False, size=160), 
     'price': fields.float('Price', required=False) 
    } 

mrp_repair_line_item() 

답변

1

당신은 하나의 문자열을 반환하는 기능 필드를 만들 수 있습니다 나타내는 값을 입력하고 해당 필드를 대신 표시하십시오. 예 : [description1: Price1], [description2: Price2], ...

+0

감사합니다. ('editable = "bottom"') 편집을 사용한다는 것을 잊어 버렸습니다 (코드 샘플에서 명백합니다). 따라서 내가 잘못 본 것이 아니라면 편집 모드와보기 모드에 대해 서로 다른 두 가지보기를 정의 할 수 없습니다. 나에게 말한대로 기능 필드를 만들면 편집 모드와보기 모드 모두에서 표시되며 편집 할 수 없습니다. 내가 맞습니까? 표 대신 표제가 표시되는 것이 정상입니까? – ziri

+0

문자열을 구문 분석하고 one2many 객체를 수정하여 함수 필드에 대한 쓰기 작업을 구현하는 함수'fnct_inv'를 정의 할 수 있습니다. 그렇게하면 필드를 편집 할 수 있습니다. 편집 및 파싱을 단순화하기 위해 사전 형식의 형식을 사용할 수 있습니다 :'description1 : Price1, description2 : Price2, ...' –