Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[16.0][ADD] project_task_pull_request_state #1189

Conversation

Volodiay622
Copy link

@Volodiay622 Volodiay622 commented Nov 6, 2023

It adds a "State" field to Task alongside with PR URI field.

@Volodiay622 Volodiay622 marked this pull request as draft November 6, 2023 19:01
@Volodiay622 Volodiay622 force-pushed the 16.0-t2959-project_task_pull_request_state-migration_from_11.0 branch from 21886e2 to 93c8ef7 Compare November 6, 2023 19:07
@Volodiay622 Volodiay622 marked this pull request as ready for review November 6, 2023 22:58
]

@api.model
def create(self, vals):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use multi record "create" implementation with vals_list instead of vale and api.create multi decorator

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resolved

project_task_pull_request_state/models/project_task.py Outdated Show resolved Hide resolved
pr_state = ICPSudo.get_param(
"project_task_pull_request_state.pr_state_default"
)
task.pr_state = pr_state
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if no config value is defined or it is empty?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resolved

@Volodiay622 Volodiay622 force-pushed the 16.0-t2959-project_task_pull_request_state-migration_from_11.0 branch from 12772fe to 1192515 Compare November 7, 2023 20:59
@Volodiay622 Volodiay622 marked this pull request as draft November 7, 2023 21:16
@Volodiay622 Volodiay622 force-pushed the 16.0-t2959-project_task_pull_request_state-migration_from_11.0 branch from 9fe5e9e to f754cee Compare November 7, 2023 21:20
@Volodiay622 Volodiay622 marked this pull request as ready for review November 7, 2023 21:20
@Volodiay622 Volodiay622 force-pushed the 16.0-t2959-project_task_pull_request_state-migration_from_11.0 branch from f754cee to 0bf3814 Compare November 13, 2023 03:21
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is is file doing here?) Is it needed? Please remove if not

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resolved

@@ -0,0 +1 @@
- Cetmix <https://cetmix.com/>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use MD format for links

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resolved

class TestPullRequestState(TransactionCase):
@classmethod
def setUpClass(cls):
super(TestPullRequestState, cls).setUpClass()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Disable tracking unless you need it for functional purposes

@classmethod
def setUpClass(cls):
    super().setUpClass()
    cls.env = cls.env(context=dict(cls.env.context, tracking_disable=True))

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resolved


pr_state = fields.Selection(
selection=lambda self: self._selection_pr_state(),
track_visibility="onchange",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This format of the "track_visibility" is not used any longer. Actually the is a warning in tests for that.
Here is a reference for that.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resolved

"PR URI is added to a task in this project",
)

def set_values(self):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function is not needed. Please use config_parameter in the field definition instead

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",
 )

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

applied

@@ -0,0 +1 @@
- Cetmix <@cetmix.com>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check back to
Cetmix <https://cetmix.com/>

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

applied

project_task_pull_request_state/__manifest__.py Outdated Show resolved Hide resolved
@Volodiay622 Volodiay622 marked this pull request as draft November 30, 2023 16:29
@Volodiay622 Volodiay622 marked this pull request as ready for review November 30, 2023 17:11
project_task_pull_request_state/models/project_task.py Outdated Show resolved Hide resolved
new_recs = super(ProjectTaskState, self).create(vals_list)

# Set pr state if URI is provided at creation
for new_rec, vals in zip(new_recs, vals_list):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pr_state will be computed automatically upon creation. No need to call this function explicitly

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resolved

project_task_pull_request_state/models/project_task.py Outdated Show resolved Hide resolved
project_task_pull_request_state/models/project_task.py Outdated Show resolved Hide resolved
@@ -17,14 +17,6 @@ class ProjectTaskState(models.Model):
readonly=False,
)

_sql_constraints = [
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if this is necessary. But I also don't understand why it doesn't work, maybe you have some idea. Now it's occured this error

@Volodiay622 Volodiay622 force-pushed the 16.0-t2959-project_task_pull_request_state-migration_from_11.0 branch from 5947b82 to af27f0b Compare December 4, 2023 02:00
Copy link

@Bearnard21 Bearnard21 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Functionality OK

@@ -0,0 +1 @@
* Cetmix <https://cetmix.com/>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please complete this section according to the latest updates in the DevMemo

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

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Applied

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd suggest going with

* `Cetmix <https://cetmix.com/>`__

  * Ivan Sokolov
  * Vladimir Kalmykov

Formatting, note the extra newline

@Volodiay622 Volodiay622 force-pushed the 16.0-t2959-project_task_pull_request_state-migration_from_11.0 branch 2 times, most recently from 801719b to 120a008 Compare December 15, 2023 21:46
Copy link
Member

@ivs-cetmix ivs-cetmix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code review LGTM

@Volodiay622 Volodiay622 force-pushed the 16.0-t2959-project_task_pull_request_state-migration_from_11.0 branch from 120a008 to 3616588 Compare December 29, 2023 18:27
@ivs-cetmix
Copy link
Member

hey @OCA/project-service-maintainers happy 2024! What a great opportunity to have one more PR merged while we are still in 2023 😄

@OCA-git-bot
Copy link
Contributor

This PR has the approved label and has been created more than 5 days ago. It should therefore be ready to merge by a maintainer (or a PSC member if the concerned addon has no declared maintainer). 🤖

Copy link
Contributor

@alexey-pelykh alexey-pelykh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR! The comments are non-blocking

@@ -0,0 +1,3 @@
# Copyright Cetmix OU 2023
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

init.py don't typically include copyright notice since there's nothing to apply copyright to.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

from odoo import fields, models


class ProjectState(models.Model):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Model name follows the filename commonly, and since this model is a well-known one there's no point in having different name.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

readonly=False,
)

def _selection_pr_state(self):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you anticipate that this could be plausibly extended in some cases? Please elaborate

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@@ -0,0 +1 @@
* Cetmix <https://cetmix.com/>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd suggest going with

* `Cetmix <https://cetmix.com/>`__

  * Ivan Sokolov
  * Vladimir Kalmykov

Formatting, note the extra newline

# Change pr_state
tasks.write({"pr_state": "closed"})

self.assertEqual(self.task_1.pr_state, "closed", "PR state must be 'closed")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess there's closing ' missing? If that message is even worth having

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

applied

from odoo import api, fields, models


class ProjectTaskState(models.Model):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
class ProjectTaskState(models.Model):
class ProjectTask(models.Model):

It would be better to follow the common naming as in https://github.com/OCA/project/pull/1189/files#r1440500916

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@leemannd, thank you for suggestion. I added this to the last commit.

@leemannd
Copy link

/ocabot merge nobump

@OCA-git-bot
Copy link
Contributor

What a great day to merge this nice PR. Let's do it!
Prepared branch 16.0-ocabot-merge-pr-1189-by-leemannd-bump-nobump, awaiting test results.

OCA-git-bot added a commit that referenced this pull request Jan 22, 2024
Signed-off-by leemannd
@OCA-git-bot
Copy link
Contributor

@leemannd The merge process could not be finalized, because command twine check odoo_addon_project_task_pull_request_state-16.0.1.0.0.2-py3-none-any.whl failed with output:

Checking 
odoo_addon_project_task_pull_request_state-16.0.1.0.0.2-py3-none-any.whl: �[31mFAILED�[0m
�[31mERROR   �[0m `long_description` has syntax errors in markup and would not be        
         rendered on PyPI.                                                      
         line 55: Warning: Enumerated list ends without a blank line; unexpected
         unindent.                                                              
�[33mWARNING �[0m `long_description_content_type` missing. defaulting to `text/x-rst`.   

@ivs-cetmix
Copy link
Member

ocabot merge nobump

Hi @leemannd could you please check what could be a reason of the merge issue?

@ivs-cetmix ivs-cetmix force-pushed the 16.0-t2959-project_task_pull_request_state-migration_from_11.0 branch 2 times, most recently from a0d4a09 to 03f3149 Compare February 4, 2024 21:26
@ivs-cetmix
Copy link
Member

Hi @leemannd I have rebase the branch, could you please try merging it again?

@OCA-git-bot
Copy link
Contributor

This PR looks fantastic, let's merge it!
Prepared branch 16.0-ocabot-merge-pr-1189-by-leemannd-bump-nobump, awaiting test results.

OCA-git-bot added a commit that referenced this pull request Feb 6, 2024
Signed-off-by leemannd
@OCA-git-bot
Copy link
Contributor

@leemannd The merge process could not be finalized, because command twine check odoo_addon_project_task_pull_request_state-16.0.1.0.0.1-py3-none-any.whl failed with output:

Checking 
odoo_addon_project_task_pull_request_state-16.0.1.0.0.1-py3-none-any.whl: �[31mFAILED�[0m
�[31mERROR   �[0m `long_description` has syntax errors in markup and would not be        
         rendered on PyPI.                                                      
         line 55: Warning: Enumerated list ends without a blank line; unexpected
         unindent.                                                              
�[33mWARNING �[0m `long_description_content_type` missing. defaulting to `text/x-rst`.   

@sbidoul
Copy link
Member

sbidoul commented Feb 6, 2024

That's a problem in the readme.

@ivs-cetmix
Copy link
Member

That's a problem in the readme.

Thank you @sbidoul ! Any hint on how this should be solved?

@sbidoul
Copy link
Member

sbidoul commented Feb 6, 2024

Warning: Enumerated list ends without a blank line; unexpected unindent.

Look for a list that does not end with a blank line.

@ivs-cetmix
Copy link
Member

Warning: Enumerated list ends without a blank line; unexpected unindent.

Look for a list that does not end with a blank line.

thank you @sbidoul @yajo let me check that!

@ivs-cetmix ivs-cetmix force-pushed the 16.0-t2959-project_task_pull_request_state-migration_from_11.0 branch from 2a44d74 to 69e67df Compare February 7, 2024 18:31
@ivs-cetmix
Copy link
Member

Ok @leemannd let's give it another try 😆

@leemannd
Copy link

/ocabot merge nobump

@OCA-git-bot
Copy link
Contributor

Hey, thanks for contributing! Proceeding to merge this for you.
Prepared branch 16.0-ocabot-merge-pr-1189-by-leemannd-bump-nobump, awaiting test results.

@OCA-git-bot OCA-git-bot merged commit b232e80 into OCA:16.0 Feb 13, 2024
7 checks passed
@OCA-git-bot
Copy link
Contributor

Congratulations, your PR was merged at 874e53a. Thanks a lot for contributing to OCA. ❤️

@ivs-cetmix ivs-cetmix deleted the 16.0-t2959-project_task_pull_request_state-migration_from_11.0 branch February 13, 2024 09:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants