Skip to content

Commit

Permalink
Merge pull request #26 from Antiun/pr-event_project
Browse files Browse the repository at this point in the history
[ADD] Add new addon event_project
  • Loading branch information
pedrobaeza committed May 15, 2015
2 parents 561b32b + 8b642f7 commit 0f33cd7
Show file tree
Hide file tree
Showing 11 changed files with 379 additions and 0 deletions.
43 changes: 43 additions & 0 deletions event_project/README.rst
@@ -0,0 +1,43 @@
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
:alt: License: AGPL-3

Plan events through projects
============================

This module allows you to assign a project template to an event, creating the corresponding project for the event that ends on the event start date, and plan the project tasks backwards according a new field "Event anticipation days".

If the event date is changed, 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 template.
* Second step, indicate in to task of template the previous days to begin task.
* And Last step, create a new event and select project template.
It will then create automatically a new project related with the event.

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.
26 changes: 26 additions & 0 deletions event_project/__init__.py
@@ -0,0 +1,26 @@

# -*- 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>
# Antonio Espinosa <antonioea@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 models
39 changes: 39 additions & 0 deletions event_project/__openerp__.py
@@ -0,0 +1,39 @@
# -*- 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>
# Antonio Espinosa <antonioea@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": "Event project",
"version": "1.0",
"author": "Antiun Ingeniería S.L., "
"Serv. Tecnol. Avanzados - Pedro M. Baeza, ",
"website": "http://www.antiun.com",
"license": "AGPL-3",
"category": "Event Management",
"depends": ['base', 'event', 'project'],
'data': [
"views/event_event_view.xml",
"views/project_task_view.xml",
],
"installable": True,
}
46 changes: 46 additions & 0 deletions event_project/i18n/es.po
@@ -0,0 +1,46 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * event_project
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 8.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-05-09 11:24+0000\n"
"PO-Revision-Date: 2015-05-09 11:24+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: event_project
#: model:ir.model,name:event_project.model_event_event
msgid "Event"
msgstr "Evento"

#. module: event_project
#: field:project.task,anticipation_days:0
msgid "Event anticipation days"
msgstr "Días de anticipación del evento"

#. module: event_project
#: help:project.task,anticipation_days:0
msgid "Previous day to event date begin"
msgstr "Días previos a la fecha inicio del evento"

#. module: event_project
#: field:event.event,project_related:0
msgid "Related project"
msgstr "Projecto relacionado"

#. module: event_project
#: model:ir.model,name:event_project.model_project_task
msgid "Task"
msgstr "Tarea"

#. module: event_project
#: field:event.event,project_template:0
msgid "Template project"
msgstr "Plantilla de projecto"
28 changes: 28 additions & 0 deletions event_project/models/__init__.py
@@ -0,0 +1,28 @@

# -*- 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>
# Antonio Espinosa <antonioea@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
from . import event_event
72 changes: 72 additions & 0 deletions event_project/models/event_event.py
@@ -0,0 +1,72 @@
# -*- 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>
# Antonio Espinosa <antonioea@antiun.com>
# Javier Iniesta <javieria@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, api


class EventEvent(models.Model):
_inherit = 'event.event'

project_template = fields.Many2one(
comodel_name='project.project', string='Template project',
domain="[('state', '=', 'template')]")
project = fields.Many2one(
comodel_name='project.project', string='Related project',
readonly=True)

def get_project_with_duplicate_template(self, template):
project_obj = self.env['project.project']
result = template.duplicate_template()
return project_obj.browse(int(result['res_id']))

@api.model
def create(self, vals):
event = super(EventEvent, self).create(vals)
if (event.project_template and not event.project):
event.project = self.get_project_with_duplicate_template(
event.project_template)
event.project.reorganize_project(event, name=vals.get('name'))
return event

@api.one
def write(self, vals):
project_obj = self.env['project.project']
project = None
date_begin = None
if vals.get('project_template') and not self.project:
project_template = project_obj.browse(
int(vals['project_template']))
project = self.get_project_with_duplicate_template(
project_template)
vals['project'] = project.id
else:
project = self.project
date_begin = fields.Datetime.from_string(
self.date_begin) if not vals.get(
'date_begin') else fields.Datetime.from_string(vals['date_begin'])
if date_begin:
project.reorganize_project(
self, date_begin=date_begin, name=vals.get('name'))
return super(EventEvent, self).write(vals)
57 changes: 57 additions & 0 deletions event_project/models/project_project.py
@@ -0,0 +1,57 @@
# -*- 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>
# Antonio Espinosa <antonioea@antiun.com>
# Javier Iniesta <javieria@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 datetime import timedelta


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

def reorganize_project(self, event, date_begin=None, name=None):
project_task_obj = self.env['project.task']
project_task_type_done = self.env.ref('project.project_tt_deployment')
project_task_ids = project_task_obj.search(
[('project_id', '=', self.id),
('stage_id', '!=', project_task_type_done.id)])
if not date_begin:
date_begin = fields.Datetime.from_string(event.date_begin)
max_anticipation_days = 0
for project_task in project_task_ids:
date_start = fields.Datetime.to_string(
date_begin - timedelta(
days=int(project_task.anticipation_days)))
project_task.write({'date_start': str(date_start)})
if max_anticipation_days < int(project_task.anticipation_days):
max_anticipation_days = int(project_task.anticipation_days)
first_date_start = fields.Datetime.to_string(
date_begin - timedelta(
days=int(max_anticipation_days)))

vals = {'date': date_begin,
'date_start': first_date_start}
if name:
vals['name'] = name
self.write(vals)
33 changes: 33 additions & 0 deletions event_project/models/project_task.py
@@ -0,0 +1,33 @@
# -*- 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>
# Antonio Espinosa <antonioea@antiun.com>
# Javier Iniesta <javieria@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


class ProjectTask(models.Model):
_inherit = 'project.task'

anticipation_days = fields.Integer(
string='Event anticipation days', help='Event anticipation days')
Binary file added event_project/static/description/icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions event_project/views/event_event_view.xml
@@ -0,0 +1,18 @@
<?xml version="1.0"?>
<openerp>
<data>
<record id="view_event_event_form" model="ir.ui.view">
<field name="name">view_event_event_form</field>
<field name="model">event.event</field>
<field name="inherit_id" ref="event.view_event_form"/>
<field name="arch" type="xml">

<field name="date_tz" position="after">
<field name="project" attrs="{'invisible':[('project_template','=',False)]}"/>
<field name="project_template" attrs="{'readonly':[('project','!=',False)]}"/>
</field>

</field>
</record>
</data>
</openerp>
17 changes: 17 additions & 0 deletions event_project/views/project_task_view.xml
@@ -0,0 +1,17 @@
<?xml version="1.0"?>
<openerp>
<data>
<record id="view_project_task_form" model="ir.ui.view">
<field name="name">view_project_task_form</field>
<field name="model">project.task</field>
<field name="inherit_id" ref="project.view_task_form2"/>
<field name="arch" type="xml">

<field name="planned_hours" position="after">
<field name="anticipation_days"/>
</field>

</field>
</record>
</data>
</openerp>

0 comments on commit 0f33cd7

Please sign in to comment.