forked from OCA/timesheet
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ADD] hr_timesheet_employee_cost_currency
- Loading branch information
1 parent
3214acc
commit 9bc4914
Showing
9 changed files
with
113 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). | ||
|
||
from . import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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', | ||
], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). | ||
|
||
from . import hr_employee |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* Alexey Pelykh <[email protected]> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
This module allows to specify employee's Timesheet Cost currency. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
28 changes: 28 additions & 0 deletions
28
hr_timesheet_employee_cost_currency/tests/test_hr_timesheet_employee_cost_currency.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?xml version="1.0"?> | ||
<!-- | ||
Copyright 2020 Brainbean Apps (https://brainbeanapps.com) | ||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
--> | ||
<odoo> | ||
|
||
<record id="hr_employee_view_form_inherit_timesheet" model="ir.ui.view"> | ||
<field name="name">hr.employee.form.timesheet</field> | ||
<field name="model">hr.employee</field> | ||
<field name="inherit_id" ref="hr_timesheet.hr_employee_view_form_inherit_timesheet"/> | ||
<field name="arch" type="xml"> | ||
<xpath expr="//field[@name='currency_id']/.." position="attributes"> | ||
<attribute name="class">o_row</attribute> | ||
</xpath> | ||
<field name="currency_id" position="attributes"> | ||
<attribute name="invisible">0</attribute> | ||
<attribute name="groups">base.group_multi_currency</attribute> | ||
</field> | ||
<field name="timesheet_cost" position="after"> | ||
<field name="currency_id" position="move"/> | ||
</field> | ||
<field name="currency_id" position="attributes"> | ||
<attribute name="class">oe_edit_only</attribute> | ||
<attribute name="nolabel">1</attribute> | ||
<attribute name="options">{'no_create': True}</attribute> | ||
</field> | ||
</field> | ||
</record> | ||
|
||
</odoo> |