Improve code.
bzr revid: jir@tinyerp.com-20130611133141-v9jm2gjst33bdf4c
This commit is contained in:
parent
f9733dcc0c
commit
0a44c54786
|
@ -27,31 +27,31 @@ from openerp.osv import fields, osv
|
|||
from openerp.tools.translate import _
|
||||
|
||||
class applicant_document(osv.osv):
|
||||
_name = 'hr.applicant'
|
||||
_inherit = 'hr.applicant'
|
||||
_name = 'hr.applicant'
|
||||
_inherit = 'hr.applicant'
|
||||
|
||||
def _get_index_content(self, cr, uid, ids, fields, args, context=None):
|
||||
res = {}
|
||||
attachment_pool = self.pool.get('ir.attachment')
|
||||
for applicant in self.browse(cr, uid, ids, context=context):
|
||||
res[applicant.id] = 0
|
||||
attach_id = attachment_pool.search(cr, uid, [('res_model','=','hr.applicant'),('res_id','=',applicant.id)])
|
||||
if attach_id:
|
||||
for attach in attachment_pool.browse(cr, uid, attach_id, context):
|
||||
res[applicant.id] = attach.index_content
|
||||
return res
|
||||
def _get_index_content(self, cr, uid, ids, fields, args, context=None):
|
||||
res = {}
|
||||
attachment_pool = self.pool.get('ir.attachment')
|
||||
for applicant in self.browse(cr, uid, ids, context=context):
|
||||
res[applicant.id] = 0
|
||||
attach_id = attachment_pool.search(cr, uid, [('res_model','=','hr.applicant'),('res_id','=',applicant.id)])
|
||||
if attach_id:
|
||||
for attach in attachment_pool.browse(cr, uid, attach_id, context):
|
||||
res[applicant.id] = attach.index_content
|
||||
return res
|
||||
|
||||
def _content_search(self, cursor, user, obj, name, args, context=None):
|
||||
record_ids = []
|
||||
attachment_pool = self.pool.get('ir.attachment')
|
||||
args += [('res_model','=','hr.applicant')]
|
||||
attach_ids = attachment_pool.search(cursor, user, args)
|
||||
for attach in attachment_pool.browse(cursor, user, attach_ids):
|
||||
record_ids.append(attach.res_id)
|
||||
return [('id', 'in', record_ids)]
|
||||
def _content_search(self, cursor, user, obj, name, args, context=None):
|
||||
record_ids = []
|
||||
attachment_pool = self.pool.get('ir.attachment')
|
||||
args += [('res_model','=','hr.applicant')]
|
||||
attach_ids = attachment_pool.search(cursor, user, args)
|
||||
for attach in attachment_pool.browse(cursor, user, attach_ids):
|
||||
record_ids.append(attach.res_id)
|
||||
return [('id', 'in', record_ids)]
|
||||
|
||||
_columns = {
|
||||
'index_content': fields.function(_get_index_content, string='Index Content', \
|
||||
_columns = {
|
||||
'index_content': fields.function(_get_index_content, string='Index Content', \
|
||||
fnct_search=_content_search,type="text"),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -294,12 +294,12 @@
|
|||
</div>
|
||||
<div class="oe_kanban_footer_left" style="margin-top:5px;">
|
||||
<t t-raw="record.message_summary.raw_value"/>
|
||||
<a t-if="record.attachments.raw_value == 1" name="attachment_tree_view" type="object" style="margin-right: 10px"> <field name="attachments"/> Document</a>
|
||||
|
||||
<a t-if="record.attachments.raw_value gt 1" name="attachment_tree_view" type="object" style="margin-right: 10px"> <field name="attachments"/> Documents</a>
|
||||
|
||||
<a t-if="record.attachments.raw_value == 1" name="attachment_tree_view" type="object" style="margin-right: 10px"> <field name="attachments"/> Document</a>
|
||||
|
||||
<a t-if="record.attachments.raw_value gt 1" name="attachment_tree_view" type="object" style="margin-right: 10px"> <field name="attachments"/> Documents</a>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
<div class="oe_clear"></div>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue