Skip to content

Commit

Permalink
Merge pull request #212 from alfredoavanzosc/12.0-mig-project_phase
Browse files Browse the repository at this point in the history
12.0 mig project phase
  • Loading branch information
alfredoavanzosc authored May 15, 2020
2 parents cf41e7d + 8574cbb commit 7c1169b
Show file tree
Hide file tree
Showing 11 changed files with 329 additions and 0 deletions.
30 changes: 30 additions & 0 deletions project_phase/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
.. image:: https://img.shields.io/badge/license-AGPL--3-blue.png
:target: https://www.gnu.org/licenses/agpl
:alt: License: AGPL-3

=============
Project Phase
=============

With this module you can define different project phases or stages.

* There should be always a phase with sequence 1.

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

Bugs are tracked on `GitHub Issues
<https://github.com/avanzosc/project-addons/issues>`_. In case of trouble,
please check there if your issue has already been reported. If you spotted
it first, help us smash it by providing detailed and welcomed feedback.

Credits
=======

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

* Oihane Crucelaegui <oihanecrucelaegi@avanzosc.es>
* Ana Juaristi <anajuaristi@avanzosc.es>

Do not contact contributors directly about support or help with technical issues.
2 changes: 2 additions & 0 deletions project_phase/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import models
from .init_hook import post_init_hook
22 changes: 22 additions & 0 deletions project_phase/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Copyright 2018 Oihane Crucelaegui - AvanzOSC
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html

{
"name": "Project Phase",
"version": "12.0.1.0.0",
"category": "Project",
"license": "AGPL-3",
"author": "AvanzOSC",
"website": "http://www.avanzosc.es",
"depends": [
"project",
],
"data": [
"data/project_phase_data.xml",
"security/ir.model.access.csv",
"views/project_project_view.xml",
"views/project_phase_view.xml",
],
"post_init_hook": "post_init_hook",
"installable": True,
}
38 changes: 38 additions & 0 deletions project_phase/data/project_phase_data.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>
<odoo noupdate="True">
<record id="draft_project_phase" model="project.phase"
forcecreate="True">
<field name="name">Draft</field>
<field name="sequence">1</field>
</record>
<record id="viability_project_phase" model="project.phase"
forcecreate="True">
<field name="name">Viability</field>
<field name="sequence">20</field>
</record>
<record id="proposal_project_phase" model="project.phase"
forcecreate="True">
<field name="name">Proposal</field>
<field name="sequence">30</field>
</record>
<record id="offer_project_phase" model="project.phase"
forcecreate="True">
<field name="name">Offer</field>
<field name="sequence">40</field>
</record>
<record id="progress_project_phase" model="project.phase"
forcecreate="True">
<field name="name">Progress</field>
<field name="sequence">50</field>
</record>
<record id="close_project_phase" model="project.phase"
forcecreate="True">
<field name="name">Closed</field>
<field name="sequence">100</field>
</record>
<record id="cancel_project_phase" model="project.phase"
forcecreate="True">
<field name="name">Cancelled</field>
<field name="sequence">150</field>
</record>
</odoo>
119 changes: 119 additions & 0 deletions project_phase/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * project_phase
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 11.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-10-23 08:29+0000\n"
"PO-Revision-Date: 2018-10-23 08:29+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_phase
#: model:project.phase,name:project_phase.cancel_project_phase
msgid "Cancelled"
msgstr "Cancelado"

#. module: project_phase
#: model:project.phase,name:project_phase.close_project_phase
msgid "Closed"
msgstr "Cerrado"

#. module: project_phase
#: model:ir.model.fields,field_description:project_phase.field_project_phase_create_uid
msgid "Created by"
msgstr "Creado por"

#. module: project_phase
#: model:ir.model.fields,field_description:project_phase.field_project_phase_create_date
msgid "Created on"
msgstr "Creado en"

#. module: project_phase
#: model:ir.model.fields,field_description:project_phase.field_project_phase_display_name
msgid "Display Name"
msgstr "Nombre mostrado"

#. module: project_phase
#: model:project.phase,name:project_phase.draft_project_phase
msgid "Draft"
msgstr "Borrador"

#. module: project_phase
#: model:ir.model.fields,field_description:project_phase.field_project_phase_id
msgid "ID"
msgstr "ID"

#. module: project_phase
#: model:ir.model.fields,field_description:project_phase.field_project_phase___last_update
msgid "Last Modified on"
msgstr "Última modificación en"

#. module: project_phase
#: model:ir.model.fields,field_description:project_phase.field_project_phase_write_uid
msgid "Last Updated by"
msgstr "Última actualización de"

#. module: project_phase
#: model:ir.model.fields,field_description:project_phase.field_project_phase_write_date
msgid "Last Updated on"
msgstr "Última actualización en"

#. module: project_phase
#: model:ir.model.fields,field_description:project_phase.field_project_phase_name
msgid "Name"
msgstr "Nombre"

#. module: project_phase
#: model:project.phase,name:project_phase.offer_project_phase
msgid "Offer"
msgstr "Oferta"

#. module: project_phase
#: model:ir.model.fields,field_description:project_phase.field_project_project_phase_id
#: model:ir.ui.view,arch_db:project_phase.project_project_phase_search
msgid "Phase"
msgstr "Etapa"

#. module: project_phase
#: model:project.phase,name:project_phase.progress_project_phase
msgid "Progress"
msgstr "Ejecución"

#. module: project_phase
#: model:ir.model,name:project_phase.model_project_project
msgid "Project"
msgstr "Proyecto"

#. module: project_phase
#: model:ir.model,name:project_phase.model_project_phase
msgid "Project Phase"
msgstr "Etapa de proyecto"

#. module: project_phase
#: model:ir.actions.act_window,name:project_phase.project_phase_action
#: model:ir.ui.menu,name:project_phase.project_phase_menuitem
msgid "Project Phases"
msgstr "Etapas de proyecto"

#. module: project_phase
#: model:project.phase,name:project_phase.proposal_project_phase
msgid "Proposal"
msgstr "Propuesta"

#. module: project_phase
#: model:ir.model.fields,field_description:project_phase.field_project_phase_sequence
msgid "Sequence"
msgstr "Secuencia"

#. module: project_phase
#: model:project.phase,name:project_phase.viability_project_phase
msgid "Viability"
msgstr "Viabilidad"

10 changes: 10 additions & 0 deletions project_phase/init_hook.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Copyright 2018 Oihane Crucelaegui - AvanzOSC
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html


def post_init_hook(cr, registry):
cr.execute("""
UPDATE project_project
SET phase_id = (SELECT id FROM project_phase WHERE sequence = 1)
WHERE phase_id IS NULL;
""")
1 change: 1 addition & 0 deletions project_phase/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import project_project
26 changes: 26 additions & 0 deletions project_phase/models/project_project.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Copyright 2018 Oihane Crucelaegui - AvanzOSC
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
from odoo import api, fields, models


class ProjectPhase(models.Model):
_name = 'project.phase'
_description = 'Project Phase'
_order = 'sequence,name'

name = fields.Char(string='Name', require=True, translate=True)
sequence = fields.Integer(string='Sequence')


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

@api.model
def _get_default_phase_id(self):
""" Gives default stage_id """
return self.env['project.phase'].search([('sequence', '=', '1')])

phase_id = fields.Many2one(
comodel_name='project.phase', string='Phase',
track_visibility='onchange', default=_get_default_phase_id,
copy=False)
3 changes: 3 additions & 0 deletions project_phase/security/ir.model.access.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_project_phase,access_project_phase,model_project_phase,,1,0,0,0
access_project_phase_manager,access_project_phase manager,model_project_phase,project.group_project_manager,1,1,1,1
37 changes: 37 additions & 0 deletions project_phase/views/project_phase_view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<record id="project_phase_tree_view" model="ir.ui.view">
<field name="model">project.phase</field>
<field name="arch" type="xml">
<tree>
<field name="sequence" widget="handle"/>
<field name="name" />
</tree>
</field>
</record>

<record id="project_phase_form_view" model="ir.ui.view">
<field name="model">project.phase</field>
<field name="arch" type="xml">
<form>
<sheet>
<group>
<field name="name" />
<field name="sequence" />
</group>
</sheet>
</form>
</field>
</record>

<record id="project_phase_action" model="ir.actions.act_window">
<field name="name">Project Phases</field>
<field name="res_model">project.phase</field>
<field name="view_mode">tree,form</field>
</record>

<menuitem id="project_phase_menuitem"
action="project_phase_action"
parent="project.menu_project_config"
sequence="50" />
</odoo>
41 changes: 41 additions & 0 deletions project_phase/views/project_project_view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<record id="project_project_phase_form_view" model="ir.ui.view">
<field name="model">project.project</field>
<field name="inherit_id" ref="project.edit_project" />
<field name="arch" type="xml">
<sheet position="before">
<header>
<field name="phase_id" widget="statusbar" clickable="True"
required="True"/>
</header>
</sheet>
</field>
</record>

<record id="project_project_phase_tree_view" model="ir.ui.view">
<field name="model">project.project</field>
<field name="inherit_id" ref="project.view_project" />
<field name="arch" type="xml">
<field name="partner_id" position="after">
<field name="phase_id" />
</field>
</field>
</record>

<record id="project_project_phase_search" model="ir.ui.view">
<field name="model">project.project</field>
<field name="inherit_id" ref="project.view_project_project_filter" />
<field name="arch" type="xml">
<filter name="Partner" position="after">
<filter string="Phase" name="phase_id_group"
context="{'group_by':'phase_id'}"/>
</filter>
</field>
</record>

<record id="project.open_view_project_all" model="ir.actions.act_window">
<field name="context">{'search_default_phase_id_group': True}</field>
</record>

</odoo>

0 comments on commit 7c1169b

Please sign in to comment.