Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions hr_employee_language/README.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
.. image:: https://odoo-community.org/readme-banner-image
:target: https://odoo-community.org/get-involved?utm_source=readme
:alt: Odoo Community Association

====================
HR Employee Language
====================
Expand All @@ -17,7 +13,7 @@ HR Employee Language
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/license-AGPL--3-blue.png
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fhr-lightgray.png?logo=github
Expand Down Expand Up @@ -75,6 +71,7 @@ Contributors
- Savoir-faire Linux (http://www.savoirfairelinux.com)
- François Honoré <francois.honore@acsone.eu>
- Saran Lim. <saranl@ecosoft.co.th>
- Stefano Consolaro <stefano.consolaro@mymage.it>

Maintainers
-----------
Expand Down
25 changes: 21 additions & 4 deletions hr_employee_language/models/hr_employee_language.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,36 @@
# Copyright (C) 2017-Today: Odoo Community Association (OCA)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

from odoo import fields, models, tools
from odoo import fields, models


class HrEmployeeLanguage(models.Model):
_name = "hr.employee.language"
_description = "HR Employee Language"

name = fields.Selection(
tools.misc.scan_languages(), string="Language", required=True
)
def _get_selection(self):
"""
generate language selection from available on db
"""
selection = []
for lang in self.env["res.lang"].search([("active", "in", (True, False))]):
selection.append((lang.code, lang.name))
return selection

name = fields.Selection(_get_selection, string="Language", required=True)
description = fields.Char()
employee_id = fields.Many2one("hr.employee", string="Employee", required=True)
can_read = fields.Boolean(string="Read", default=True)
can_write = fields.Boolean(string="Write", default=True)
can_speak = fields.Boolean(string="Speak", default=True)
can_listen = fields.Boolean(string="Listen", default=True)

def _compute_display_name(self):
"""
redefine record display_name to show languages name instead languages code
"""
for record in self:
lang = self.env["res.lang"].search(
[("code", "=", record.name), ("active", "in", (True, False))], limit=1
)
record.display_name = lang.name if lang.name else record.name
1 change: 1 addition & 0 deletions hr_employee_language/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
- Savoir-faire Linux (<http://www.savoirfairelinux.com>)
- François Honoré \<francois.honore@acsone.eu\>
- Saran Lim. \<saranl@ecosoft.co.th\>
- Stefano Consolaro \<stefano.consolaro@mymage.it\>
38 changes: 15 additions & 23 deletions hr_employee_language/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,15 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils: https://docutils.sourceforge.io/" />
<title>README.rst</title>
<title>HR Employee Language</title>
<style type="text/css">

/*
:Author: David Goodger (goodger@python.org)
:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $
:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $
:Copyright: This stylesheet has been placed in the public domain.

Default cascading style sheet for the HTML output of Docutils.
Despite the name, some widely supported CSS2 features are used.

See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
customize this style sheet.
Expand Down Expand Up @@ -275,7 +274,7 @@
margin-left: 2em ;
margin-right: 2em }

pre.code .ln { color: gray; } /* line numbers */
pre.code .ln { color: grey; } /* line numbers */
pre.code, code { background-color: #eeeeee }
pre.code .comment, code .comment { color: #5C6576 }
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
Expand All @@ -301,7 +300,7 @@
span.pre {
white-space: pre }

span.problematic, pre.problematic {
span.problematic {
color: red }

span.section-subtitle {
Expand Down Expand Up @@ -360,21 +359,16 @@
</style>
</head>
<body>
<div class="document">
<div class="document" id="hr-employee-language">
<h1 class="title">HR Employee Language</h1>


<a class="reference external image-reference" href="https://odoo-community.org/get-involved?utm_source=readme">
<img alt="Odoo Community Association" src="https://odoo-community.org/readme-banner-image" />
</a>
<div class="section" id="hr-employee-language">
<h1>HR Employee Language</h1>
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:b3ab2caa6293b55025a5f7b0132a080a0edb268df1a0dcf4349e0ddb55d2bf2b
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/license-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/hr/tree/18.0/hr_employee_language"><img alt="OCA/hr" src="https://img.shields.io/badge/github-OCA%2Fhr-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/hr-18-0/hr-18-0-hr_employee_language"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/hr&amp;target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/hr/tree/18.0/hr_employee_language"><img alt="OCA/hr" src="https://img.shields.io/badge/github-OCA%2Fhr-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/hr-18-0/hr-18-0-hr_employee_language"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/hr&amp;target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>This module allows you to manage your employee languages.</p>
<p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents">
Expand All @@ -390,7 +384,7 @@ <h1>HR Employee Language</h1>
</ul>
</div>
<div class="section" id="usage">
<h2><a class="toc-backref" href="#toc-entry-1">Usage</a></h2>
<h1><a class="toc-backref" href="#toc-entry-1">Usage</a></h1>
<p>To use this module, you need to:</p>
<ul class="simple">
<li>Go to <em>Employees</em> &gt; select or create a new employee.</li>
Expand All @@ -400,36 +394,35 @@ <h2><a class="toc-backref" href="#toc-entry-1">Usage</a></h2>
<em>Languages</em></p>
</div>
<div class="section" id="bug-tracker">
<h2><a class="toc-backref" href="#toc-entry-2">Bug Tracker</a></h2>
<h1><a class="toc-backref" href="#toc-entry-2">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/hr/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/hr/issues/new?body=module:%20hr_employee_language%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
<h2><a class="toc-backref" href="#toc-entry-3">Credits</a></h2>
<h1><a class="toc-backref" href="#toc-entry-3">Credits</a></h1>
<div class="section" id="authors">
<h3><a class="toc-backref" href="#toc-entry-4">Authors</a></h3>
<h2><a class="toc-backref" href="#toc-entry-4">Authors</a></h2>
<ul class="simple">
<li>Savoir-faire Linux</li>
<li>Acsone</li>
</ul>
</div>
<div class="section" id="contributors">
<h3><a class="toc-backref" href="#toc-entry-5">Contributors</a></h3>
<h2><a class="toc-backref" href="#toc-entry-5">Contributors</a></h2>
<ul class="simple">
<li>Savoir-faire Linux (<a class="reference external" href="http://www.savoirfairelinux.com">http://www.savoirfairelinux.com</a>)</li>
<li>François Honoré &lt;<a class="reference external" href="mailto:francois.honore&#64;acsone.eu">francois.honore&#64;acsone.eu</a>&gt;</li>
<li>Saran Lim. &lt;<a class="reference external" href="mailto:saranl&#64;ecosoft.co.th">saranl&#64;ecosoft.co.th</a>&gt;</li>
<li>Stefano Consolaro &lt;<a class="reference external" href="mailto:stefano.consolaro&#64;mymage.it">stefano.consolaro&#64;mymage.it</a>&gt;</li>
</ul>
</div>
<div class="section" id="maintainers">
<h3><a class="toc-backref" href="#toc-entry-6">Maintainers</a></h3>
<h2><a class="toc-backref" href="#toc-entry-6">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org">
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
</a>
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.</p>
Expand All @@ -438,6 +431,5 @@ <h3><a class="toc-backref" href="#toc-entry-6">Maintainers</a></h3>
</div>
</div>
</div>
</div>
</body>
</html>
1 change: 1 addition & 0 deletions hr_employee_language/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import test_add_lang
40 changes: 40 additions & 0 deletions hr_employee_language/tests/test_add_lang.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
from odoo.tests.common import TransactionCase


class TestAddLanguage(TransactionCase):
@classmethod
def setUpClass(cls):
super().setUpClass()

def test_add_lang(self):
lang_list = self.env["res.lang"].search(
[("active", "in", (True, False))], limit=1
)
lang_old = lang_list.code
selection = self.env["hr.employee.language"]._get_selection()
selection_ck = any(map(lambda t: lang_old in t, selection))
# Test if a old lang is present
self.assertEqual(selection_ck, True, "Old language is present")

self.env["res.lang"].create({"code": "xx_XX", "name": "Foo"})
selection = self.env["hr.employee.language"]._get_selection()
selection_ck = any(map(lambda t: "xx_XX" in t, selection))
# Test if a new lang is present
self.assertEqual(selection_ck, True, "New language is present")

def test_compute_display_name(self):
self.env["hr.employee.language"].create(
{
"name": "en_GB",
"employee_id": self.env["hr.employee"].create({"name": "Test"}).id,
}
)
self.env["hr.employee.language"]._compute_display_name()
lang_ref = self.env["res.lang"].search(
[("code", "=", "en_GB"), ("active", "in", (True, False))], limit=1
)
self.assertEqual(
lang_ref.name,
"English (UK)",
"_compute_display_name not returns right value",
)