Skip to content

Commit

Permalink
[MIG] Migration of global_resource_leave.
Browse files Browse the repository at this point in the history
  • Loading branch information
adrienpeiffer committed May 2, 2017
1 parent 906027e commit 8b685f2
Show file tree
Hide file tree
Showing 13 changed files with 61 additions and 109 deletions.
1 change: 0 additions & 1 deletion global_resource_leave/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
# -*- coding: utf-8 -*-
from . import models
22 changes: 22 additions & 0 deletions global_resource_leave/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# -*- coding: utf-8 -*-
# Copyright 2015-2017 ACSONE SA/NV (<http://acsone.eu>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

{
'name': "Global Resource Leave",

'summary': """
Define globals leaves for working times.
""",
'author': 'ACSONE SA/NV',
'website': "http://acsone.eu",
'category': 'Other',
'version': '10.0.1.0.0',
'license': 'AGPL-3',
'depends': [
'resource',
],
'data': [
'views/resource_view.xml',
],
}
42 changes: 0 additions & 42 deletions global_resource_leave/__openerp__.py

This file was deleted.

1 change: 0 additions & 1 deletion global_resource_leave/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
# -*- coding: utf-8 -*-
from . import resource
57 changes: 19 additions & 38 deletions global_resource_leave/models/resource.py
Original file line number Diff line number Diff line change
@@ -1,29 +1,8 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# This file is part of global_resource_leave,
# an Odoo module.
#
# Copyright (c) 2015 ACSONE SA/NV (<http://acsone.eu>)
#
# global_resource_leave is free software:
# you can redistribute it and/or modify it under the terms of the GNU
# Affero General Public License as published by the Free Software
# Foundation,either version 3 of the License, or (at your option) any
# later version.
#
# global_resource_leave is distributed
# in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
# PURPOSE. See the GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with global_resource_leave.
# If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
# Copyright 2015-2017 ACSONE SA/NV (<http://acsone.eu>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from openerp import models, fields, api
from odoo import models, fields, api


class ResourceCalendar(models.Model):
Expand All @@ -37,29 +16,31 @@ class ResourceCalendar(models.Model):
string='All Leaves',
compute='_compute_all_leaves')

@api.one
@api.multi
@api.depends('calendar_leave_ids')
def _compute_all_leaves(self):
global_leaves = self.env['resource.calendar.leaves'].search(
[('calendar_id', '=', False),
('resource_id', '=', False),
'|',
('company_id', '=', self.company_id.id),
('company_id', '=', False)])
all_leaves = global_leaves + self.calendar_leave_ids
self.leave_ids = all_leaves
for record in self:
global_leaves = self.env['resource.calendar.leaves'].search(
[('calendar_id', '=', False),
('resource_id', '=', False),
'|',
('company_id', '=', record.company_id.id),
('company_id', '=', False)])
all_leaves = global_leaves + record.calendar_leave_ids
record.leave_ids = all_leaves


class ResourceCalendarLeaves(models.Model):
_inherit = "resource.calendar.leaves"

@api.one
@api.multi
@api.depends('calendar_id', 'calendar_id.company_id', 'force_company_id')
def _compute_company_id(self):
if self.calendar_id:
self.company_id = self.calendar_id.company_id
else:
self.company_id = self.force_company_id
for record in self:
if record.calendar_id:
record.company_id = record.calendar_id.company_id
else:
record.company_id = record.force_company_id

company_id = fields.Many2one(comodel_name='res.company', string="Company",
store=True, compute='_compute_company_id')
Expand Down
1 change: 0 additions & 1 deletion global_resource_leave/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
# -*- coding: utf-8 -*-
from . import test_global_resource_leave
27 changes: 3 additions & 24 deletions global_resource_leave/tests/test_global_resource_leave.py
Original file line number Diff line number Diff line change
@@ -1,29 +1,8 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# This file is part of global_resource_leave,
# an Odoo module.
#
# Copyright (c) 2015 ACSONE SA/NV (<http://acsone.eu>)
#
# global_resource_leave is free software:
# you can redistribute it and/or modify it under the terms of the GNU
# Affero General Public License as published by the Free Software
# Foundation,either version 3 of the License, or (at your option) any
# later version.
#
# global_resource_leave is distributed
# in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
# PURPOSE. See the GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with global_resource_leave.
# If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
# Copyright 2015-2017 ACSONE SA/NV (<http://acsone.eu>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from openerp.tests import common
from odoo.tests import common


class TestGlobalResourceLeave(common.TransactionCase):
Expand Down
4 changes: 2 additions & 2 deletions global_resource_leave/views/resource_view.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<odoo>
<data>
<record id="resource_calendar_leave_form" model="ir.ui.view">
<field name="name">resource.calendar.leaves.form (global_resource_leave)</field>
Expand Down Expand Up @@ -27,4 +27,4 @@
</field>
</record>
</data>
</openerp>
</odoo>
6 changes: 6 additions & 0 deletions setup/global_resource_leave/.eggs/README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
This directory contains eggs that were downloaded by setuptools to build, test, and run plug-ins.

This directory caches those eggs to prevent repeated downloads.

However, it is safe to delete this directory.

1 change: 1 addition & 0 deletions setup/global_resource_leave/odoo/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__import__('pkg_resources').declare_namespace(__name__)
1 change: 1 addition & 0 deletions setup/global_resource_leave/odoo/addons/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__import__('pkg_resources').declare_namespace(__name__)
6 changes: 6 additions & 0 deletions setup/global_resource_leave/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)

0 comments on commit 8b685f2

Please sign in to comment.