2016-12-02 66 views
1

我建立一個模塊,具有many2one場加場到many2one(被插入到CRM模塊),但是當我點擊添加一個新的價值,我創建的字段沒有顯示:如何通過模塊

module.py

class tipo_facturacion(models.Model): 
    _name = "tipo_facturacion" 
    name = fields.Char(string="Tipo Facturación", size=50, required=True) 
    otro = fields.Char("Esto", required=True) 

class cant_neg_crm(models.Model): 
     _inherit = "crm.lead" 
     _columns = { 
     'modo_facturacion': fields.many2one('tipo_facturacion' ,'Tipo Facturacion'), 
    } 

謝謝Y:What it happens

我在文件中寫了這個ou非常提前爲您提供幫助!

親切的問候,

回答

0

對不起。現在的工作,但其顯示的,而不是字符值:

enter image description here

謝謝!

+0

如果filed'd模型(many2one字段的模型)包含名稱字段,則它會在其中顯示名稱字段,否則將採用**型號名稱id **。如果名稱字段不存在,則可以通過在模型中設置此屬性來設置_rec_name ='other_field_name'',您將在many2one中看到該字段的值。 –

+0

非常感謝!有效! –

1

您需要定義一個字段視圖以及由視圖繼承,你可以做到這一點。

class tipo_facturacion(models.Model): 
    _name = "tipo_facturacion" 

    name = fields.Char(string="Tipo Facturación", size=50, required=True) 
    otro = fields.Char("Esto", required=True) 

class cant_neg_crm(models.Model): 
    _inherit = "crm.lead" 
    _columns = { 
     'modo_facturacion': fields.many2one('tipo_facturacion' ,'Tipo Facturacion'), 
    } 

現在使用繼承這個字段(Many2one)添加到現有的視圖。

(基本視圖ID => crm.crm_case_form_view_leads)它可能會有所不同。

<record id="new_view_id" model="ir.ui.view"> 
    <field name="name">crm.lead.form</field> 
    <field name="model">crm.lead</field> 
    <field name="inherit_id" ref="crm.crm_case_form_view_leads" /> 
    <field name="priority" eval="40"/> 
    <field name="arch" type="xml"> 
     <!-- field name which you specify here after then new field will be added. --> 
     <field name="existing_field_name" position="after"> 
      <field name="modo_facturacion" /> 
     </field> 
    </field> 
</record> 

同樣可以在列表視圖中添加場也是如此。條件是隻有 ,你必須在__init__.py和xml文件中加入這個py文件在 __openerp__.py文件中並重新啓動服務器和升級/安裝模塊。

+0

非常感謝!我會試試看看它是如何工作的! –

+0

不幸的是,這不起作用。當打開many2one字段時,它會顯示其他字段...比如EAN13和其他許多與創建的其他字段無關的字段。 謝謝你的幫助! –