openerp one2many问题与视图

时间:2014-01-27 05:24:56

标签: view openerp

我正在尝试创建一个存储合作伙伴的多个地址的模块。我的问题是视图部分,只有城市字段在其他字段不可见的形式中可见,点击“添加项目”时,地址字段按照随后的顺序排列,如首先是邮政编码,然后是街道等。

请建议如何进行以便所有字段都可见?

class extendcustomersaddress(orm.Model): 
  _name="res.partner" 
  _inherit = 'res.partner'
  _columns = 
   {
    'extraaddress':fields.one2many('seq.address','x_client_id','Address')
   }

 extendcustomersaddress()

class related_address(orm.Model): 
   _name="seq.address" 
   _columns = 
   { 
   'x_street' : fields.char('Street', size=170 ),
   'x_street1' : fields.char('Street1', size=170), 
   'x_city' : fields.char('City', size=170), 
   'x_state' : fields.char('state', size=170), 
   'x_zip' : fields.char('Zip code', size=10),
   'x_country' : fields.many2one('res.country', 'Country'), 
   'x_client_id': fields.many2one('res.partner', 'id',invisible=True) 
   }

related_address()

<openerp> 
   <data> 
     <record model="ir.ui.view" id="namelist_dailyupdate">
       <field name="name">res.partner.form</field> <field name="model">res.partner</field>

       <field name="inherit_id" ref="base.view_partner_form" />
       <field name="type">form</field>
      <field name="arch" type="xml">
      <notebook position="inside">
         <page string="Email">
            <separator string="Additional Emails" colspan="4"/>
             <tree name="abcd" editable="Bottom">
               <field name="extraaddress" />
             </tree>

         </page>
       </notebook>

     </field> 
   </record>

   </data> 
</openerp>

2 个答案:

答案 0 :(得分:2)

试试这个,

<openerp> 
   <data> 
     <record model="ir.ui.view" id="namelist_dailyupdate">
     <field name="name">res.partner.form</field> <field name="model">res.partner</field>

     <field name="inherit_id" ref="base.view_partner_form" />
     <field name="type">form</field>
     <field name="arch" type="xml">
     <notebook position="inside">
     <page string="Email">
        <separator string="Additional Emails" colspan="4"/>
           <field name="extraaddress">
               <tree string="Extra Addresses" editable="bottom">
                   <field name="x_street"/>
                   <field name="x_street1"/>
                   <field name="x_city"/>
                   <field name="x_zip"/>
                   <field name="x_state"/>
                   <field name="x_country"/>
               </tree>
           </field>
         </page>
       </notebook>
     </field> 
   </record>
   </data> 
</openerp>

答案 1 :(得分:0)

您必须为模型seq.address创建视图,您可以在res.partner视图或单独视图(treeform

例如,请参阅销售订单中的sale_view.xml