-
-
Notifications
You must be signed in to change notification settings - Fork 785
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[IMP] project_task_pull_request_state: add module
- Loading branch information
1 parent
9301391
commit 3616588
Showing
20 changed files
with
935 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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", | ||
], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
15
project_task_pull_request_state/models/res_config_settings.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
* Cetmix <https://cetmix.com/> | ||
Ivan Sokolov | ||
Vladimir Kalmykov |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
Oops, something went wrong.