flectra/addons/website_hr_recruitment/models/hr_recruitment.py
Siddharth Bhalgami e088762a21 [IMP] Improve Multi-Website Functionalities:-
- Affected Modules:
    website_sale, website_blog, website_partner, website_crm_partner_assign,
    website_customer, website_slides, website_links, website_membership,
    website_hr, website_hr_recruitment, website_payment, website_sale_delivery,
    website_forum, website_event

- Remove unnecessary model `website.product.pricelist` from website_sale,
  All its mechanism already transferd to existing model `product.pricelist`

- Change in `product.pricelist` model, make website_id(o2m) to website_ids(m2m),
  As user can choose that same pricelist can be used in multiple websites

- Added `default_website` as default values in `website_ids(m2m)` & `website_id(m2o)` field in
  almost all affected modules (mentioned above!!)

- To use/publish things(like... product, pricelist, blog, forum, events, etc...) in website,
  User have to set `website_published` mechanism `on` (if it's available for that model/object),
  Also have to set/assign different websites in `website_ids` field as per needs
2018-02-12 18:44:52 +05:30

72 lines
2.6 KiB
Python

# -*- coding: utf-8 -*-
# Part of Odoo, Flectra. See LICENSE file for full copyright and licensing details.
from werkzeug import urls
from flectra import api, fields, models
from flectra.tools.translate import html_translate
class RecruitmentSource(models.Model):
_inherit = 'hr.recruitment.source'
url = fields.Char(compute='_compute_url', string='Url Parameters')
@api.one
@api.depends('source_id', 'source_id.name', 'job_id')
def _compute_url(self):
base_url = self.env['ir.config_parameter'].sudo().get_param('web.base.url')
for source in self:
source.url = urls.url_join(base_url, "%s?%s" % (source.job_id.website_url,
urls.url_encode({
'utm_campaign': self.env.ref('hr_recruitment.utm_campaign_job').name,
'utm_medium': self.env.ref('utm.utm_medium_website').name,
'utm_source': source.source_id.name
})
))
class Applicant(models.Model):
_inherit = 'hr.applicant'
website_id = fields.Many2one('website', string="Website")
def website_form_input_filter(self, request, values):
if 'partner_name' in values:
values.setdefault('name', '%s\'s Application' % values['partner_name'])
return values
class Job(models.Model):
_name = 'hr.job'
_inherit = ['hr.job', 'website.seo.metadata', 'website.published.mixin']
def _get_default_website_description(self):
default_description = self.env["ir.model.data"].xmlid_to_object("website_hr_recruitment.default_website_description")
return (default_description.render() if default_description else "")
def _default_website(self):
default_website_id = self.env.ref('website.default_website')
return [default_website_id.id] if default_website_id else None
website_description = fields.Html('Website description', translate=html_translate, sanitize_attributes=False, default=_get_default_website_description)
website_ids = fields.Many2many('website', 'website_hr_job_pub_rel',
'website_id', 'job_id',
default=_default_website,
string='Websites', copy=False,
help='List of websites in which Job '
'will published.')
@api.multi
def _compute_website_url(self):
super(Job, self)._compute_website_url()
for job in self:
job.website_url = "/jobs/detail/%s" % job.id
@api.multi
def set_open(self):
self.write({'website_published': False})
return super(Job, self).set_open()