Skip to content

Commit

Permalink
TA#66855 [MIG][16.0] project_default_task_stage
Browse files Browse the repository at this point in the history
  • Loading branch information
rivo2302 committed Aug 29, 2024
1 parent f5d51ef commit 52ab10d
Show file tree
Hide file tree
Showing 17 changed files with 184 additions and 0 deletions.
1 change: 1 addition & 0 deletions .docker_files/main/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"project_task_date_planned",
"project_task_full_text_search",
"project_type_advanced",
"project_default_task_stage",
],
"installable": True,
}
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ USER odoo
COPY project_task_date_planned /mnt/extra-addons/project_task_date_planned
COPY project_task_full_text_search /mnt/extra-addons/project_task_full_text_search
COPY project_type_advanced /mnt/extra-addons/project_type_advanced
COPY project_default_task_stage /mnt/extra-addons/project_default_task_stage

COPY .docker_files/main /mnt/extra-addons/main
COPY .docker_files/odoo.conf /etc/odoo
31 changes: 31 additions & 0 deletions project_default_task_stage/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
Project Default Task Stage
==========================
This module allows to define default task stages on projects.

Dependencies
------------
This module depends on modules ``project_type`` and ``project_stage_no_quick_create`` from the same repository.

Usage
-----
As member of ``Project / Manager``, I go to the form view of a project type.

I notice a new field ``Default Task Stages``. I select 3 stages in this field.

.. image:: static/description/project_type.png

I create a new project.

.. image:: static/description/new_project.png

I select my project type. I notice that the 3 previously defined stages are automatically filled.

.. image:: static/description/new_project_with_task_stages.png

Contributors
------------
* Numigi (tm) and all its contributors (https://bit.ly/numigiens)

More information
----------------
* Meet us at https://bit.ly/numigi-com
4 changes: 4 additions & 0 deletions project_default_task_stage/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Copyright 2024 Numigi (tm) and all its contributors (https://bit.ly/numigiens)
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

from . import models

Check notice on line 4 in project_default_task_stage/__init__.py

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

project_default_task_stage/__init__.py#L4

'.models' imported but unused (F401)
19 changes: 19 additions & 0 deletions project_default_task_stage/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright 2024 Numigi (tm) and all its contributors (https://bit.ly/numigiens)
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

{

Check warning on line 4 in project_default_task_stage/__manifest__.py

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

project_default_task_stage/__manifest__.py#L4

Statement seems to have no effect
"name": "Project Default Task Stages",
"version": "16.0.1.0.0",
"author": "Numigi",
"maintainer": "Numigi",
"website": "https://bit.ly/numigi-com",
"license": "LGPL-3",
"category": "Project",
"summary": "Default task stages on projects.",
"depends": ["project_type", "project"],
"data": [
"views/project_type_views.xml",
"views/project_project_views.xml",
],
"installable": True,
}
31 changes: 31 additions & 0 deletions project_default_task_stage/i18n/fr.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * project_default_task_stage
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-08-29 08:49+0000\n"
"PO-Revision-Date: 2024-08-29 08:49+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_default_task_stage
#: model:ir.model.fields,field_description:project_default_task_stage.field_project_type__default_task_stage_ids
msgid "Default Task Stages"
msgstr "Étapes de tâches par défaut"

#. module: project_default_task_stage
#: model:ir.model,name:project_default_task_stage.model_project_project
msgid "Project"
msgstr "Projet"

#. module: project_default_task_stage
#: model:ir.model,name:project_default_task_stage.model_project_type
msgid "Project Type"
msgstr "Type de projet"
5 changes: 5 additions & 0 deletions project_default_task_stage/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Copyright 2024 Numigi (tm) and all its contributors (https://bit.ly/numigiens)
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

from . import project

Check notice on line 4 in project_default_task_stage/models/__init__.py

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

project_default_task_stage/models/__init__.py#L4

'.project' imported but unused (F401)
from . import project_type

Check notice on line 5 in project_default_task_stage/models/__init__.py

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

project_default_task_stage/models/__init__.py#L5

'.project_type' imported but unused (F401)
15 changes: 15 additions & 0 deletions project_default_task_stage/models/project.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright 2024 Numigi (tm) and all its contributors (https://bit.ly/numigiens)
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

from odoo import api, models


class Project(models.Model):

_inherit = "project.project"

@api.onchange("type_id")
def _on_change_project_type_id__set_default_task_stages(self):
if self.type_id:
type_ids = self.type_id.default_task_stage_ids
self.type_ids = [(6, 0, type_ids.ids)]
17 changes: 17 additions & 0 deletions project_default_task_stage/models/project_type.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright 2024 Numigi (tm) and all its contributors (https://bit.ly/numigiens)
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

from odoo import fields, models


class ProjectType(models.Model):

_inherit = "project.type"

default_task_stage_ids = fields.Many2many(
"project.task.type",
"project_type_default_task_stage_rel",
"type_id",
"task_stage_id",
string="Default Task Stages",
)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions project_default_task_stage/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Copyright 2024 Numigi (tm) and all its contributors (https://bit.ly/numigiens)
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

from . import test_default_task_stage
26 changes: 26 additions & 0 deletions project_default_task_stage/tests/test_default_task_stage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Copyright 2024 Numigi (tm) and all its contributors (https://bit.ly/numigiens)
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).


from odoo.tests.common import SavepointCase


class TestDefaultTaskStage(SavepointCase):

@classmethod
def setUpClass(cls):
super().setUpClass()
cls.stage_1 = cls.env["project.task.type"].create({"name": "Stage 1"})
cls.stage_2 = cls.env["project.task.type"].create({"name": "Stage 2"})
cls.project_type = cls.env["project.type"].create(
{
"name": "My Project Type",
"default_task_stage_ids": [(6, 0, [cls.stage_1.id, cls.stage_2.id])],
}
)
cls.project = cls.env["project.project"].create({"name": "My Project"})

def test_onchange_project_type__task_stages_set(self):
self.project.type_id = self.project_type
self.project._on_change_project_type_id__set_default_task_stages()
assert self.project.type_ids == self.stage_1 | self.stage_2
15 changes: 15 additions & 0 deletions project_default_task_stage/views/project_project_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<odoo>

<record id="project_form" model="ir.ui.view">
<field name="name">Project Project Form</field>
<field name="model">project.project</field>
<field name="inherit_id" ref="project_type.project_form" />
<field name="arch" type="xml">
<field name="type_id" position="after">
<field name="type_ids" widget="many2many_tags" />
</field>
</field>
</record>

</odoo>
15 changes: 15 additions & 0 deletions project_default_task_stage/views/project_type_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<odoo>

<record id="project_type_form" model="ir.ui.view">
<field name="name">Project Type Form</field>
<field name="model">project.type</field>
<field name="inherit_id" ref="project_type.project_type_form" />
<field name="arch" type="xml">
<field name="code" position="before">
<field name="default_task_stage_ids" widget="many2many_tags"/>
</field>
</field>
</record>

</odoo>

0 comments on commit 52ab10d

Please sign in to comment.