Skip to content

Commit

Permalink
Merge 0490dec into 0f33cd7
Browse files Browse the repository at this point in the history
  • Loading branch information
Endika committed Jun 5, 2015
2 parents 0f33cd7 + 0490dec commit 3624f48
Show file tree
Hide file tree
Showing 13 changed files with 650 additions and 0 deletions.
42 changes: 42 additions & 0 deletions project_recalculate/README.rst
@@ -0,0 +1,42 @@
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
:alt: License: AGPL-3

Project recalculate
===================

This module allows you to recalculate a tasks project, assign "date from" and "estimation days" in project tasks, and runs recalculate proyect button in project profile. The tasks recalculate according a new field "Calculation type".

If the project date is changed or modified in the gant view, then all the pending tasks are retro-planned again according the new date.


Usage
=====

To use this module, you need to:

* First step, create a project or project template and assign calculation type and date begin or date end depending for calculation type.
* Second step, indicate in to tasks of project the "from days" and "estimation days".
* And Last step, runs "recalculate project" in project profile.

Credits
=======

Contributors
------------

* Endika Iglesias <endikaig@antiun.com>

Maintainer
----------

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
: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.

To contribute to this module, please visit https://odoo-community.org.
25 changes: 25 additions & 0 deletions project_recalculate/__init__.py
@@ -0,0 +1,25 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# This module copyright :
# (c) 2014 Antiun Ingenieria S.L. (Madrid, Spain, http://www.antiun.com)
# Endika Iglesias <endikaig@antiun.com>
#
# This program 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.
#
# This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################

from . import wizard
from . import models
38 changes: 38 additions & 0 deletions project_recalculate/__openerp__.py
@@ -0,0 +1,38 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# This module copyright :
# (c) 2014 Antiun Ingenieria S.L. (Madrid, Spain, http://www.antiun.com)
# Endika Iglesias <endikaig@antiun.com>
#
# This program 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.
#
# This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################

{
"name": "Project recalculate",
"version": "1.0",
"author": "Antiun Ingeniería S.L., ",
"website": "http://www.antiun.com",
"license": "AGPL-3",
"category": "Project",
"depends": ['base', 'project'],
'data': [
"wizard/recalculate_wizard.xml",
"views/project_project_view.xml",
"views/project_task_view.xml",
],
"installable": True,
}
150 changes: 150 additions & 0 deletions project_recalculate/i18n/es.po
@@ -0,0 +1,150 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * project_recalculate
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 8.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-05-28 22:07+0000\n"
"PO-Revision-Date: 2015-05-28 22:07+0000\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: project_recalculate
#: view:project.recalculate.wizard:project_recalculate.wizard_project_recalculate_form
msgid "\"\n"
" Continue?"
msgstr "\"\n"
" Continuar?"

#. module: project_recalculate
#: view:project.recalculate.wizard:project_recalculate.wizard_project_recalculate_form
msgid "\" will be recalculated.\n"
" The reference date is \""
msgstr "\" se recalculará.\n"
" La fecha tomada como referencia es \""

#. module: project_recalculate
#: help:project.task,from_days:0
msgid "Anticipation days from date begin or date end"
msgstr "Días de anticipación a la fecha de inicio o fin"

#. module: project_recalculate
#: field:project.project,calculation_type:0
msgid "Calculation type"
msgstr "Tipo de calculo"

#. module: project_recalculate
#: code:addons/project_recalculate/wizard/recalculate_wizard.py:49
#, python-format
msgid "Cannot recalculate project because your project don't have date end."
msgstr "No se puede recalcular el proyecto porque no tiene fecha fin."

#. module: project_recalculate
#: code:addons/project_recalculate/wizard/recalculate_wizard.py:44
#, python-format
msgid "Cannot recalculate project because your project don't have date start."
msgstr "No se puede recalcular el proyecto porque no tiene fecha inicio."

#. module: project_recalculate
#: view:project.recalculate.wizard:project_recalculate.wizard_project_recalculate_form
msgid "Continue"
msgstr "Continuar"

#. module: project_recalculate
#: field:project.recalculate.wizard,create_uid:0
msgid "Created by"
msgstr "Creado por"

#. module: project_recalculate
#: field:project.recalculate.wizard,create_date:0
msgid "Created on"
msgstr "Creado en"

#. module: project_recalculate
#: selection:project.project,calculation_type:0
msgid "Date begin"
msgstr "Fecha inicio"

#. module: project_recalculate
#: selection:project.project,calculation_type:0
msgid "Date end"
msgstr "Fecha fin"

#. module: project_recalculate
#: code:addons/project_recalculate/wizard/recalculate_wizard.py:44
#: code:addons/project_recalculate/wizard/recalculate_wizard.py:49
#, python-format
msgid "Error!"
msgstr "Error!"

#. module: project_recalculate
#: field:project.task,estimated_days:0
msgid "Estimated days"
msgstr "Días estimados"

#. module: project_recalculate
#: help:project.task,estimated_days:0
msgid "Estimated days to end"
msgstr "Días estimados para completar"

#. module: project_recalculate
#: field:project.task,from_days:0
msgid "From days"
msgstr "Días desde"

#. module: project_recalculate
#: field:project.recalculate.wizard,id:0
msgid "ID"
msgstr "ID"

#. module: project_recalculate
#: field:project.recalculate.wizard,write_uid:0
msgid "Last Updated by"
msgstr "última actualización por"

#. module: project_recalculate
#: field:project.recalculate.wizard,write_date:0
msgid "Last Updated on"
msgstr "última actualización en"

#. module: project_recalculate
#: model:ir.model,name:project_recalculate.model_project_project
#: field:project.recalculate.wizard,project:0
msgid "Project"
msgstr "Proyecto"

#. module: project_recalculate
#: field:project.recalculate.wizard,project_date:0
msgid "Project date"
msgstr "Fecha proyecto"

#. module: project_recalculate
#: model:ir.actions.act_window,name:project_recalculate.wizard_project_recalculate
msgid "Project recalculate"
msgstr "Recalcular proyecto"

#. module: project_recalculate
#: view:project.recalculate.wizard:project_recalculate.wizard_project_recalculate_form
msgid "Project tasks \""
msgstr "Las tareas del proyecto \""

#. module: project_recalculate
#: view:project.project:project_recalculate.edit_project_recalculate
msgid "Recalculate project"
msgstr "Recalcular proyecto"

#. module: project_recalculate
#: model:ir.model,name:project_recalculate.model_project_task
msgid "Task"
msgstr "Tareas"

#. module: project_recalculate
#: help:project.project,calculation_type:0
msgid "how to calculate tasks with date start or date end references"
msgstr "Cómo organizar las tareas con la fecha inicio o con la fecha fin como referencia"
25 changes: 25 additions & 0 deletions project_recalculate/models/__init__.py
@@ -0,0 +1,25 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# This module copyright :
# (c) 2014 Antiun Ingenieria S.L. (Madrid, Spain, http://www.antiun.com)
# Endika Iglesias <endikaig@antiun.com>
#
# This program 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.
#
# This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################

from . import project_project
from . import project_task
105 changes: 105 additions & 0 deletions project_recalculate/models/project_project.py
@@ -0,0 +1,105 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# This module copyright :
# (c) 2014 Antiun Ingenieria, SL (Madrid, Spain, http://www.antiun.com)
# Endika Iglesias <endikaig@antiun.com>
#
# This program 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.
#
# This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################

from openerp import models, fields
from openerp.exceptions import Warning # , RedirectWarning
from openerp.tools.translate import _


class ProjectProject(models.Model):
_inherit = 'project.project'

calculation_type = fields.Selection(
[('date_begin', 'Date begin'), ('date_end', 'Date end')],
default='date_begin', string='Calculation type',
help='how to calculate tasks with date start or date end references')

def calcule_date_start_date_end(self):
project_task_obj = self.env['project.task']
project_task_ids = project_task_obj.search(
[('project_id', '=', self.id)])
date_start = (fields.Datetime.from_string(self.date_start)
if self.date_start
else fields.Datetime.from_string(self.date))
date_end = (fields.Datetime.from_string(self.date)
if self.date
else fields.Datetime.from_string(self.date_start))
if len(project_task_ids) > 0:
min_date_start = fields.Datetime.from_string(
project_task_ids[0].date_start)
date_start_from_days = project_task_ids[0].from_days
max_date_end = fields.Datetime.from_string(
project_task_ids[0].date_end)
date_end_from_days = project_task_ids[0].from_days
date_start = fields.Datetime.from_string(
project_task_ids[0].date_start)
for project_task in project_task_ids:
if not project_task.date_start and project_task.date_end:
project_task.date_start = project_task.date_end
if not project_task.date_end and project_task.date_start:
project_task.date_end = project_task.date_start
if not project_task.date_start or not project_task.date_end:
continue
date_start = fields.Datetime.from_string(
project_task.date_start)
date_end = fields.Datetime.from_string(project_task.date_end)
if min_date_start > date_start:
min_date_start = date_start
date_start_from_days = project_task.from_days
if max_date_end < date_end:
max_date_end = date_end
date_end_from_days = project_task.from_days
if self.calculation_type == 'date_begin':
date_start = project_task_obj.calculate_date_without_weekend(
date_start, date_start_from_days, increment=False)
date_end = max_date_end
else:
date_start = min_date_start
date_end = project_task_obj.calculate_date_without_weekend(
max_date_end, date_end_from_days,
increment=True)
return (fields.Datetime.to_string(date_start),
fields.Datetime.to_string(date_end))

def project_recalculate(self):
if not self.calculation_type:
raise Warning(_('Cannot recalculate project because your project '
'don\'t have calculation type.'))
if self.calculation_type == 'date_begin' and not self.date_start:
raise Warning(_('Cannot recalculate project because your project '
'don\'t have date start.'))
if self.calculation_type == 'date_end' and not self.date:
raise Warning(_('Cannot recalculate project because your project '
'don\'t have date end.'))
project_task_obj = self.env['project.task']
project_task_type_obj = self.env['project.task.type']
project_task_type = project_task_type_obj.search([('fold', '=', True)])
project_task_type_ids = [x.id for x in project_task_type]
project_task_ids = project_task_obj.search(
[('project_id', '=', self.id),
('stage_id', 'not in', project_task_type_ids)
])
for project_task in project_task_ids:
project_task.task_recalculate()
date_start, date_end = self.calcule_date_start_date_end()
self.write({'date_start': date_start, 'date': date_end})

0 comments on commit 3624f48

Please sign in to comment.