2012-04-02 05:44:18 +00:00
# -*- coding: utf-8 -*-
##############################################################################
#
2012-04-10 09:56:42 +00:00
# OpenERP, Open Source Business Applications
2014-02-11 11:24:34 +00:00
# Copyright (C) 2004-Today OpenERP S.A. (<http://openerp.com>).
2012-04-02 05:44:18 +00:00
#
# 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/>.
#
##############################################################################
2014-02-11 11:24:34 +00:00
from openerp import SUPERUSER_ID
2012-12-06 14:56:32 +00:00
from openerp . osv import fields , osv
2012-04-02 05:44:18 +00:00
2014-02-11 11:24:34 +00:00
class hr_applicant_settings ( osv . TransientModel ) :
2012-04-10 10:56:32 +00:00
_name = ' hr.config.settings '
_inherit = [ ' hr.config.settings ' , ' fetchmail.config.settings ' ]
2012-04-02 05:44:18 +00:00
_columns = {
2013-07-15 10:10:35 +00:00
' module_document ' : fields . boolean ( ' Allow the automatic indexation of resumes ' ,
2013-07-24 13:45:48 +00:00
help = ' Manage your CV \' s and motivation letter related to all applicants. \n '
2013-09-17 13:08:14 +00:00
' -This installs the module document_ftp. This will install the knowledge management module in order to allow you to search using specific keywords through the content of all documents (PDF, .DOCx...) ' ) ,
2013-10-15 06:24:26 +00:00
' alias_prefix ' : fields . char ( ' Default Alias Name for Jobs ' ) ,
2014-02-11 11:24:34 +00:00
' alias_domain ' : fields . char ( ' Alias Domain ' ) ,
2012-04-02 05:44:18 +00:00
}
2013-12-24 07:22:24 +00:00
_defaults = {
2014-02-11 11:24:34 +00:00
' alias_domain ' : lambda self , cr , uid , context : self . pool [ ' mail.alias ' ] . _get_alias_domain ( cr , SUPERUSER_ID , [ 1 ] , None , None ) [ 1 ] ,
2013-12-24 07:22:24 +00:00
}
2014-02-11 11:24:34 +00:00
def _find_default_job_alias_id ( self , cr , uid , context = None ) :
alias_id = self . pool [ ' ir.model.data ' ] . xmlid_to_res_id ( cr , uid , ' hr_recruitment.mail_alias_jobs ' )
if not alias_id :
alias_ids = self . pool [ ' mail.alias ' ] . search (
cr , uid , [
( ' alias_model_id.model ' , ' = ' , ' hr.applicant ' ) ,
2014-02-13 11:28:11 +00:00
( ' alias_force_thread_id ' , ' = ' , False ) ,
2014-02-11 11:24:34 +00:00
( ' alias_parent_model_id.model ' , ' = ' , ' hr.job ' ) ,
2014-02-13 11:28:11 +00:00
( ' alias_parent_thread_id ' , ' = ' , False ) ,
2014-02-11 11:24:34 +00:00
( ' alias_defaults ' , ' = ' , ' {} ' )
] , context = context )
alias_id = alias_ids and alias_ids [ 0 ] or False
return alias_id
2013-05-27 13:32:37 +00:00
def get_default_alias_prefix ( self , cr , uid , ids , context = None ) :
2014-02-11 11:24:34 +00:00
alias_name = False
alias_id = self . _find_default_job_alias_id ( cr , uid , context = context )
if alias_id :
alias_name = self . pool [ ' mail.alias ' ] . browse ( cr , uid , alias_id , context = context ) . alias_name
2013-05-27 13:32:37 +00:00
return { ' alias_prefix ' : alias_name }
def set_default_alias_prefix ( self , cr , uid , ids , context = None ) :
mail_alias = self . pool . get ( ' mail.alias ' )
2014-02-11 11:24:34 +00:00
for record in self . browse ( cr , uid , ids , context = context ) :
alias_id = self . _find_default_job_alias_id ( cr , uid , context = context )
if not alias_id :
create_ctx = dict ( context , alias_model_name = ' hr.applicant ' , alias_parent_model_name = ' hr.job ' )
alias_id = self . pool [ ' mail.alias ' ] . create ( cr , uid , { ' alias_name ' : record . alias_prefix } , context = create_ctx )
else :
mail_alias . write ( cr , uid , alias_id , { ' alias_name ' : record . alias_prefix } , context = context )
2013-05-29 07:29:32 +00:00
return True