mirror of
https://gitlab.com/hibou-io/hibou-odoo/suite.git
synced 2025-01-20 12:37:31 +02:00
[ADD] hr_timesheet_work_entry: for Odoo 13
This commit is contained in:
15
hr_timesheet_work_entry/__init__.py
Normal file
15
hr_timesheet_work_entry/__init__.py
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
from . import models
|
||||||
|
|
||||||
|
|
||||||
|
def ts_work_type_pre_init_hook(cr):
|
||||||
|
"""
|
||||||
|
This module installs a Work Entry Type with code "TS"
|
||||||
|
If you have undergone a migration (either for this module
|
||||||
|
or even your own Payslip Work Entry lines with code "TS")
|
||||||
|
then the uniqueness constraint will prevent this module
|
||||||
|
from installing.
|
||||||
|
"""
|
||||||
|
cr.execute("UPDATE hr_work_entry_type "
|
||||||
|
"SET code = 'TS-PRE-INSTALL' "
|
||||||
|
"WHERE code = 'TS';"
|
||||||
|
)
|
||||||
22
hr_timesheet_work_entry/__manifest__.py
Executable file
22
hr_timesheet_work_entry/__manifest__.py
Executable file
@@ -0,0 +1,22 @@
|
|||||||
|
{
|
||||||
|
'name': 'Timesheet Work Entry Type',
|
||||||
|
'description': 'Set work types on timesheet records.',
|
||||||
|
'version': '13.0.1.0.0',
|
||||||
|
'website': 'https://hibou.io/',
|
||||||
|
'author': 'Hibou Corp. <hello@hibou.io>',
|
||||||
|
'license': 'AGPL-3',
|
||||||
|
'category': 'Human Resources',
|
||||||
|
'depends': [
|
||||||
|
'hr_timesheet',
|
||||||
|
'hr_work_entry',
|
||||||
|
],
|
||||||
|
'data': [
|
||||||
|
'data/hr_timesheet_work_entry_data.xml',
|
||||||
|
'views/timesheet_views.xml',
|
||||||
|
'views/work_entry_views.xml',
|
||||||
|
],
|
||||||
|
'demo': [
|
||||||
|
'data/hr_timesheet_work_entry_demo.xml',
|
||||||
|
],
|
||||||
|
'pre_init_hook': 'ts_work_type_pre_init_hook',
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<odoo>
|
||||||
|
|
||||||
|
<record id="work_input_timesheet" model="hr.work.entry.type">
|
||||||
|
<field name="name">Timesheet</field>
|
||||||
|
<field name="code">TS</field>
|
||||||
|
<field name="allow_timesheet" eval="True"/>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
</odoo>
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<odoo>
|
||||||
|
|
||||||
|
<record id="work_input_timesheet_internal" model="hr.work.entry.type">
|
||||||
|
<field name="name">Internal</field>
|
||||||
|
<field name="code">TS_INTERNAL</field>
|
||||||
|
<field name="allow_timesheet" eval="True"/>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
</odoo>
|
||||||
2
hr_timesheet_work_entry/models/__init__.py
Normal file
2
hr_timesheet_work_entry/models/__init__.py
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
from . import timesheet
|
||||||
|
from . import work_entry
|
||||||
9
hr_timesheet_work_entry/models/timesheet.py
Normal file
9
hr_timesheet_work_entry/models/timesheet.py
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
from odoo import api, fields, models
|
||||||
|
|
||||||
|
|
||||||
|
class AccountAnalyticLine(models.Model):
|
||||||
|
_inherit = 'account.analytic.line'
|
||||||
|
|
||||||
|
work_type_id = fields.Many2one('hr.work.entry.type', string='Work Type',
|
||||||
|
default=lambda self: self.env.ref('hr_timesheet_work_entry.work_input_timesheet',
|
||||||
|
raise_if_not_found=False))
|
||||||
7
hr_timesheet_work_entry/models/work_entry.py
Normal file
7
hr_timesheet_work_entry/models/work_entry.py
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
from odoo import fields, models
|
||||||
|
|
||||||
|
|
||||||
|
class HrWorkEntryType(models.Model):
|
||||||
|
_inherit = 'hr.work.entry.type'
|
||||||
|
|
||||||
|
allow_timesheet = fields.Boolean(string='Allow on Timesheet')
|
||||||
1
hr_timesheet_work_entry/tests/__init__.py
Normal file
1
hr_timesheet_work_entry/tests/__init__.py
Normal file
@@ -0,0 +1 @@
|
|||||||
|
from . import test_timesheet_work_type
|
||||||
19
hr_timesheet_work_entry/tests/test_timesheet_work_type.py
Normal file
19
hr_timesheet_work_entry/tests/test_timesheet_work_type.py
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
from odoo.tests import common
|
||||||
|
|
||||||
|
|
||||||
|
class TestTimesheetWorkType(common.TransactionCase):
|
||||||
|
def setUp(self):
|
||||||
|
super().setUp()
|
||||||
|
self.employee = self.env.ref('hr.employee_hne')
|
||||||
|
self.project = self.env.ref('project.project_project_2')
|
||||||
|
self.default_work_type = self.env.ref('hr_timesheet_work_entry.work_input_timesheet')
|
||||||
|
|
||||||
|
def test_01_work_type(self):
|
||||||
|
timesheet = self.env['account.analytic.line'].create({
|
||||||
|
'name': '/',
|
||||||
|
'employee_id': self.employee.id,
|
||||||
|
'unit_amount': 1.0,
|
||||||
|
'project_id': self.project.id,
|
||||||
|
})
|
||||||
|
self.assertTrue(timesheet.work_type_id)
|
||||||
|
self.assertEqual(timesheet.work_type_id, self.default_work_type)
|
||||||
30
hr_timesheet_work_entry/views/timesheet_views.xml
Normal file
30
hr_timesheet_work_entry/views/timesheet_views.xml
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<odoo>
|
||||||
|
|
||||||
|
<record id="hr_timesheet_line_tree_inherit" model="ir.ui.view">
|
||||||
|
<field name="name">account.analytic.line.tree.hr_timesheet.inherit</field>
|
||||||
|
<field name="model">account.analytic.line</field>
|
||||||
|
<field name="inherit_id" ref="hr_timesheet.hr_timesheet_line_tree"/>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<xpath expr="//tree/field[@name='task_id']" position="after">
|
||||||
|
<field name="work_type_id"
|
||||||
|
domain="[('allow_timesheet', '=', True)]"
|
||||||
|
context="{'default_allow_timesheet': True}" />
|
||||||
|
</xpath>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record id="hr_timesheet_line_form_inherit" model="ir.ui.view">
|
||||||
|
<field name="name">account.analytic.line.form.inherit</field>
|
||||||
|
<field name="model">account.analytic.line</field>
|
||||||
|
<field name="inherit_id" ref="hr_timesheet.hr_timesheet_line_form"/>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<xpath expr="//field[@name='task_id']" position="after">
|
||||||
|
<field name="work_type_id"
|
||||||
|
domain="[('allow_timesheet', '=', True)]"
|
||||||
|
context="{'default_allow_timesheet': True}" />
|
||||||
|
</xpath>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
</odoo>
|
||||||
23
hr_timesheet_work_entry/views/work_entry_views.xml
Normal file
23
hr_timesheet_work_entry/views/work_entry_views.xml
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<odoo>
|
||||||
|
|
||||||
|
<record id="hr_work_entry_type_view_form_inherit" model="ir.ui.view">
|
||||||
|
<field name="name">hr.work.type.view.form.inherit</field>
|
||||||
|
<field name="model">hr.work.entry.type</field>
|
||||||
|
<field name="inherit_id" ref="hr_work_entry.hr_work_entry_type_view_form"/>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<xpath expr="//group/group" position="after">
|
||||||
|
<group name="timesheet" string="Timesheets">
|
||||||
|
<field name="allow_timesheet"/>
|
||||||
|
</group>
|
||||||
|
</xpath>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<menuitem
|
||||||
|
id="hr_work_entry_type_menu"
|
||||||
|
name="Work Entry Types"
|
||||||
|
parent="hr_timesheet.hr_timesheet_menu_configuration"
|
||||||
|
action="hr_work_entry.hr_work_entry_type_action"/>
|
||||||
|
|
||||||
|
</odoo>
|
||||||
Reference in New Issue
Block a user