Skip to content

Commit

Permalink
[ADD] hr_timesheet_employee_cost_currency
Browse files Browse the repository at this point in the history
  • Loading branch information
alexey-pelykh committed Feb 22, 2020
1 parent 3214acc commit 9bc4914
Show file tree
Hide file tree
Showing 9 changed files with 113 additions and 0 deletions.
3 changes: 3 additions & 0 deletions hr_timesheet_employee_cost_currency/__init__.py
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
22 changes: 22 additions & 0 deletions hr_timesheet_employee_cost_currency/__manifest__.py
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',
],
}
3 changes: 3 additions & 0 deletions hr_timesheet_employee_cost_currency/models/__init__.py
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
21 changes: 21 additions & 0 deletions hr_timesheet_employee_cost_currency/models/hr_employee.py
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
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Alexey Pelykh <[email protected]>
1 change: 1 addition & 0 deletions hr_timesheet_employee_cost_currency/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This module allows to specify employee's Timesheet Cost currency.
3 changes: 3 additions & 0 deletions hr_timesheet_employee_cost_currency/tests/__init__.py
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
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)
31 changes: 31 additions & 0 deletions hr_timesheet_employee_cost_currency/views/hr_employee.xml
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>

0 comments on commit 9bc4914

Please sign in to comment.