2015-06-19 49 views
0

這是工作的罰款many2one場,所以我想「AREA_ID」hindu_data_super類應該在many2many或請讓我知道我可以在一個區域中選擇多個項目......我有many2one領域的域名過濾代碼。如何爲許多人做?

class hindu_desh(osv.Model): 
    _name="hindu.desh" 
    _description="Define districts" 
    _columns={ 'name':fields.char('District Name',size=64,required=True) } 
hindu_desh() 



class hindu_state(osv.Model): 
    _name="hindu.state" 
    _description="Define sub districts" 
    _columns={ 'name':fields.char('Sub District Name',size=64,required=True), 'hindu_state_id': fields.many2one('hindu.desh','District Name',select=True,required=True,ondelete="restrict") } 
hindu_state() 


class hindu_dist(osv.Model): 
    _name="hindu.dist" 
    _description="Define areas" 
    _columns={ 'name':fields.char('Area Name',size=64,required=True), 
     #'area_type': fields.selection(area_type_lov,'Area Type',required=True), 
     'hindu_state_id':fields.many2one('hindu.state','Sub District Name',size=64,required=True), 
      'district_id':fields.related('hindu_state_id','hindu_state_id',readonly=True,type='many2one',relation='hindu.desh',string='District Name'), 
} 

hindu_dist() 



class hindu_data_super(osv.Model): 
    _name = "hindu.data.super" 
    _description = "Area of Registration Super" 
    _columns = { 
     'district_id' : fields.many2one('hindu.desh','District', select=True, required=True, ondelete="restrict"), 
     'hindu_state_id' : fields.many2one('hindu.state', 'Sub District', domain="[('hindu_state_id', '=', district_id)]", select=True, required=True), 
     'area_id' : fields.many2one('hindu.dist', 'Area', domain="[('hindu_state_id', '=', hindu_state_id)]", select=True, required=True), 
    } 
hindu_data_super() 
+0

你想在** hindu.data.super **而不是many2one的many2many領域?想要設置area_id many2many?你可以請添加更多的描述與你想做的事情。這樣有人可以給你更好的解決問題的建議。 –

+0

亞hindu.data.super我有area_id應該是many2many領域.becoz我想選擇多個項目。所以這個領域應該在很多領域。我努力了 。我得到了內疚的錯誤。如果你有助於獲得many2many域名過濾器選項,這將是偉大的 –

回答

0

我已經更改了字段結構,請檢查並嘗試它,並且hindu.data.super中的area_ids是fields.related,因此您將根據狀態選擇獲取所有區域,如果您需要更多,我認爲需要更多的工作。

class hindu_desh(osv.Model): 
    _name="hindu.desh" 
    _description="Define districts" 
    _columns={ 'name':fields.char('District Name',size=64,required=True) } 
hindu_desh() 


class hindu_state(osv.Model): 
    _name="hindu.state" 
    _description="Define sub districts" 
    _columns={ 
      'name':fields.char('Sub District Name',size=64,required=True), 
      'hindu_state_id': fields.many2one('hindu.desh','District Name',select=True,required=True,ondelete="restrict") } 
      'area_ids' : fields.one2many('hindu.dist','hindu_state_id','Areas') 
hindu_state() 


class hindu_dist(osv.Model): 
    _name="hindu.dist" 
    _description="Define areas" 
    _columns={ 
     'name':fields.char('Area Name',size=64,required=True), 
     'hindu_state_id':fields.many2one('hindu.state','Sub District Name',size=64,required=True), 
     'district_id':fields.related('hindu_state_id','hindu_state_id',readonly=True,type='many2one',relation='hindu.desh',string='District Name'), 
} 

hindu_dist() 



class hindu_data_super(osv.Model): 
    _name = "hindu.data.super" 
    _description = "Area of Registration Super" 
    _columns = { 
     'district_id' : fields.many2one('hindu.desh','District', select=True, required=True, ondelete="restrict"), 
     'hindu_state_id' : fields.many2one('hindu.state', 'Sub District', domain="[('hindu_state_id', '=', district_id)]", select=True, required=True), 
     'area_ids' : fields.related('hindu_state_id','hindu_state_id',readonly=True,type='one2many',relation='hindu.dist',string='Area',store=True), 
    } 
hindu_data_super() 
+0

我無法從area_id中選擇任何項目..它顯示的創建和編輯。 。我知道你是如何做到的area_ids [0] [2]和wt是super_id,hindu_dist_rel –

+0

我想我需要了解你的班級結構和你的目標,然後我會更新我的答案。 –

+0

請儘量讓我這一個...我非常需要這個爲我的acadamics項目 –