2012-11-17 124 views
2

我安裝OpenERP的6.1 http://apps.openerp.com/addon/2507?filter= {%22order_by%22%3A +%22click_counter +降序%22%2C +%22text_search%22%3A +%22product_brand%22} &頁的product_brand模塊= 0OpenERP的6.1把產品品牌銷售訂單

通過Web客戶端,我通過插入product_brand_id字段,通過調試(開發人員)模式繼承product.product.tree視圖,從而設法在產品列表頁中顯示產品品牌。

但是現在我想讓產品品牌名稱顯示在銷售訂單的sale.order.line.tree視圖中。 我注意到他們是不同的型號,一個是product.product,另一個是sale.order.line。 是否可以在OpenERP中顯示其他模型的字段? 可能是我的問題標題可以更改爲: 如何在相關(不同)模型中引用字段名稱?

回答

1

它可能使用相關領域。首先,你需要繼承沽盤模型,並添加相關領域的產品品牌標識 例如:

from osv import osv, fields 
class sale_order_line(osv.osv): 
    _inherit = 'sale.order.line' 
    _columns = { 
     'brand_id': fields.related('product_id','product_brand_id',string='Brand',type='many2one',relation='product.brand') 
    } 
sale_order_line() 

然後需要繼承銷售訂單視圖。銷售訂單行樹和表單視圖在銷售訂單視圖內指定。 SO使用xpath繼承銷售訂單表單視圖。例如:

<?xml version="1.0" encoding="utf-8"?> 
    <openerp> 
    <data> 
     <record model="ir.ui.view" id="view_order_inherited_brand"> 
     <field name="name">sale.order.brand</field> 
     <field name="type">form</field> 
     <field name="model">sale.order</field> 
     <field name="inherit_id" ref="sale.view_order_form" /> 
     <field name="arch" type="xml"> 
      <xpath expr="//field[@name='order_line']/tree/field[@name='name']" position="after"> 
       <field name='brand_id'/> 
      </xpath> 
     </field> 
     </record> 
    </data> 
</openerp>