[FIX] hr_recruitment: use utm_mixin to allow to track the job applicant.
Remove old source_id
Use hr.recruitment.source to generate link with utm and create
alias with default value for utm
[FIX] crm/utm: Fix bug with utm (ddac26cdbb)
Move demo into data
Move ir_http to save the utm in the dispatch
This commit is contained in:
@@ -23,7 +23,6 @@ import crm
|
||||
import crm_lead
|
||||
import sales_team
|
||||
import calendar_event
|
||||
import ir_http
|
||||
import crm_phonecall
|
||||
import report
|
||||
import wizard
|
||||
|
||||
@@ -46,6 +46,7 @@ You can define the different phases of interviews and easily rate the applicant
|
||||
'calendar',
|
||||
'fetchmail',
|
||||
'web_kanban_gauge',
|
||||
'utm',
|
||||
],
|
||||
'data': [
|
||||
'wizard/hr_recruitment_create_partner_job_view.xml',
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
import werkzeug
|
||||
from datetime import datetime
|
||||
|
||||
from openerp import tools
|
||||
@@ -38,8 +39,54 @@ class hr_recruitment_source(osv.osv):
|
||||
""" Sources of HR Recruitment """
|
||||
_name = "hr.recruitment.source"
|
||||
_description = "Source of Applicants"
|
||||
_inherits = {"utm.source": "source_id"}
|
||||
|
||||
def _get_url(self, cr, uid, ids, field_name, arg, context=None):
|
||||
result = {}
|
||||
imd = self.pool['ir.model.data']
|
||||
for source in self.browse(cr, uid, ids, context=context):
|
||||
if not source.alias_id.id:
|
||||
result[source.id] = ''
|
||||
else:
|
||||
result[source.id] = werkzeug.url_encode({
|
||||
'utm_campaign': imd.xmlid_to_object(cr, SUPERUSER_ID, 'hr_recruitment.utm_campaign_job').name,
|
||||
'utm_medium': imd.xmlid_to_object(cr, SUPERUSER_ID, 'utm.utm_medium_website').name,
|
||||
'utm_source': source.source_id.name
|
||||
})
|
||||
return result
|
||||
|
||||
def create_alias(self, cr, uid, ids, context=None):
|
||||
imd = self.pool['ir.model.data']
|
||||
for source in self.browse(cr, uid, ids, context=context):
|
||||
alias_context = dict(context or {}, alias_model_name='hr.applicant', alias_parent_model_name='hr.job')
|
||||
vals = {
|
||||
'alias_parent_thread_id': source.job_id.id,
|
||||
'alias_name': "%s+%s" % (source.job_id.alias_name or source.job_id.name, source.name),
|
||||
'alias_defaults': {
|
||||
'job_id': source.job_id.id,
|
||||
'campaign_id': imd.xmlid_to_res_id(cr, SUPERUSER_ID, 'hr_recruitment.utm_campaign_job'),
|
||||
'medium_id': imd.xmlid_to_res_id(cr, SUPERUSER_ID, 'utm.utm_medium_email'),
|
||||
'source_id': source.source_id.id,
|
||||
},
|
||||
}
|
||||
new_alias_id = self.pool['mail.alias'].create(cr, uid, vals, alias_context)
|
||||
source.write({'alias_id': new_alias_id, 'name': source.source_id.name})
|
||||
return
|
||||
|
||||
def _get_source(self, cr, uid, ids, context=None):
|
||||
if ids:
|
||||
return self.pool['hr.recruitment.source'].search(cr, uid, [('source_id', 'in', ids)], context=context)
|
||||
return []
|
||||
|
||||
_columns = {
|
||||
'name': fields.char('Source Name', required=True, translate=True),
|
||||
'source_id': fields.many2one('utm.source', 'Source', ondelete='cascade', required=True),
|
||||
'url': fields.function(_get_url, string='Url', type='char', store={
|
||||
'hr.recruitment.source': (lambda self, cr, uid, ids, ctx: ids, ['source_id'], 20),
|
||||
'utm.source': (_get_source, ['name'], 20),
|
||||
}),
|
||||
'email': fields.related('alias_id', 'alias_name', string='Email', readonly=True, type='char'),
|
||||
'job_id': fields.many2one('hr.job', 'Job ID'),
|
||||
'alias_id': fields.many2one('mail.alias', 'Alias ID'),
|
||||
}
|
||||
|
||||
class hr_recruitment_stage(osv.osv):
|
||||
@@ -83,7 +130,7 @@ class hr_applicant(osv.Model):
|
||||
_name = "hr.applicant"
|
||||
_description = "Applicant"
|
||||
_order = "priority desc, id desc"
|
||||
_inherit = ['mail.thread', 'ir.needaction_mixin']
|
||||
_inherit = ['mail.thread', 'ir.needaction_mixin', 'utm.mixin']
|
||||
|
||||
_track = {
|
||||
'emp_id': {
|
||||
@@ -223,7 +270,6 @@ class hr_applicant(osv.Model):
|
||||
'survey': fields.related('job_id', 'survey_id', type='many2one', relation='survey.survey', string='Survey'),
|
||||
'response_id': fields.many2one('survey.user_input', "Response", ondelete='set null', oldname="response"),
|
||||
'reference': fields.char('Referred By'),
|
||||
'source_id': fields.many2one('hr.recruitment.source', 'Source'),
|
||||
'day_open': fields.function(_compute_day, string='Days to Open',
|
||||
multi='day_open', type="float",
|
||||
store={'hr.applicant': (lambda self, cr, uid, ids, c={}: ids, ['date_open'], 10)}),
|
||||
|
||||
@@ -54,22 +54,6 @@
|
||||
${object.user_id.signature | safe}]]></field>
|
||||
</record>
|
||||
|
||||
<!-- HR Recruitment Source -->
|
||||
|
||||
<record model="hr.recruitment.source" id="source_linkedin">
|
||||
<field name="name">LinkedIn</field>
|
||||
</record>
|
||||
<record model="hr.recruitment.source" id="source_monster">
|
||||
<field name="name">Monster</field>
|
||||
</record>
|
||||
<record model="hr.recruitment.source" id="source_word">
|
||||
<field name="name">Word of Mouth</field>
|
||||
</record>
|
||||
<record model="hr.recruitment.source" id="source_website_company">
|
||||
<field name="name">Company Website</field>
|
||||
</record>
|
||||
|
||||
|
||||
<!-- Resource(type_id) -->
|
||||
|
||||
<record model="hr.recruitment.degree" id="degree_graduate">
|
||||
@@ -182,5 +166,9 @@
|
||||
<record id="tag_applicant_sales" model="hr.applicant_category">
|
||||
<field name="name">Sales</field>
|
||||
</record>
|
||||
<record model="utm.campaign" id="utm_campaign_job">
|
||||
<field name="name">Job Campaign</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
|
||||
@@ -34,7 +34,6 @@
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
<!-- Applicants -->
|
||||
<record model="ir.ui.view" id="crm_case_tree_view_job">
|
||||
<field name="name">Applicants</field>
|
||||
@@ -53,7 +52,8 @@
|
||||
<field name="stage_id"/>
|
||||
<field name="title_action" invisible="context.get('invisible_next_action', True)"/>
|
||||
<field name="date_action" invisible="context.get('invisible_next_date', True)"/>
|
||||
<field name="source_id" invisible="1"/>
|
||||
<field name="medium_id"/>
|
||||
<field name="source_id"/>
|
||||
<field name="survey" invisible="1"/>
|
||||
<field name="response_id" invisible="1"/>
|
||||
<field name="priority"/>
|
||||
@@ -139,6 +139,7 @@
|
||||
<field name="title_action" class="oe_inline" placeholder="e.g. Call for interview"/>
|
||||
</div>
|
||||
<field name="priority" widget="priority"/>
|
||||
<field name="medium_id"/>
|
||||
<field name="source_id"/>
|
||||
<field name="reference"/>
|
||||
</group>
|
||||
@@ -337,6 +338,23 @@
|
||||
</p>
|
||||
</field>
|
||||
</record>
|
||||
<record model="ir.actions.act_window" id="action_hr_job_sources">
|
||||
<field name="name">Jobs Sources</field>
|
||||
<field name="res_model">hr.recruitment.source</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="domain">[('job_id', '=', active_id)]</field>
|
||||
<field name="context">{'default_job_id': active_id}</field>
|
||||
<field name="help" type="html">
|
||||
<p>
|
||||
Create here some alias...
|
||||
That will allow you to track from where the applicant is coming from...
|
||||
</p>
|
||||
<p>
|
||||
Create email and url for each distinct source. <br/>
|
||||
When the applicant will arrive, you will know from wich source the Job position is coming.
|
||||
</p>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- Jobs -->
|
||||
<record id="view_job_filter_recruitment" model="ir.ui.view">
|
||||
@@ -419,6 +437,11 @@
|
||||
type="object">
|
||||
<field name="documents_count" widget="statinfo" string="Documents"/>
|
||||
</button>
|
||||
<button class="oe_stat_button" type="action"
|
||||
name="%(action_hr_job_sources)d" icon="fa-share"
|
||||
context="{'default_job_id': active_id}">
|
||||
<div>Source / Alias</div>
|
||||
</button>
|
||||
</div>
|
||||
</xpath>
|
||||
</field>
|
||||
@@ -654,7 +677,10 @@
|
||||
<field name="model">hr.recruitment.source</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Sources of Applicants">
|
||||
<field name="name"/>
|
||||
<field name="source_id"/>
|
||||
<field name="email"/>
|
||||
<field name="url"/>
|
||||
<button name="create_alias" string="Create alias" type="object" icon="gtk-redo" />
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
@@ -664,7 +690,11 @@
|
||||
<field name="arch" type="xml">
|
||||
<form string="Sources of Applicants">
|
||||
<group>
|
||||
<field name="name"/>
|
||||
<field name="source_id"/>
|
||||
<field name="email"/>
|
||||
<field name="url"/>
|
||||
<field name="alias_id" invisible="1"/>
|
||||
<field name="job_id" invisible="1"/>
|
||||
</group>
|
||||
</form>
|
||||
</field>
|
||||
|
||||
@@ -6,11 +6,12 @@ Enable UTM trackers in shared links.
|
||||
=====================================================
|
||||
""",
|
||||
'version': '1.0',
|
||||
'depends':['marketing'],
|
||||
'data' : [
|
||||
'depends': ['marketing'],
|
||||
'data': [
|
||||
'security/ir.model.access.csv',
|
||||
'views/utm.xml',
|
||||
'utm_data.xml'
|
||||
],
|
||||
'demo': ['utm_demo.xml'],
|
||||
'demo': [],
|
||||
'auto_install': True,
|
||||
}
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import utm
|
||||
import utm
|
||||
import ir_http
|
||||
|
||||
@@ -96,4 +96,4 @@ class utm_mixin(osv.AbstractModel):
|
||||
'source_id': lambda self, cr, uid, ctx: self._get_default_track(cr, uid, 'source_id', ctx),
|
||||
'campaign_id': lambda self, cr, uid, ctx: self._get_default_track(cr, uid, 'campaign_id', ctx),
|
||||
'medium_id': lambda self, cr, uid, ctx: self._get_default_track(cr, uid, 'medium_id', ctx),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,7 +107,6 @@ class website_hr_recruitment(http.Controller):
|
||||
# public user can't create applicants (duh)
|
||||
env = request.env(user=SUPERUSER_ID)
|
||||
value = {
|
||||
'source_id' : env.ref('hr_recruitment.source_website_company').id,
|
||||
'name': '%s\'s Application' % post.get('partner_name'),
|
||||
}
|
||||
for f in ['email_from', 'partner_name', 'description']:
|
||||
|
||||
Reference in New Issue
Block a user