2013-05-14 69 views
0

這裏是我的節日模特班。OpenERP 7 many2one與本月過濾器

class festival_registration(osv.osv): 
    _name = "bpl.festival" 
    _description = "Festivals" 
    _columns = { 
     'relegious_places_id': fields.many2one('bpl.relegious.places', 'Religious Places'), 
     'name': fields.char('Name', size=256, required=True, help='Festival Name'), 
     'fest_allowance': fields.float('Advance', size=64, required=True, help='Advance Amount'), 
     'installments': fields.integer('Installments', size=32, required=True, help='Number of Installments Installment'), 
     'month':fields.selection([('1', 'January'), ('2', 'February'), ('3', 'March'), ('4', 'April'), 
      ('5', 'May'), ('6', 'June'), ('7', 'July'), ('8', 'August'), ('9', 'September'), 
      ('10', 'October'), ('11', 'November'), ('12', 'December')], 'Month'), 

    } 
festival_registration() 

我需要讓節日在我的另一種形式給節日前進。然後我需要過濾的記錄和需要,只顯示與當月 節日如何添加域濾波這一要求或請諮詢我對這個問題的另一種技術

感謝

這裏整理出來顯示了我的另一個模型類的視圖XML

<record model="ir.ui.view" id="bpl_religion_registration_form"> 
<field name="name">bpl.relegious.places.form</field> 
<field name="model">bpl.relegious.places</field> 
<field name="type">form</field> 
<field name="arch" type="xml"> 
<form string="bpl_religion_registration" version='7.0'> 
<sheet> 
<group> 
    <group> 
     <field name="religion_id" style="width: 80%%" /> 
     <field name="relegious_place" style="width: 80%%" /> 
    </group> 
</group> 
<div name="Other Info"></div> 
<notebook> 
    <page string=" Festivals"> 
     <field name='festival_id' nolabel='1'> 
      <tree string='List' editable='bottom'> 
       <field name='name' /> 
       <field name='fest_allowance' /> 
       <field name='installments' /> 
       <field name='month' /> ..... 

這裏是這是會參考節日類另一個模型類

class festival_advance(osv.osv): 
    _name = "bpl.festival.advance" 
    _description = "Festival Advance" 
    _columns = { 
     'bpl_company_id':fields.many2one('res.company', 'Company', help='Company'), 
     'bpl_estate_id':fields.many2one('bpl.estate.n.registration', 'Estate', help='Estate', required=True), 
     'bpl_division_id':fields.many2one('bpl.division.n.registration', 'Division', help='Division', domain="[('estate_id','=',bpl_estate_id)]", required=True), 
     'festival_id': fields.many2one('bpl.festival', 'Festival' **NEED TO ADD FILTER HERE TO GET CURRENT MONTH FESTIVALS**), 
     'festival_advance': fields.float('Amount'), 
     'installment': fields.integer('Installment'), 
     'festival_advance_ids': fields.one2many('bpl.festival.advance.register', 'festival_advance_id', 'Festival Advances'), 
    } 

和這裏示出了屏幕快照更easeness

refer this image festival_advance()

回答

1

嘗試通過[( '月' 的節字段添加此領域, '=',time.strftime(」 %M'))]。它應該工作並顯示當月即將到來的所有節日。

0

感謝Priyesh。 用以下代碼完成

<field name='festival_id' on_change="on_change_festival(bpl_division_id,festival_id)" 
domain="[('month','=',time.strftime('%%m'))]" />