From 9bc4914ce910c440885fd04b577c192f77b14825 Mon Sep 17 00:00:00 2001 From: Alexey Pelykh Date: Fri, 21 Feb 2020 11:03:08 -0700 Subject: [PATCH] [ADD] hr_timesheet_employee_cost_currency --- .../__init__.py | 3 ++ .../__manifest__.py | 22 +++++++++++++ .../models/__init__.py | 3 ++ .../models/hr_employee.py | 21 +++++++++++++ .../readme/CONTRIBUTORS.rst | 1 + .../readme/DESCRIPTION.rst | 1 + .../tests/__init__.py | 3 ++ ...est_hr_timesheet_employee_cost_currency.py | 28 +++++++++++++++++ .../views/hr_employee.xml | 31 +++++++++++++++++++ 9 files changed, 113 insertions(+) create mode 100644 hr_timesheet_employee_cost_currency/__init__.py create mode 100644 hr_timesheet_employee_cost_currency/__manifest__.py create mode 100644 hr_timesheet_employee_cost_currency/models/__init__.py create mode 100644 hr_timesheet_employee_cost_currency/models/hr_employee.py create mode 100644 hr_timesheet_employee_cost_currency/readme/CONTRIBUTORS.rst create mode 100644 hr_timesheet_employee_cost_currency/readme/DESCRIPTION.rst create mode 100644 hr_timesheet_employee_cost_currency/tests/__init__.py create mode 100644 hr_timesheet_employee_cost_currency/tests/test_hr_timesheet_employee_cost_currency.py create mode 100644 hr_timesheet_employee_cost_currency/views/hr_employee.xml diff --git a/hr_timesheet_employee_cost_currency/__init__.py b/hr_timesheet_employee_cost_currency/__init__.py new file mode 100644 index 000000000..4b76c7b2d --- /dev/null +++ b/hr_timesheet_employee_cost_currency/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +from . import models diff --git a/hr_timesheet_employee_cost_currency/__manifest__.py b/hr_timesheet_employee_cost_currency/__manifest__.py new file mode 100644 index 000000000..3b22d1524 --- /dev/null +++ b/hr_timesheet_employee_cost_currency/__manifest__.py @@ -0,0 +1,22 @@ +# Copyright 2020 Brainbean Apps (https://brainbeanapps.com) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +{ + 'name': 'HR Timesheet: Employee Cost Currency', + 'version': '12.0.1.0.0', + 'category': 'Human Resources', + 'website': 'https://github.com/OCA/timesheet', + 'author': + 'Brainbean Apps, ' + 'Odoo Community Association (OCA)', + 'license': 'AGPL-3', + 'installable': True, + 'application': False, + 'summary': 'Configure employee\'s Timesheet Cost currency.', + 'depends': [ + 'hr_timesheet', + ], + 'data': [ + 'views/hr_employee.xml', + ], +} diff --git a/hr_timesheet_employee_cost_currency/models/__init__.py b/hr_timesheet_employee_cost_currency/models/__init__.py new file mode 100644 index 000000000..7456e6897 --- /dev/null +++ b/hr_timesheet_employee_cost_currency/models/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +from . import hr_employee diff --git a/hr_timesheet_employee_cost_currency/models/hr_employee.py b/hr_timesheet_employee_cost_currency/models/hr_employee.py new file mode 100644 index 000000000..6c4d69bf4 --- /dev/null +++ b/hr_timesheet_employee_cost_currency/models/hr_employee.py @@ -0,0 +1,21 @@ +# Copyright 2020 Brainbean Apps (https://brainbeanapps.com) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import fields, models + + +class HrEmployee(models.Model): + _inherit = 'hr.employee' + + currency_id = fields.Many2one( + comodel_name='res.currency', + related=None, + readonly=False, + required=True, + default=lambda self: self._get_default_currency_id(), + track_visibility='onchange', + ) + + def _get_default_currency_id(self): + return self.company_id.currency_id \ + or self.env.user.company_id.currency_id diff --git a/hr_timesheet_employee_cost_currency/readme/CONTRIBUTORS.rst b/hr_timesheet_employee_cost_currency/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..1c6a35a1e --- /dev/null +++ b/hr_timesheet_employee_cost_currency/readme/CONTRIBUTORS.rst @@ -0,0 +1 @@ +* Alexey Pelykh diff --git a/hr_timesheet_employee_cost_currency/readme/DESCRIPTION.rst b/hr_timesheet_employee_cost_currency/readme/DESCRIPTION.rst new file mode 100644 index 000000000..2c7424c5b --- /dev/null +++ b/hr_timesheet_employee_cost_currency/readme/DESCRIPTION.rst @@ -0,0 +1 @@ +This module allows to specify employee's Timesheet Cost currency. diff --git a/hr_timesheet_employee_cost_currency/tests/__init__.py b/hr_timesheet_employee_cost_currency/tests/__init__.py new file mode 100644 index 000000000..15c0a01cc --- /dev/null +++ b/hr_timesheet_employee_cost_currency/tests/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +from . import test_hr_timesheet_employee_cost_currency diff --git a/hr_timesheet_employee_cost_currency/tests/test_hr_timesheet_employee_cost_currency.py b/hr_timesheet_employee_cost_currency/tests/test_hr_timesheet_employee_cost_currency.py new file mode 100644 index 000000000..ca603a21a --- /dev/null +++ b/hr_timesheet_employee_cost_currency/tests/test_hr_timesheet_employee_cost_currency.py @@ -0,0 +1,28 @@ +# Copyright 2020 Brainbean Apps (https://brainbeanapps.com) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +from odoo.tests import common + + +class TestHrTimesheetEmployeeCostCurrency(common.TransactionCase): + + def setUp(self): + super().setUp() + + self.HrEmployee = self.env['hr.employee'] + self.eur = self.env.ref('base.EUR') + + def test_defaults(self): + employee = self.HrEmployee.create({ + 'name': 'Employee', + }) + + self.assertEqual(employee.currency_id, employee.company_id.currency_id) + + def test_specific(self): + employee = self.HrEmployee.create({ + 'name': 'Employee', + 'currency_id': self.eur.id, + }) + + self.assertEqual(employee.currency_id, self.eur) diff --git a/hr_timesheet_employee_cost_currency/views/hr_employee.xml b/hr_timesheet_employee_cost_currency/views/hr_employee.xml new file mode 100644 index 000000000..0e27edaa0 --- /dev/null +++ b/hr_timesheet_employee_cost_currency/views/hr_employee.xml @@ -0,0 +1,31 @@ + + + + + + hr.employee.form.timesheet + hr.employee + + + + o_row + + + 0 + base.group_multi_currency + + + + + + oe_edit_only + 1 + {'no_create': True} + + + + +