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

How to write domain filter onchange function for one2many field in odoo?

By
shridhar b ivani
on 11/27/15, 6:02 AM 1,274 views

 

In the following case I have written **def onchange_insp(self, cr, uid, ids, folionum,context=None)** function but at **inspec_type** in **'feedback.tree'** is not working properly.

from openerp.osv import fields, osv

from openerp import api

import logging

class feedback_form(osv.Model):

_name = 'feedback.form'

_columns = {

'company_id111': fields.many2one('res.company', 'Substation', required=True),

'folionum' : fields.many2one('calendar.event','Maintenance ID',),

'folio_number' : fields.many2one('asset.asset','Folio number',),

# this field is filtering properly

'inspec_type' : fields.many2one('asset1.inspection','Inspection Type',),

'frequency' : fields.char('Frequency'),

'shutdown' : fields.char('Shut Down'),

#'insp_msr1' : fields.many2one('results.measure','Result',),

'insp_rslt' : fields.one2many('feedback.tree','insp_rsltts','Inspection Result',),

}

def onchange_insp(self, cr, uid, ids, folionum,context=None):

dids = []

res = {}

for record in self.pool.get('calendar.event').browse(cr, uid, folionum, context=context):

dids = [x.id for x in record.inspection_name]

dids1 = []

for record in self.pool.get('calendar.event').browse(cr, uid, folionum, context=context):

dids1 = [x.id for x in record.folio_num1]

res.update({'inspec_type':[('id','in',dids)]})

res.update({'folio_number':[('id','in',dids1)]})

return {'domain':res}

feedback_form()

class feedback_tree(osv.Model):

_name = 'feedback.tree'

_columns = {

**# How to do this for this field please reply me soon**

'inspec_type' : fields.many2one('asset1.inspection','Inspection Type',),

'valuess' : fields.char('Values/Results'),

'insp_rsltts': fields.many2one('feedback.form','Result Id'),

'insp_msr1' : fields.many2one('results.measure','Result',),

}

def onchange_measure(self, cr, uid, ids, inspec_type, context=None):

dids = []

for record in self.pool.get('asset1.inspection').browse(cr, uid, inspec_type, context=context):

dids = [x.id for x in record.msr_insp]

return {'domain':{'insp_msr1':[('id','in',dids)]}}

feedback_tree()

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

1 follower(s)

Stats

Asked: 11/27/15, 6:02 AM
Seen: 1274 times
Last updated: 11/27/15, 1:56 PM