Skip to content

Commit

Permalink
[11.0][MIG] hr_contract_default_trial_length
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaime Arroyo committed Jul 24, 2019
1 parent 7edd6e0 commit 5706513
Show file tree
Hide file tree
Showing 15 changed files with 123 additions and 41 deletions.
72 changes: 53 additions & 19 deletions hr_contract_default_trial_length/README.rst
Original file line number Diff line number Diff line change
@@ -1,18 +1,43 @@
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
:alt: License: AGPL-3

=============================
Default Contract Trail Length
=============================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fhr-lightgray.png?logo=github
:target: https://github.com/OCA/hr/tree/11.0/hr_contract_default_trial_length
:alt: OCA/hr
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/hr-11-0/hr-11-0-hr_contract_default_trial_length
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/116/11.0
:alt: Try me on Runbot

|badge1| |badge2| |badge3| |badge4| |badge5|

This addon allows you to define default trail length for contracts

**Table of contents**

.. contents::
:local:

Installation
============

To install this module, you need to:

* clone the branch 10.0 of the repository https://github.com/OCA/hr
* clone the branch 11.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 "Default Contract Trail Length" in your addons
Expand All @@ -26,43 +51,52 @@ shown above.

Usage
=====
* Set your trail length on your contract types

* Set your trail length on your contract types

Known issues / Roadmap
======================

* Contract trial length can also depend on contract duration

.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/116/10.0

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/hr/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed feedback
`here <https://github.com/OCA/hr/issues/new?body=module:%20hr_contract_default_trial_length%0Aversion:%208.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
If you spotted it first, help us smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/hr/issues/new?body=module:%20hr_contract_default_trial_length%0Aversion:%2011.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
~~~~~~~

* Salton Massally <smassally@idtlabs.sl>

Contributors
------------
~~~~~~~~~~~~

* Salton Massally (iDT Labs) <smassally@idtlabs.sl>
* Julien Laloux <julien.laloux@jlaloux.be>
* Jaime Arroyo <jaime.arroyo@creublanca.es>

Maintainer
----------
Maintainers
~~~~~~~~~~~

.. image:: http://odoo-community.org/logo.png
This module is maintained by the OCA.

.. 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.
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.

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.
This module is part of the `OCA/hr <https://github.com/OCA/hr/tree/11.0/hr_contract_default_trial_length>`_ project on GitHub.

To contribute to this module, please visit http://odoo-community.org.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 0 additions & 1 deletion hr_contract_default_trial_length/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Copyright 2015 Salton Massally
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

Expand Down
19 changes: 9 additions & 10 deletions hr_contract_default_trial_length/__manifest__.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
# -*- coding: utf-8 -*-
# Copyright 2015 Salton Massally
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

{
"name": "Default Contract Trail Length",
"version": "10.0.1.0.0",
'name': 'Default Contract Trail Length',
'version': '11.0.1.0.0',
'license': 'AGPL-3',
'author': "Salton Massally <smassally@idtlabs.sl>, "
"Odoo Community Association (OCA)",
"website": "http://idtlabs.sl",
"category": "Human Resources",
"summary": "Define default trail length for contracts",
"depends": [
'author': 'Salton Massally <smassally@idtlabs.sl>,'
'Odoo Community Association (OCA)',
'website': 'http://idtlabs.sl',
'category': 'Human Resources',
'summary': 'Define default trail length for contracts',
'depends': [
'hr_contract'
],
"data": [
'data': [
'views/hr_contract_type.xml',
],
'installable': True,
Expand Down
1 change: 0 additions & 1 deletion hr_contract_default_trial_length/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Copyright 2015 Salton Massally
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

Expand Down
12 changes: 6 additions & 6 deletions hr_contract_default_trial_length/models/hr_contract.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Copyright 2015 Salton Massally
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

Expand All @@ -9,13 +8,14 @@
class HrContract(models.Model):
_inherit = 'hr.contract'

@api.onchange('trial_date_start', 'type_id')
@api.onchange('type_id')
@api.multi
def onchange_trial_date_start(self):
self.ensure_one()
if self.trial_date_start and len(self.type_id):
res = self.type_id.trial_length
if res:
self.trial_date_end = False
if self.date_start and self.type_id:
days = self.type_id.trial_length
if days:
end_dt = fields.Date.from_string(
self.trial_date_start) + relativedelta(days=res)
self.date_start) + relativedelta(days=days)
self.trial_date_end = fields.Date.to_string(end_dt)
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Copyright 2015 Salton Massally
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

Expand Down
2 changes: 2 additions & 0 deletions hr_contract_default_trial_length/readme/CONFIGURE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
This module does not require any special configuration apart from enabling it as
shown above.
3 changes: 3 additions & 0 deletions hr_contract_default_trial_length/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
* Salton Massally (iDT Labs) <smassally@idtlabs.sl>
* Julien Laloux <julien.laloux@jlaloux.be>
* Jaime Arroyo <jaime.arroyo@creublanca.es>
1 change: 1 addition & 0 deletions hr_contract_default_trial_length/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This addon allows you to define default trail length for contracts
7 changes: 7 additions & 0 deletions hr_contract_default_trial_length/readme/INSTALL.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
To install this module, you need to:

* clone the branch 11.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 "Default Contract Trail Length" in your addons
* install the module
1 change: 1 addition & 0 deletions hr_contract_default_trial_length/readme/ROADMAP.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Contract trial length can also depend on contract duration
1 change: 1 addition & 0 deletions hr_contract_default_trial_length/readme/USAGE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Set your trail length on your contract types
1 change: 1 addition & 0 deletions hr_contract_default_trial_length/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import test_trial_length
30 changes: 30 additions & 0 deletions hr_contract_default_trial_length/tests/test_trial_length.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Copyright 2018 Eficent Business and IT Consulting Services, S.L.
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html


from odoo.tests.common import TransactionCase


class TestTrialLength(TransactionCase):

def setUp(self):
super().setUp()
self.type1 = self.env['hr.contract.type'].create({
'name': 'Type 1',
'trial_length': 20,
})
self.type2 = self.env['hr.contract.type'].create({
'name': 'Type 2',
'trial_length': 10,
})
self.contract = self.env['hr.contract'].create({
'name': 'Contract',
'type_id': self.type1.id,
'date_start': '2019-10-10',
'wage': 50000,
})

def test_onchange_trial_date_start(self):
self.contract.write({'type_id': self.type2.id})
self.contract.onchange_trial_date_start()
self.assertEqual(self.contract.trial_date_end, '2019-10-20')
12 changes: 9 additions & 3 deletions hr_contract_default_trial_length/views/hr_contract_type.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,15 @@
<field name="model">hr.contract.type</field>
<field name="inherit_id" ref="hr_contract.hr_contract_type_view_form"/>
<field name="arch" type="xml">
<field name="name" position="after">
<field name="trial_length"/>
</field>
<xpath expr="//group" position="after">
<group>
<label for="trial_length" string="Default Trial Length"/>
<div name="trial">
<field name="trial_length" nolabel="1"/>
<span> days</span>
</div>
</group>
</xpath>
</field>
</record>

Expand Down

0 comments on commit 5706513

Please sign in to comment.