[CLEAN] hr_applicant_document: code cleaning
- new module organisation: model-related files in models/, demo in demo/, view data in views/ - code cleaning to lessen the code size bzr revid: tde@openerp.com-20131206163911-qx1k1edogqxg52kv
This commit is contained in:
parent
33633157f2
commit
3a038b60f2
|
@ -19,6 +19,4 @@
|
|||
#
|
||||
##############################################################################
|
||||
|
||||
import hr_applicant_document
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
import models
|
||||
|
|
|
@ -1,24 +1,4 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2010-today OpenERP SA (<http://www.openerp.com>)
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
|
||||
{
|
||||
'name': 'Applicant Resumes and Letters',
|
||||
|
@ -26,17 +6,20 @@
|
|||
'category': 'Human Resources',
|
||||
'sequence': 25,
|
||||
'summary': 'Search job applications by Index content.',
|
||||
'description': """
|
||||
This module allows you to search job applications by Index content
|
||||
of Resumes & Letters.
|
||||
""",
|
||||
'description': """This module allows you to search job applications by content
|
||||
of resumes and letters.""",
|
||||
'author': 'OpenERP SA',
|
||||
'website': 'http://www.openerp.com',
|
||||
'images': [],
|
||||
'depends': ['hr_recruitment','document'],
|
||||
'data': ['hr_applicant_document_view.xml'],
|
||||
'demo': ['hr_applicant_document_demo.xml'],
|
||||
'test': [],
|
||||
'depends': [
|
||||
'hr_recruitment',
|
||||
'document'
|
||||
],
|
||||
'data': [
|
||||
'views/hr_applicant.xml'
|
||||
],
|
||||
'demo': [
|
||||
'demo/hr_applicant.xml'
|
||||
],
|
||||
'installable': True,
|
||||
'auto_install': True,
|
||||
'application': True,
|
||||
|
|
|
@ -1,51 +0,0 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2010-today OpenERP SA (<http://www.openerp.com>)
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
#
|
||||
##############################################################################
|
||||
from openerp.osv import fields, osv
|
||||
|
||||
class hr_applicant(osv.osv):
|
||||
_inherit = 'hr.applicant'
|
||||
|
||||
def _get_index_content(self, cr, uid, ids, fields, args, context=None):
|
||||
res = {}
|
||||
attachment_pool = self.pool.get('ir.attachment')
|
||||
for id in ids:
|
||||
res[id] = ''
|
||||
attachment_ids = attachment_pool.search(cr, uid, [('res_model', '=', 'hr.applicant'), ('res_id', '=', id)], context=context)
|
||||
for attachment in attachment_pool.browse(cr, uid, attachment_ids, context=context):
|
||||
# adding index content of all attachments into one in order to find easily from all attachments
|
||||
res[id] += attachment.index_content or ''
|
||||
return res
|
||||
|
||||
def _content_search(self, cr, user, obj, name, args, context=None):
|
||||
record_ids = []
|
||||
attachment_pool = self.pool.get('ir.attachment')
|
||||
args += [('res_model','=','hr.applicant')]
|
||||
attachment_ids = attachment_pool.search(cr, user, args, context=context)
|
||||
for attachment in attachment_pool.browse(cr, user, attachment_ids, context=context):
|
||||
if attachment.res_id not in record_ids:
|
||||
record_ids.append(attachment.res_id)
|
||||
return [('id', 'in', record_ids)]
|
||||
|
||||
_columns = {
|
||||
'index_content': fields.function(_get_index_content, string='Index Content', \
|
||||
fnct_search=_content_search, type="text"),
|
||||
}
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from openerp.osv import fields, osv
|
||||
|
||||
|
||||
class hr_applicant(osv.Model):
|
||||
_inherit = 'hr.applicant'
|
||||
|
||||
def _get_index_content(self, cr, uid, ids, fields, args, context=None):
|
||||
res = dict.fromkeys(ids, '')
|
||||
Attachment = self.pool.get('ir.attachment')
|
||||
attachment_ids = Attachment.search(cr, uid, [('res_model', '=', 'hr.applicant'), ('res_id', 'in', ids)], context=context)
|
||||
for attachment in Attachment.browse(cr, uid, attachment_ids, context=context):
|
||||
res[attachment.res_id] += attachment.index_content or ''
|
||||
return res
|
||||
|
||||
def _content_search(self, cr, user, obj, name, args, context=None):
|
||||
record_ids = set()
|
||||
Attachment = self.pool.get('ir.attachment')
|
||||
args = ['&'] + args + [('res_model', '=', 'hr.applicant')]
|
||||
att_ids = Attachment.search(cr, user, args, context=context)
|
||||
record_ids = set(att.res_id for att in Attachment.browse(cr, user, att_ids, context=context))
|
||||
return [('id', 'in', list(record_ids))]
|
||||
|
||||
_columns = {
|
||||
'index_content': fields.function(
|
||||
_get_index_content, fnct_search=_content_search,
|
||||
string='Index Content', type="text"),
|
||||
}
|
Loading…
Reference in New Issue