2017-03-08 57 views
0

我繼承了res.partner模式是這樣的:展場 - Odoo V9社區

class Partner(models.Model): 
    _inherit = 'res.partner' 

    type = fields.Selection(selection_add=[(('mina', 'Mina'))]) 
    origen = fields.Char(string="Origen") 
    destino = fields.Char(string="Destino") 

我添加了一個新的類型,稱爲「米娜」

這種新的聯繫方式,應該只顯示這兩個字段,origendestino

Tje新的單選按鈕顯示在窗體上,沒關係,但我無法弄清楚如何僅顯示這兩個字段,它只是顯示另一個type的聯繫人字段,這是我的看法:

 <record id="view_partner_form_1" model="ir.ui.view"> 
     <field name="name">res.partner.form</field> 
     <field name="model">res.partner</field> 
     <field name='inherit_id' ref='base.view_partner_form'/> 
     <field name="arch" type="xml"> 
      <xpath expr="//form//sheet//group//notebook" position="after"> 
       <form string="Minas"> 
           <sheet> 
            <field name="type" required="1" widget="radio" options="{'horizontal': true}"/> 
            <hr/> 
            <group> 
             <group attrs="{'invisible': [('type','=', 'mina')]}"> 
             </group> 
             <group> 
              <field name="origen" string="Origen" attrs="{'required' : [('type', '=', 'mina')]}"/> 
              <field name="destino" string="Destino" attrs="{'required' : [('type', '=', 'mina')]}"/> 
             </group> 
            </group> 
           </sheet> 
          </form> 
         </xpath> 
       </field> 
     </record> 

對此的任何想法?

在此先感謝

回答

1

位置after意味着你追加更多要素來看,如果要修改現有的領域,利用職務之attributes代替。你可以使用下面的代碼隱藏其他字段:

<xpath expr="//field[@name='field_name']" position="attributes"> 
    <attribute name="attrs">{'invisible': [...]}</attribute> 
</xpath> 
+0

太棒了!謝謝 – NeoVe

相關問題