Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] 9.0 migration of hr_holidays_legal_leave #267

Merged
merged 5 commits into from
Oct 27, 2016
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions hr_holidays_legal_leave/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ set leaves from the employee form.
Installation
============

* clone the branch 8.0 of the repository https://github.com/OCA/hr
* clone the branch 9.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 "HR Holidays Legal Leave" in your addons
Expand All @@ -25,8 +25,11 @@ Configuration

To configure this module, you need to:

Company setup
* Go to the company and select the leave type to use as legal leave
* assign legal leave type via Leaves > Configuration:
- choose Leave type you need
- click [Edit]
- set Legal/Annual checkbox
- click [Save]

HR Module Setup
* Assign legal leave type via Settings > Human Resources
Expand All @@ -36,7 +39,7 @@ Usage

.. 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/8.0
:target: https://runbot.odoo-community.org/runbot/116/9.0

Known issues / Roadmap
======================
Expand Down Expand Up @@ -67,6 +70,9 @@ Contributors

* Salton Massally <smassally@idtlabs.sl>
* Fekete Mihai <feketemihai@gmail.com>
* Ivan Yelizariev <yelizariev@it-projects.info>
* Bassirou Ndaw <b.ndaw@ergobit.org>
* Alexandre Fayolle <alexandre.fayolle@camptocamp.com>

Maintainer
----------
Expand Down
7 changes: 3 additions & 4 deletions hr_holidays_legal_leave/__openerp__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

{
'name': 'HR Holidays Legal Leave',
'version': '8.0.1.0.0',
'version': '9.0.1.0.0',
'category': 'Human Resources',
'license': 'AGPL-3',
'summary': 'Allows the definition of legal/annual leave',
Expand All @@ -13,8 +13,7 @@
'website': 'http://idtlabs.sl',
'depends': ['hr_holidays'],
'data': [
'views/res_config.xml',
'views/res_company.xml',
'views/hr_holidays_status.xml',
],
'installable': False,
'installable': True,
}
4 changes: 2 additions & 2 deletions hr_holidays_legal_leave/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
# © 2015 iDT LABS (http://www.@idtlabs.sl)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from . import res_config
from . import res_company
from . import hr_holidays_status
from . import hr_employee
from . import res_company
16 changes: 8 additions & 8 deletions hr_holidays_legal_leave/models/hr_employee.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from openerp import models, api, fields, _
from openerp.exceptions import Warning as UserError
from openerp.exceptions import UserError


class HrEmployee(models.Model):
Expand Down Expand Up @@ -38,13 +38,13 @@ def _inverse_remaining_days(self):

@api.multi
def _compute_remaining_days(self):
self.ensure_one()
legal_leave = self.company_id.legal_holidays_status_id
if not legal_leave:
raise UserError(_('Legal/annual leave type is not defined for '
'your company.'))
self.remaining_leaves = legal_leave.get_days(
self.id)[legal_leave.id]['remaining_leaves']
for rec in self:
legal_leave = rec.company_id.legal_holidays_status_id
if not legal_leave:
raise UserError(_('Legal/annual leave type is not defined for '
'your company.'))
rec.remaining_leaves = legal_leave.get_days(
rec.id)[legal_leave.id]['remaining_leaves']

remaining_leaves = fields.Integer(
'Remaining Legal Leaves',
Expand Down
30 changes: 30 additions & 0 deletions hr_holidays_legal_leave/models/hr_holidays_status.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# -*- coding: utf-8 -*-
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from openerp import fields, models, api


class HolidaysType(models.Model):
_inherit = "hr.holidays.status"

is_annual = fields.Boolean(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although I know this is what is now in v10, I'm seeing that this is not comfortable for user with access to several companies. We should have a company_id field that is filled by default with user company, but with the possibility to be switched. This is similar to Accounting settings.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pedrobaeza you're right (I think) but is it correct to have a different behaviour between 9 and 10 versions ?
If you want me to do it, I can but I will make a PR on v10 too to have the same behaviour.

@gurneyalex @feketemihai cc

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, please. I think it's a good change. We can cherry-pick the commit directly in v10 when done in v9.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pedrobaeza done in df9830f. Is it what you wanted ?

'Legal/Annual',
compute='_compute_is_annual',
inverse='_inverse_is_annual',
help='Use this Leave type as Legal/Annual for current company. '
'One and only one leave type can have this checkbox. '
'You cannot unset it directly. '
'Set it on another Leave type instead. '
)

@api.multi
def _compute_is_annual(self):
company = self.env.user.company_id
self.filtered(lambda x: x == company.legal_holidays_status_id)\
.update({'is_annual': True})

@api.multi
def _inverse_is_annual(self):
self.ensure_one()
company = self.env.user.company_id
if self.is_annual:
company.legal_holidays_status_id = self.id
27 changes: 0 additions & 27 deletions hr_holidays_legal_leave/models/res_config.py

This file was deleted.

14 changes: 14 additions & 0 deletions hr_holidays_legal_leave/views/hr_holidays_status.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="edit_holiday_status_form" model="ir.ui.view">
<field name="name">hr.holidays.status.form</field>
<field name="model">hr.holidays.status</field>
<field name="inherit_id" ref="hr_holidays.edit_holiday_status_form" />
<field name="arch" type="xml">
<xpath expr="//field[@name='name']"
position="after">
<field name="is_annual" />
</xpath>
</field>
</record>
</odoo>
18 changes: 0 additions & 18 deletions hr_holidays_legal_leave/views/res_company.xml

This file was deleted.

21 changes: 0 additions & 21 deletions hr_holidays_legal_leave/views/res_config.xml

This file was deleted.