4
def _open_partner(self, cr, uid, data, context):
6
def _get_answers(self, cr, uid, ids):
8
select distinct(answer)
9
from profile_question_yes_rel
10
where profile in (%s)"""% ','.join([str(i) for i in ids ])
13
ans_yes = [x[0] for x in cr.fetchall()]
16
select distinct(answer)
17
from profile_question_no_rel
18
where profile in (%s)"""% ','.join([str(i) for i in ids ])
21
ans_no = [x[0] for x in cr.fetchall()]
23
return [ans_yes, ans_no]
25
def _get_parents(self, cr, uid, ids):
28
select distinct(parent_id)
29
from crm_profiling_profile
30
where parent_id is not null
31
and id in (%s)""" % ','.join([str(i) for i in ids ]))
33
parent_ids = [x[0] for x in cr.fetchall()]
37
if x not in ids_to_check:
38
ids_to_check.append(x)
42
ids_to_check = _get_parents(self, cr, uid, ids_to_check)
46
if (data['id'] in data['ids'])|(data['ids'] == []):
47
ids_to_check = _get_parents(self, cr, uid, data['ids'])
49
ids_to_check = _get_parents(self, cr, uid, [data['id']])
51
[yes_answers, no_answers] = _get_answers(self, cr, uid, ids_to_check)
53
query = "select partner from partner_question_rel "
54
query_end = "group by partner"
58
where answer in (%s) """ % (','.join([str(a) for a in yes_answers]))
60
#rebuild the end of the query
63
having count(*) >= %s """ % len(yes_answers)
67
query = query + "and "
69
query = query + "where "
73
select partner from partner_question_rel
74
where answer in (%s)) """ % ( ','.join([str(a) for a in no_answers]))
76
query = query + query_end
80
'name': 'Matching partners',
82
'view_mode': 'tree,form',
83
'res_model': 'res.partner',
84
'type': 'ir.actions.act_window'
87
(res,) =cr.fetchall(),
89
action['domain']= "[('id','=',(%s))]" % str(res[0][0])
91
action['domain']= "[('id','in',(%s))]" % ','.join([str(x[0]) for x in res])
95
class open_partner(wizard.interface):
99
'result': {'type': 'action', 'action': _open_partner, 'state':'end'}
103
open_partner('open_partner')