Skip to content

Commit

Permalink
[IMP] project_task_pull_request_state: add module
Browse files Browse the repository at this point in the history
  • Loading branch information
Volodiay616 committed Dec 29, 2023
1 parent 9301391 commit 3616588
Show file tree
Hide file tree
Showing 20 changed files with 935 additions and 0 deletions.
101 changes: 101 additions & 0 deletions project_task_pull_request_state/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
===============================
Project Task Pull Request State
===============================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:acd2039cd12805d8338b8489c2a4826a6997cd805e91aa6f03d2bd5960f0d88a
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fproject-lightgray.png?logo=github
:target: https://github.com/OCA/project/tree/16.0/project_task_pull_request_state
:alt: OCA/project
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/project-16-0/project-16-0-project_task_pull_request_state
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/project&target_branch=16.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

This module extends functionality of the project_task_pull_request module. It adds a
"State" field to Task alongside with PR URI field.

Following pre-defined states are available: "Draft", "Open", "Merged", "Closed". You can
add or modify this list easily by overriding the "\_selection_pr_state" function in the
"project.task" model

**Table of contents**

.. contents::
:local:

Use Cases / Context
===================

This module is designed as a basis for further automation based on the pull
request state of the task. For example one can use webhooks to set PR state
in the task when it is updated in the GitHub. And use automated actions afterwards
to update task status, assign and activity or do any other related actions.

Configuration
=============

#. In General Settings -> Project -> Project Task Pull Request section select default PR
State for all tasks

To define custom default PR state for particular project:

#. Select project -> Open "Settings" -> Set "Default PR State"

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

Bugs are tracked on `GitHub Issues <https://github.com/OCA/project/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/project/issues/new?body=module:%20project_task_pull_request_state%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
~~~~~~~

* Cetmix

Contributors
~~~~~~~~~~~~

* Cetmix <https://cetmix.com/>
Ivan Sokolov
Vladimir Kalmykov

Maintainers
~~~~~~~~~~~

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

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.

This module is part of the `OCA/project <https://github.com/OCA/project/tree/16.0/project_task_pull_request_state>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
3 changes: 3 additions & 0 deletions project_task_pull_request_state/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Copyright Cetmix OU 2023
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl-3.0).
from . import models
21 changes: 21 additions & 0 deletions project_task_pull_request_state/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright Cetmix OU 2023
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl-3.0).
{
"name": "Project Task Pull Request State",
"summary": "Track Pull Request state in tasks",
"version": "16.0.1.0.0",
"category": "Project Management",
"website": "https://github.com/OCA/project",
"author": "Cetmix, Odoo Community Association (OCA)",
"license": "AGPL-3",
"application": False,
"installable": True,
"depends": [
"project_task_pull_request",
],
"data": [
"views/project_task_view.xml",
"views/project_project_view.xml",
"views/res_config_settings_view.xml",
],
}
5 changes: 5 additions & 0 deletions project_task_pull_request_state/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Copyright Cetmix OU 2023
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl-3.0).
from . import project_task
from . import project_project
from . import res_config_settings
14 changes: 14 additions & 0 deletions project_task_pull_request_state/models/project_project.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Copyright Cetmix OU 2023
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl-3.0).
from odoo import fields, models


class ProjectState(models.Model):
_inherit = "project.project"

pr_state_default = fields.Selection(
selection=lambda self: self.env["project.task"]._selection_pr_state(),
string="Default PR State",
help="Default PR state that will be set when PR URI "
"is added to a task in this project",
)
41 changes: 41 additions & 0 deletions project_task_pull_request_state/models/project_task.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Copyright Cetmix OU 2023
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl-3.0).
from odoo import api, fields, models


class ProjectTaskState(models.Model):
_inherit = "project.task"

pr_state = fields.Selection(
selection=lambda self: self._selection_pr_state(),
tracking=True,
copy=False,
string="PR State",
compute="_compute_pr_state",
precompute=True,
store=True,
readonly=False,
)

def _selection_pr_state(self):
"""Function to select the state of the pull request"""
return [
("open", "Open"),
("draft", "Draft"),
("merged", "Merged"),
("closed", "Closed"),
]

@api.depends("pr_uri")
def _compute_pr_state(self):
ICPSudo = self.env["ir.config_parameter"].sudo()
pr_state_default = ICPSudo.get_param(
"project_task_pull_request_state.pr_state_default"
)
for task in self:
if not task.pr_uri:
task.pr_state = False
elif task.project_id and task.project_id.pr_state_default:
task.pr_state = task.project_id.pr_state_default
else:
task.pr_state = pr_state_default or False
15 changes: 15 additions & 0 deletions project_task_pull_request_state/models/res_config_settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright Cetmix OU 2023
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl-3.0).
from odoo import fields, models


class ResConfigSettings(models.TransientModel):
_inherit = "res.config.settings"

pr_state_default = fields.Selection(
selection=lambda self: self.env["project.task"]._selection_pr_state(),
string="Default PR State",
config_parameter="project_task_pull_request_state.pr_state_default",
help="Default PR state that will be set when "
"PR URI is added to a task in this project",
)
6 changes: 6 additions & 0 deletions project_task_pull_request_state/readme/CONFIGURE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#. In General Settings -> Project -> Project Task Pull Request section select default PR
State for all tasks

To define custom default PR state for particular project:

#. Select project -> Open "Settings" -> Set "Default PR State"
4 changes: 4 additions & 0 deletions project_task_pull_request_state/readme/CONTEXT.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
This module is designed as a basis for further automation based on the pull
request state of the task. For example one can use webhooks to set PR state
in the task when it is updated in the GitHub. And use automated actions afterwards
to update task status, assign and activity or do any other related actions.
3 changes: 3 additions & 0 deletions project_task_pull_request_state/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
* Cetmix <https://cetmix.com/>
Ivan Sokolov
Vladimir Kalmykov
6 changes: 6 additions & 0 deletions project_task_pull_request_state/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
This module extends functionality of the project_task_pull_request module. It adds a
"State" field to Task alongside with PR URI field.

Following pre-defined states are available: "Draft", "Open", "Merged", "Closed". You can
add or modify this list easily by overriding the "\_selection_pr_state" function in the
"project.task" model
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 3616588

Please sign in to comment.