[IMP] website_hr compatible with Multi-Website

This commit is contained in:
Kaushal Prajapati 2018-01-01 17:27:16 +05:30 committed by Siddharth Bhalgami
parent a8637343a9
commit 1ef704567a
3 changed files with 13 additions and 6 deletions

View File

@ -8,6 +8,10 @@ class HrEmployee(models.Model):
_inherit = ['hr.employee', 'website.published.mixin']
public_info = fields.Char(string='Public Info')
website_ids = fields.Many2many('website', 'website_hr_emp_pub_rel',
'website_id', 'emp_id',
string='Websites', copy=False,
help='List of websites in which Employee is published.')
@api.multi
def _compute_website_url(self):

View File

@ -15,6 +15,7 @@
<xpath expr="//page[@name='public']/group" position="inside">
<group>
<field name="public_info"/>
<field name="website_ids" widget="many2many_tags"/>
</group>
</xpath>
</field>

View File

@ -11,7 +11,7 @@
<xpath expr="//div[hasclass('oe_structure')]" position="after">
<section class="container" id="team">
<t t-set="is_publisher" t-value="request.env['res.users'].has_group('website.group_website_publisher')" />
<t t-set="employees_domain" t-value="[] if is_publisher else [('website_published', '=', True)]" />
<t t-set="employees_domain" t-value="[] if is_publisher else [('website_published', '=', True), '|', ('website_ids', '=', False), ('website_ids', 'in', website)]" />
<t t-set="employees" t-value="request.env['hr.employee'].search(employees_domain)" />
<div class="col-sm-12 text-center" t-if="len(employees)">
<h2>Our Team</h2>
@ -22,12 +22,14 @@
<t t-set="publish_edit" t-value="True"/>
</t>
<div class="clearfix"/>
<img t-att-src="website.image_url(employee, 'image_medium')" class="img shadow img-rounded"/>
<div class="mt8">
<strong t-field="employee.name"></strong>
<div class="emp" t-attf-data-publish="#{employee.website_published &amp; (not employee.website_ids or website in employee.website_ids) and 'on' or 'off'}">
<img t-att-src="website.image_url(employee, 'image_medium')" class="img shadow img-rounded"/>
<div class="mt8">
<strong t-field="employee.name"></strong>
</div>
<div t-field="employee.job_id"/>
<div t-field="employee.public_info" class="text-muted mt16 center-block"/>
</div>
<div t-field="employee.job_id"/>
<div t-field="employee.public_info" class="text-muted mt16 center-block"/>
</div>
</section>
</xpath>