diff --git a/hr_employee_firstname/README.rst b/hr_employee_firstname/README.rst index c0ff8a600cdf..d5631065f612 100644 --- a/hr_employee_firstname/README.rst +++ b/hr_employee_firstname/README.rst @@ -1,5 +1,6 @@ .. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg - :alt: License: AGPL-3 + :target: https://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 HR Employee First Name, Last Name ================================= @@ -12,7 +13,7 @@ Installation To install this module, you need to: -* clone the branch 8.0 of the repository https://github.com/OCA/hr +* clone the branch 10.0 of the repository https://github.com/OCA/hr * add the path to this repository in your configuration (addons-path) * update the module list * search for "HR Employee First Name, Last Name" in your addons @@ -43,13 +44,14 @@ Contributors * Fekete Mihai * David Dufresne * Adrien Peiffer (ACSONE) +* Antonio Esposito (ONESTEIN BV) Maintainer ---------- -.. image:: http://odoo-community.org/logo.png +.. image:: https://odoo-community.org/logo.png :alt: Odoo Community Association - :target: http://odoo-community.org + :target: https://odoo-community.org This module is maintained by the OCA. @@ -57,4 +59,4 @@ 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. -To contribute to this module, please visit http://odoo-community.org. +To contribute to this module, please visit https://odoo-community.org. diff --git a/hr_employee_firstname/__init__.py b/hr_employee_firstname/__init__.py index ba5b716b3e7b..98c5a36df58f 100644 --- a/hr_employee_firstname/__init__.py +++ b/hr_employee_firstname/__init__.py @@ -1,23 +1,6 @@ # -*- coding: utf-8 -*- -############################################################################## -# -# OpenERP, Open Source Management Solution -# This module copyright (C) 2010 - 2014 Savoir-faire Linux -# (). -# -# 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 . -# -############################################################################## +# Copyright (C) 2010 - 2014 Savoir-faire Linux () +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). from . import models +from .init_hook import post_init_hook diff --git a/hr_employee_firstname/__manifest__.py b/hr_employee_firstname/__manifest__.py index 35b8b12ae1e4..8b38269757cd 100644 --- a/hr_employee_firstname/__manifest__.py +++ b/hr_employee_firstname/__manifest__.py @@ -1,28 +1,10 @@ # -*- coding: utf-8 -*- -############################################################################## -# -# OpenERP, Open Source Management Solution -# This module copyright (C) 2010 - 2014 Savoir-faire Linux -# (). -# -# 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 . -# -############################################################################## +# © 2010 - 2014 Savoir-faire Linux () +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). { 'name': 'HR Employee First Name, Last Name', - 'version': '8.0.0.0.2', + 'version': '10.0.1.0.0', 'author': "Savoir-faire Linux, " "Fekete Mihai (Forest and Biomass Services Romania), " "Odoo Community Association (OCA)", @@ -38,7 +20,8 @@ 'data': [ 'views/hr_view.xml', ], + "post_init_hook": "post_init_hook", 'demo': [], 'test': [], - 'installable': False, + 'installable': True, } diff --git a/hr_employee_firstname/i18n/ar.po b/hr_employee_firstname/i18n/ar.po index efcd94b3a3b1..7219edda9c4b 100644 --- a/hr_employee_firstname/i18n/ar.po +++ b/hr_employee_firstname/i18n/ar.po @@ -5,7 +5,7 @@ # Translators: msgid "" msgstr "" -"Project-Id-Version: hr (8.0)\n" +"Project-Id-Version: hr (10.0)\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2015-11-30 05:19+0000\n" "PO-Revision-Date: 2015-08-13 14:31+0000\n" diff --git a/hr_employee_firstname/i18n/de.po b/hr_employee_firstname/i18n/de.po index 1f03c294dee8..a4684a97bb3a 100644 --- a/hr_employee_firstname/i18n/de.po +++ b/hr_employee_firstname/i18n/de.po @@ -4,7 +4,7 @@ # msgid "" msgstr "" -"Project-Id-Version: Odoo Server 8.0\n" +"Project-Id-Version: Odoo Server 10.0\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2015-04-24 10:20+0000\n" "PO-Revision-Date: 2015-04-24 10:20+0000\n" diff --git a/hr_employee_firstname/i18n/es.po b/hr_employee_firstname/i18n/es.po index 01f88593516e..cbb8f4855646 100644 --- a/hr_employee_firstname/i18n/es.po +++ b/hr_employee_firstname/i18n/es.po @@ -6,7 +6,7 @@ # Antonio Trueba, 2016 msgid "" msgstr "" -"Project-Id-Version: hr (8.0)\n" +"Project-Id-Version: hr (10.0)\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2015-11-30 05:19+0000\n" "PO-Revision-Date: 2016-02-05 12:48+0000\n" diff --git a/hr_employee_firstname/i18n/fi.po b/hr_employee_firstname/i18n/fi.po index 770ccba57b3d..3e6a6e6bcd65 100644 --- a/hr_employee_firstname/i18n/fi.po +++ b/hr_employee_firstname/i18n/fi.po @@ -5,7 +5,7 @@ # Translators: msgid "" msgstr "" -"Project-Id-Version: hr (8.0)\n" +"Project-Id-Version: hr (10.0)\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2016-04-14 04:15+0000\n" "PO-Revision-Date: 2016-04-04 11:07+0000\n" diff --git a/hr_employee_firstname/i18n/fr.po b/hr_employee_firstname/i18n/fr.po index 36d16120c3df..b7f0b65028b1 100644 --- a/hr_employee_firstname/i18n/fr.po +++ b/hr_employee_firstname/i18n/fr.po @@ -4,7 +4,7 @@ # msgid "" msgstr "" -"Project-Id-Version: Odoo Server 8.0\n" +"Project-Id-Version: Odoo Server 10.0\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2015-04-24 10:20+0000\n" "PO-Revision-Date: 2015-04-24 10:20+0000\n" diff --git a/hr_employee_firstname/i18n/hr_employee_firstname.pot b/hr_employee_firstname/i18n/hr_employee_firstname.pot deleted file mode 100644 index 6b13f0cf122c..000000000000 --- a/hr_employee_firstname/i18n/hr_employee_firstname.pot +++ /dev/null @@ -1,32 +0,0 @@ -# Translation of Odoo Server. -# This file contains the translation of the following modules: -# * hr_employee_firstname -# -msgid "" -msgstr "" -"Project-Id-Version: Odoo Server 8.0\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2015-04-24 10:20+0000\n" -"PO-Revision-Date: 2015-04-24 10:20+0000\n" -"Last-Translator: <>\n" -"Language-Team: \n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: \n" -"Plural-Forms: \n" - -#. module: hr_employee_firstname -#: model:ir.model,name:hr_employee_firstname.model_hr_employee -msgid "Employee" -msgstr "" - -#. module: hr_employee_firstname -#: field:hr.employee,firstname:0 -msgid "Firstname" -msgstr "" - -#. module: hr_employee_firstname -#: field:hr.employee,lastname:0 -msgid "Lastname" -msgstr "" - diff --git a/hr_employee_firstname/i18n/it.po b/hr_employee_firstname/i18n/it.po index a24c509f82b9..deebd0359a32 100644 --- a/hr_employee_firstname/i18n/it.po +++ b/hr_employee_firstname/i18n/it.po @@ -6,7 +6,7 @@ # Paolo Valier, 2016 msgid "" msgstr "" -"Project-Id-Version: hr (8.0)\n" +"Project-Id-Version: hr (10.0)\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2016-03-12 12:02+0000\n" "PO-Revision-Date: 2016-03-19 10:38+0000\n" diff --git a/hr_employee_firstname/i18n/nl_NL.po b/hr_employee_firstname/i18n/nl_NL.po index eb09d04a5f4f..2bedf6ae5f4b 100644 --- a/hr_employee_firstname/i18n/nl_NL.po +++ b/hr_employee_firstname/i18n/nl_NL.po @@ -6,7 +6,7 @@ # lfreeke , 2015 msgid "" msgstr "" -"Project-Id-Version: hr (8.0)\n" +"Project-Id-Version: hr (10.0)\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2015-10-03 22:37+0000\n" "PO-Revision-Date: 2015-09-28 20:59+0000\n" diff --git a/hr_employee_firstname/i18n/pt_BR.po b/hr_employee_firstname/i18n/pt_BR.po index 5c433097e413..beb1d3f27fbd 100644 --- a/hr_employee_firstname/i18n/pt_BR.po +++ b/hr_employee_firstname/i18n/pt_BR.po @@ -6,7 +6,7 @@ # danimaribeiro , 2016 msgid "" msgstr "" -"Project-Id-Version: hr (8.0)\n" +"Project-Id-Version: hr (10.0)\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2016-03-11 01:48+0000\n" "PO-Revision-Date: 2016-03-08 03:18+0000\n" diff --git a/hr_employee_firstname/i18n/ro.po b/hr_employee_firstname/i18n/ro.po index e8d7be091fc7..2af0c836f31a 100644 --- a/hr_employee_firstname/i18n/ro.po +++ b/hr_employee_firstname/i18n/ro.po @@ -4,7 +4,7 @@ # msgid "" msgstr "" -"Project-Id-Version: Odoo Server 8.0\n" +"Project-Id-Version: Odoo Server 10.0\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2015-04-24 10:20+0000\n" "PO-Revision-Date: 2015-04-24 10:20+0000\n" diff --git a/hr_employee_firstname/i18n/sl.po b/hr_employee_firstname/i18n/sl.po index 122a067c389a..0238cc9646c1 100644 --- a/hr_employee_firstname/i18n/sl.po +++ b/hr_employee_firstname/i18n/sl.po @@ -6,7 +6,7 @@ # Matjaž Mozetič , 2015 msgid "" msgstr "" -"Project-Id-Version: hr (8.0)\n" +"Project-Id-Version: hr (10.0)\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2015-08-18 13:10+0000\n" "PO-Revision-Date: 2015-08-16 11:40+0000\n" diff --git a/hr_employee_firstname/init_hook.py b/hr_employee_firstname/init_hook.py new file mode 100644 index 000000000000..12ca46d33d5d --- /dev/null +++ b/hr_employee_firstname/init_hook.py @@ -0,0 +1,11 @@ +# -*- coding: utf-8 -*- +# Copyright 2016 Onestein () +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo import SUPERUSER_ID +from odoo.api import Environment + + +def post_init_hook(cr, pool): + env = Environment(cr, SUPERUSER_ID, {}) + env['hr.employee']._update_employee_names() diff --git a/hr_employee_firstname/models/__init__.py b/hr_employee_firstname/models/__init__.py index c48e9660be46..ea58859484d5 100644 --- a/hr_employee_firstname/models/__init__.py +++ b/hr_employee_firstname/models/__init__.py @@ -1,23 +1,5 @@ # -*- coding: utf-8 -*- -############################################################################## -# -# OpenERP, Open Source Management Solution -# This module copyright (C) 2010 - 2014 Savoir-faire Linux -# (). -# -# 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 . -# -############################################################################## +# © 2010 - 2014 Savoir-faire Linux () +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). from . import hr_employee diff --git a/hr_employee_firstname/models/hr_employee.py b/hr_employee_firstname/models/hr_employee.py index e7022e28c29f..f7617af79267 100644 --- a/hr_employee_firstname/models/hr_employee.py +++ b/hr_employee_firstname/models/hr_employee.py @@ -1,29 +1,10 @@ # -*- coding: utf-8 -*- -############################################################################## -# -# OpenERP, Open Source Management Solution -# This module copyright (C) 2010 - 2014 Savoir-faire Linux -# (). -# -# 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 . -# -############################################################################## +# © 2010 - 2014 Savoir-faire Linux () +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from openerp import models, fields, api, SUPERUSER_ID +from odoo import models, fields, api -UPDATE_PARTNER_FIELDS = set(['firstname', 'lastname', 'user_id', - 'address_home_id']) +UPDATE_PARTNER_FIELDS = ['firstname', 'lastname', 'user_id', 'address_home_id'] class HrEmployee(models.Model): @@ -34,11 +15,6 @@ def split_name(self, name): clean_name = u" ".join(name.split(None)) if name else name return self.env['res.partner']._get_inverse_name(clean_name) - @api.cr_context - def _auto_init(self, cr, context=None): - super(HrEmployee, self)._auto_init(cr, context=context) - self._update_employee_names(cr, SUPERUSER_ID, context=context) - @api.model def _update_employee_names(self): employees = self.search([ @@ -64,11 +40,13 @@ def _update_partner_firstname(self, employee): def _get_name(self, lastname, firstname): return self.env['res.partner']._get_computed_name(lastname, firstname) - @api.one + @api.multi @api.onchange('firstname', 'lastname') def get_name(self): - if self.firstname and self.lastname: - self.name = self._get_name(self.lastname, self.firstname) + for employee in self: + if employee.firstname and employee.lastname: + employee.name = self._get_name( + employee.lastname, employee.firstname) def _firstname_default(self): return ' ' if self.env.context.get('module') else False diff --git a/hr_employee_firstname/tests/__init__.py b/hr_employee_firstname/tests/__init__.py index a9df4e5c6e2b..f24f5d832fc2 100644 --- a/hr_employee_firstname/tests/__init__.py +++ b/hr_employee_firstname/tests/__init__.py @@ -1 +1,4 @@ +# -*- coding: utf-8 -*- +# Copyright (C) 2014 Savoir-faire Linux. All Rights Reserved. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). from . import test_hr_employee_firstname diff --git a/hr_employee_firstname/tests/test_hr_employee_firstname.py b/hr_employee_firstname/tests/test_hr_employee_firstname.py index fb49f1042005..2e8a27d1bc1d 100644 --- a/hr_employee_firstname/tests/test_hr_employee_firstname.py +++ b/hr_employee_firstname/tests/test_hr_employee_firstname.py @@ -1,26 +1,9 @@ # -*- coding: utf-8 -*- -############################################################################## -# -# Copyright (C) 2014 Savoir-faire Linux. All Rights Reserved. -# -# 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 . -# -############################################################################## - -import openerp.tests -from openerp.tests.common import TransactionCase +# Copyright (C) 2014 Savoir-faire Linux. All Rights Reserved. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +import odoo +from odoo.tests.common import TransactionCase class TestEmployeeFirstname(TransactionCase): @@ -60,6 +43,17 @@ def test_get_name(self): # Check for employee3 self.assertEqual(self.employee3_id.name, 'Jenssens Famke') + def test_onchange(self): + """ + Validate the get_name method is not failing + """ + field_onchange = self.employee1_id._onchange_spec() + self.assertEqual(field_onchange.get('firstname'), '1') + self.assertEqual(field_onchange.get('lastname'), '1') + values = {'firstname': 'Antonio', 'lastname': 'Esposito'} + self.employee1_id.onchange(values, 'firstname', field_onchange) + self.employee1_id.onchange(values, 'lastname', field_onchange) + def test_auto_init_name(self): """ Validate the create method if the name is split @@ -111,10 +105,10 @@ def test_change_firstname_and_lastname(self): self.assertEqual(self.employee1_id.name, 'Carnaud Jean-Pierre') - @openerp.tests.common.at_install(False) - @openerp.tests.common.post_install(True) + @odoo.tests.common.at_install(False) + @odoo.tests.common.post_install(True) def test_update_name_post_install(self): - self.empl_demo = self.env.ref('hr.employee_fp') + self.empl_demo = self.env.ref('hr.employee_root') self.assertEqual(self.empl_demo.firstname, 'Parker') self.assertEqual(self.empl_demo.lastname, 'Pieter') diff --git a/hr_employee_firstname/views/hr_view.xml b/hr_employee_firstname/views/hr_view.xml index 16aa496fb0ae..4f053fbbef7c 100644 --- a/hr_employee_firstname/views/hr_view.xml +++ b/hr_employee_firstname/views/hr_view.xml @@ -1,27 +1,28 @@ - - + hr.employee - - - +