Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

OpenERP 7 many2one with current month filter

By
priyankahdp
on 5/14/13, 3:22 AM 24,726 views

here is my festival model class.

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()

i need to get festivals in my another form for give festival advances. then i need to filter that records and need to show only festivals related to current month how to add domain filter for this requirement or please advice me to sort out this issue by another technique

thanks

here shows my view xml of another model class

<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' />  .....

and here is that another model class which is going to refer festival class

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'),
    }

and here shows the screen snapshot for more easeness

refer this image festival_advance()

1
Jignesh Rathod (jir)
On 5/14/13, 3:48 AM

[('month','=',time.strftime('%m'))]

thanks Jignesh

priyankahdp
on 5/14/13, 5:04 AM
0

priyankahdp

--priyankahdp--
1089
| 5 5 6
Colombo, Sri Lanka
--priyankahdp--
Java Developer ORACLE Python J2EE Spring Hibernate Struts & Jquery............. :-)
priyankahdp
On 5/14/13, 5:04 AM

its Done with following code

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

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

0 follower(s)

Stats

Asked: 5/14/13, 3:22 AM
Seen: 24726 times
Last updated: 3/16/15, 8:10 AM