From d195054b9b83f9a68e040505ec6811ea3b388ec9 Mon Sep 17 00:00:00 2001
From: Volodiay616 <108336612+Volodiay616@users.noreply.github.com>
Date: Sun, 21 Jan 2024 21:30:08 -0600
Subject: [PATCH] [IMP] project_task_pull_request_state:after review
fix
---
project_task_pull_request_state/README.rst | 11 +++----
.../models/__init__.py | 2 --
.../models/project_project.py | 4 +--
.../models/project_task.py | 6 ++--
.../models/res_config_settings.py | 2 +-
.../readme/CONTRIBUTORS.rst | 7 +++--
.../readme/DESCRIPTION.rst | 2 +-
.../test_project_task_pull_request_state.py | 30 +++++++++----------
8 files changed, 32 insertions(+), 32 deletions(-)
diff --git a/project_task_pull_request_state/README.rst b/project_task_pull_request_state/README.rst
index 9234199b9e..6a5fc6d2a1 100644
--- a/project_task_pull_request_state/README.rst
+++ b/project_task_pull_request_state/README.rst
@@ -7,7 +7,7 @@ Project Task Pull Request State
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- !! source digest: sha256:acd2039cd12805d8338b8489c2a4826a6997cd805e91aa6f03d2bd5960f0d88a
+ !! source digest: sha256:e4361ed521f7d798fd58d0076a5554ecb61e5a99e05a6720cce230670b2bd6cf
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
@@ -32,7 +32,7 @@ This module extends functionality of the project_task_pull_request module. It ad
"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
+add or modify this list easily by overriding the "selection_pr_state" function in the
"project.task" model
**Table of contents**
@@ -79,9 +79,10 @@ Authors
Contributors
~~~~~~~~~~~~
-* Cetmix
- Ivan Sokolov
- Vladimir Kalmykov
+* `Cetmix `__
+
+ * Ivan Sokolov
+ * Vladimir Kalmykov
Maintainers
~~~~~~~~~~~
diff --git a/project_task_pull_request_state/models/__init__.py b/project_task_pull_request_state/models/__init__.py
index 2729576d95..fcf8c4e0d6 100644
--- a/project_task_pull_request_state/models/__init__.py
+++ b/project_task_pull_request_state/models/__init__.py
@@ -1,5 +1,3 @@
-# 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
diff --git a/project_task_pull_request_state/models/project_project.py b/project_task_pull_request_state/models/project_project.py
index 482c8242ea..e849705d8d 100644
--- a/project_task_pull_request_state/models/project_project.py
+++ b/project_task_pull_request_state/models/project_project.py
@@ -3,11 +3,11 @@
from odoo import fields, models
-class ProjectState(models.Model):
+class Project(models.Model):
_inherit = "project.project"
pr_state_default = fields.Selection(
- selection=lambda self: self.env["project.task"]._selection_pr_state(),
+ 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",
diff --git a/project_task_pull_request_state/models/project_task.py b/project_task_pull_request_state/models/project_task.py
index 264bb84cb3..7b8e2b6b75 100644
--- a/project_task_pull_request_state/models/project_task.py
+++ b/project_task_pull_request_state/models/project_task.py
@@ -3,11 +3,11 @@
from odoo import api, fields, models
-class ProjectTaskState(models.Model):
+class ProjectTask(models.Model):
_inherit = "project.task"
pr_state = fields.Selection(
- selection=lambda self: self._selection_pr_state(),
+ selection=lambda self: self.selection_pr_state(),
tracking=True,
copy=False,
string="PR State",
@@ -17,7 +17,7 @@ class ProjectTaskState(models.Model):
readonly=False,
)
- def _selection_pr_state(self):
+ def selection_pr_state(self):
"""Function to select the state of the pull request"""
return [
("open", "Open"),
diff --git a/project_task_pull_request_state/models/res_config_settings.py b/project_task_pull_request_state/models/res_config_settings.py
index a405f3e0df..2c01439cc7 100644
--- a/project_task_pull_request_state/models/res_config_settings.py
+++ b/project_task_pull_request_state/models/res_config_settings.py
@@ -7,7 +7,7 @@ class ResConfigSettings(models.TransientModel):
_inherit = "res.config.settings"
pr_state_default = fields.Selection(
- selection=lambda self: self.env["project.task"]._selection_pr_state(),
+ 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 "
diff --git a/project_task_pull_request_state/readme/CONTRIBUTORS.rst b/project_task_pull_request_state/readme/CONTRIBUTORS.rst
index 63e9232e48..7c03b7eb60 100644
--- a/project_task_pull_request_state/readme/CONTRIBUTORS.rst
+++ b/project_task_pull_request_state/readme/CONTRIBUTORS.rst
@@ -1,3 +1,4 @@
-* Cetmix
- Ivan Sokolov
- Vladimir Kalmykov
+* `Cetmix `__
+
+ * Ivan Sokolov
+ * Vladimir Kalmykov
diff --git a/project_task_pull_request_state/readme/DESCRIPTION.rst b/project_task_pull_request_state/readme/DESCRIPTION.rst
index 9632c15a9d..0df6d8d5bc 100644
--- a/project_task_pull_request_state/readme/DESCRIPTION.rst
+++ b/project_task_pull_request_state/readme/DESCRIPTION.rst
@@ -2,5 +2,5 @@ This module extends functionality of the project_task_pull_request module. It ad
"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
+add or modify this list easily by overriding the "selection_pr_state" function in the
"project.task" model
diff --git a/project_task_pull_request_state/tests/test_project_task_pull_request_state.py b/project_task_pull_request_state/tests/test_project_task_pull_request_state.py
index 3d07849f59..54627c82ea 100644
--- a/project_task_pull_request_state/tests/test_project_task_pull_request_state.py
+++ b/project_task_pull_request_state/tests/test_project_task_pull_request_state.py
@@ -76,16 +76,16 @@ def test_pull_request_state_set_default(self):
tasks = self.Task.browse([self.task_1.id, self.task_2.id, self.task_3.id])
tasks.write({"pr_uri": "https://@my.pr.uri/pr"})
- self.assertEqual(self.task_1.pr_state, "draft", "PR state must be 'draft")
- self.assertEqual(self.task_2.pr_state, "open", "PR state must be 'open")
- self.assertEqual(self.task_3.pr_state, "closed", "PR state must be 'closed")
+ self.assertEqual(self.task_1.pr_state, "draft", "PR state must be 'draft'")
+ self.assertEqual(self.task_2.pr_state, "open", "PR state must be 'open'")
+ self.assertEqual(self.task_3.pr_state, "closed", "PR state must be 'closed'")
# Change pr_state
tasks.write({"pr_state": "closed"})
- self.assertEqual(self.task_1.pr_state, "closed", "PR state must be 'closed")
- self.assertEqual(self.task_2.pr_state, "closed", "PR state must be 'closed")
- self.assertEqual(self.task_3.pr_state, "closed", "PR state must be 'closed")
+ self.assertEqual(self.task_1.pr_state, "closed", "PR state must be 'closed'")
+ self.assertEqual(self.task_2.pr_state, "closed", "PR state must be 'closed'")
+ self.assertEqual(self.task_3.pr_state, "closed", "PR state must be 'closed'")
def test_pull_request_state_set_explicit(self):
"""Set PR state from vals when PR URI is added to task"""
@@ -93,9 +93,9 @@ def test_pull_request_state_set_explicit(self):
tasks = self.Task.browse([self.task_1.id, self.task_2.id, self.task_3.id])
tasks.write({"pr_uri": "https://@my.pr.uri/pr", "pr_state": "merged"})
- self.assertEqual(self.task_1.pr_state, "merged", "PR state must be 'merged")
- self.assertEqual(self.task_2.pr_state, "merged", "PR state must be 'merged")
- self.assertEqual(self.task_3.pr_state, "merged", "PR state must be 'merged")
+ self.assertEqual(self.task_1.pr_state, "merged", "PR state must be 'merged'")
+ self.assertEqual(self.task_2.pr_state, "merged", "PR state must be 'merged'")
+ self.assertEqual(self.task_3.pr_state, "merged", "PR state must be 'merged'")
def test_create_task_with_uri(self):
"""Add PR URI when task created"""
@@ -130,9 +130,9 @@ def test_multi_create(self):
]
test_tasks = self.Task.create(test_tasks_data)
- self.assertEqual(test_tasks[0].pr_state, "draft", "PR state must be 'draft")
- self.assertEqual(test_tasks[1].pr_state, "open", "PR state must be 'open")
- self.assertEqual(test_tasks[2].pr_state, "closed", "PR state must be 'closed")
+ self.assertEqual(test_tasks[0].pr_state, "draft", "PR state must be 'draft'")
+ self.assertEqual(test_tasks[1].pr_state, "open", "PR state must be 'open'")
+ self.assertEqual(test_tasks[2].pr_state, "closed", "PR state must be 'closed'")
def test_set_pr_state(self):
"""Test _set_pr_state function"""
@@ -142,10 +142,10 @@ def test_set_pr_state(self):
self._set_default_pr_state("closed")
self.task_3.write({"pr_uri": "https://@my.pr.uri/new_pr"})
- self.assertEqual(self.task_3.pr_state, "closed", "PR state must be 'closed")
+ self.assertEqual(self.task_3.pr_state, "closed", "PR state must be 'closed'")
self.task_1.write({"pr_uri": "https://@my.pr.uri/pr"})
- self.assertEqual(self.task_1.pr_state, "draft", "PR state must be 'draft")
+ self.assertEqual(self.task_1.pr_state, "draft", "PR state must be 'draft'")
# Remove PR URI
self.task_1.write({"pr_uri": ""})
self.assertFalse(self.task_1.pr_state, "PR state must be False")
@@ -158,7 +158,7 @@ def test_set_pr_state(self):
"pr_uri": "https://@my.pr.uri/pr",
}
)
- self.assertEqual(test_task.pr_state, "closed", "PR state must be 'closed")
+ self.assertEqual(test_task.pr_state, "closed", "PR state must be 'closed'")
def test_set_pr_state_default(self):
"""Set values for the pr_state_default parameter"""