diff --git a/project_task_pull_request_state/README.rst b/project_task_pull_request_state/README.rst index a863d160f5..c3f37bda7d 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:bb9eb5ec6fa57cb44e4351905de08de7e3cbd046be8d85c8cf8bc23408a88ae9 + !! source digest: sha256:442d3934d77362069fd54a14bd95ff9bcac02734e36668a67ad8476c21f2a019 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! .. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png @@ -72,7 +72,6 @@ Contributors ------------ - Cetmix https://cetmix.com/ -- Vladimir Kalmykov volodiay616@gmail.com Maintainers ----------- @@ -87,9 +86,6 @@ 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. -.. |maintainer-isserver1| image:: https://github.com/isserver1.png?size=40px - :target: https://github.com/isserver1 - :alt: isserver1 .. |maintainer-CetmixGitDrone| image:: https://github.com/CetmixGitDrone.png?size=40px :target: https://github.com/CetmixGitDrone :alt: CetmixGitDrone @@ -99,7 +95,7 @@ promote its widespread use. Current `maintainers `__: -|maintainer-isserver1| |maintainer-CetmixGitDrone| |maintainer-Volodiay622| +|maintainer-CetmixGitDrone| |maintainer-Volodiay622| This module is part of the `OCA/project `_ project on GitHub. diff --git a/project_task_pull_request_state/__manifest__.py b/project_task_pull_request_state/__manifest__.py index 977425776f..7673a10312 100644 --- a/project_task_pull_request_state/__manifest__.py +++ b/project_task_pull_request_state/__manifest__.py @@ -7,7 +7,7 @@ "category": "Project Management", "website": "https://github.com/OCA/project", "author": "Cetmix, Odoo Community Association (OCA)", - "maintainers": ["isserver1", "CetmixGitDrone", "Volodiay622"], + "maintainers": ["CetmixGitDrone", "Volodiay622"], "license": "AGPL-3", "application": False, "installable": True, diff --git a/project_task_pull_request_state/models/project_task.py b/project_task_pull_request_state/models/project_task.py index 6207cef697..149f7f2d9e 100644 --- a/project_task_pull_request_state/models/project_task.py +++ b/project_task_pull_request_state/models/project_task.py @@ -24,14 +24,15 @@ def _selection_pr_state(self): ("closed", "Closed"), ] - @api.model - def create(self, vals): - new_rec = super(ProjectTaskState, self).create(vals) + @api.model_create_multi + def create(self, vals_list): + new_recs = super(ProjectTaskState, self).create(vals_list) # Set pr state if URI is provided at creation - if "pr_uri" in vals: - new_rec._set_pr_state(vals.get("pr_uri")) - return new_rec + for new_rec, vals in zip(new_recs, vals_list): + if "pr_uri" in vals: + new_rec._set_pr_state(vals.get("pr_uri")) + return new_recs def write(self, vals): if "pr_uri" in vals: @@ -41,18 +42,16 @@ def write(self, vals): @api.depends("pr_uri", "project_id.pr_state_default") def _compute_pr_state(self): for task in self: - pr_uri = task.pr_uri - if not pr_uri: + 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: - if task.project_id and task.project_id.pr_state_default: - task.pr_state = task.project_id.pr_state_default - else: - ICPSudo = self.env["ir.config_parameter"].sudo() - pr_state = ICPSudo.get_param( - "project_task_pull_request_state.pr_state_default" - ) - task.pr_state = pr_state + ICPSudo = self.env["ir.config_parameter"].sudo() + pr_state_default = ICPSudo.get_param( + "project_task_pull_request_state.pr_state_default" + ) + task.pr_state = pr_state_default or False def _set_pr_state(self, pr_uri, pr_state=None): """Set PR state based on pr_uri diff --git a/project_task_pull_request_state/readme/CONTRIBUTORS.md b/project_task_pull_request_state/readme/CONTRIBUTORS.md index 5f88dd6203..9015061b86 100644 --- a/project_task_pull_request_state/readme/CONTRIBUTORS.md +++ b/project_task_pull_request_state/readme/CONTRIBUTORS.md @@ -1,2 +1 @@ - Cetmix -- Vladimir Kalmykov diff --git a/project_task_pull_request_state/static/description/index.html b/project_task_pull_request_state/static/description/index.html index 3c4291eb5d..378ff4e741 100644 --- a/project_task_pull_request_state/static/description/index.html +++ b/project_task_pull_request_state/static/description/index.html @@ -367,7 +367,7 @@

Project Task Pull Request State

!! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -!! source digest: sha256:bb9eb5ec6fa57cb44e4351905de08de7e3cbd046be8d85c8cf8bc23408a88ae9 +!! source digest: sha256:442d3934d77362069fd54a14bd95ff9bcac02734e36668a67ad8476c21f2a019 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->

Beta License: AGPL-3 OCA/project Translate me on Weblate Try me on Runboat

This module extends functionality of the project_task_pull_request @@ -419,7 +419,6 @@

Authors

Contributors

@@ -430,7 +429,7 @@

Maintainers

mission is to support the collaborative development of Odoo features and promote its widespread use.

Current maintainers:

-

isserver1 CetmixGitDrone Volodiay622

+

CetmixGitDrone Volodiay622

This module is part of the OCA/project project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

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 336c8aa10d..5066d5b961 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 @@ -93,12 +93,55 @@ def test_create_task_with_uri(self): ) self.assertEqual(task_with_uri.pr_state, "open", "PR state must be 'open'") + def test_multi_create(self): + """Create several tasks at the one time""" + pr_state_default_config = self.env["res.config.settings"].get_values() + self.assertNotIn("pr_state_default", pr_state_default_config) + self.ICPSudo.set_param( + "project_task_pull_request_state.pr_state_default", "closed" + ) + pr_state_default_config = self.env["res.config.settings"].get_values() + self.assertEqual( + pr_state_default_config["pr_state_default"], + "closed", + "PR state must be 'closed'", + ) + test_tasks_data = [ + { + "name": "Test Task 1", + "project_id": self.project_1.id, + "pr_uri": "https://@my.pr.uri/pr", + }, + { + "name": "Test Task 2", + "project_id": self.project_2.id, + "pr_uri": "https://@my.pr.uri/pr", + }, + { + "name": "Test Task 3", + "project_id": self.project_3.id, + "pr_uri": "https://@my.pr.uri/pr", + }, + ] + 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") + # Set empty values + self.env["res.config.settings"].set_values() + self.assertFalse(test_tasks[2].pr_state, "PR state must be False") + def test_set_pr_state(self): """Test _set_pr_state function""" + self.task_3.write({"pr_uri": "https://@my.pr.uri/pr"}) + self.assertFalse(self.task_3.pr_state, "PR state must be False") # Set system wide default PR state self.ICPSudo.set_param( "project_task_pull_request_state.pr_state_default", "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.task_1.write({"pr_uri": "https://@my.pr.uri/pr"}) self.assertEqual(self.task_1.pr_state, "draft", "PR state must be 'draft")