Skip to content

Commit

Permalink
[IMP] [16.0] pre-commit : add black (#448)
Browse files Browse the repository at this point in the history
  • Loading branch information
rivo2302 authored Nov 19, 2024
1 parent acf3253 commit ec7b6c0
Show file tree
Hide file tree
Showing 10 changed files with 18 additions and 16 deletions.
4 changes: 4 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ default_language_version:
python: python3
node: "14.13.0"
repos:
- repo: https://github.com/psf/black
rev: 22.8.0
hooks:
- id: black
- repo: https://github.com/PyCQA/flake8
rev: 3.8.3
hooks:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@


class TestDefaultTaskStage(SavepointCase):

@classmethod
def setUpClass(cls):
super().setUpClass()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class AccountAnalyticLine(models.Model):
def _should_apply_constraints(self, env):
def _is_testing():
return getattr(threading.current_thread(), "testing", False)

return not _is_testing() or env.context.get(
"enable_project_stage_allow_timesheet_constraint"
)
Expand Down
10 changes: 6 additions & 4 deletions project_stage_allow_timesheet/models/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@

class Project(models.Model):

_inherit = 'project.project'
_inherit = "project.project"

@api.depends('stage_id', 'stage_id.allow_timesheet')
@api.depends("stage_id", "stage_id.allow_timesheet")
def _compute_allow_timesheet(self):
for record in self:
record.allow_timesheets = record.stage_id.allow_timesheet

allow_timesheets = fields.Boolean(
readonly=True, compute="_compute_allow_timesheet", store=True,
help="Depends if the project stage allows timesheet."
readonly=True,
compute="_compute_allow_timesheet",
store=True,
help="Depends if the project stage allows timesheet.",
)
2 changes: 1 addition & 1 deletion project_stage_allow_timesheet/models/project_stage.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@


class ProjectStage(models.Model):
_inherit = 'project.project.stage'
_inherit = "project.project.stage"

allow_timesheet = fields.Boolean(
default=True,
Expand Down
6 changes: 3 additions & 3 deletions project_stage_allow_timesheet/models/project_task.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

# Copyright 2024 Numigi (tm) and all its contributors (https://bit.ly/numigiens)
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

Expand All @@ -13,14 +12,15 @@ class ProjectTask(models.Model):
def _should_apply_constraints(self, env):
def _is_testing():
return getattr(threading.current_thread(), "testing", False)

return not _is_testing() or env.context.get(
"enable_project_stage_allow_timesheet_constraint"
)

@api.constrains("project_id")
def _check_project_move_allow_timesheet(self):
""" Check if a line is moved to another project,
the target project must allow time sheet """
"""Check if a line is moved to another project,
the target project must allow time sheet"""
if not self._should_apply_constraints(self.env):
return

Expand Down
2 changes: 1 addition & 1 deletion project_stage_allow_timesheet/models/project_task_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class ProjectTaskType(models.Model):

_inherit = 'project.task.type'
_inherit = "project.task.type"

allow_timesheet = fields.Boolean(
string="Allow timesheets",
Expand Down
6 changes: 2 additions & 4 deletions project_stage_allow_timesheet/tests/test_project_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ def setUpClass(cls):
context = dict(
cls.env.context, enable_project_stage_allow_timesheet_constraint=True
)
cls.employee = cls.env["hr.employee"].create(
{"name": "Employee"}
)
cls.employee = cls.env["hr.employee"].create({"name": "Employee"})
cls.env = cls.env(context=context)
cls.project_stage_timesheet = cls.env["project.project.stage"].create(
{"name": "project_stage", "allow_timesheet": True}
Expand Down Expand Up @@ -42,7 +40,7 @@ def setUpClass(cls):
"name": "line",
"task_id": cls.task_timesheet.id,
"project_id": cls.project_timesheet.id,
"employee_id": cls.employee.id
"employee_id": cls.employee.id,
}
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@


class TestFullTextSearchParamKey(common.SavepointCase):

@classmethod
def setUpClass(cls):
super().setUpClass()
Expand Down
1 change: 0 additions & 1 deletion project_task_full_text_search/tests/test_project_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@


class TestTaskFullTextSearch(common.SavepointCase):

@classmethod
def setUpClass(cls):
super().setUpClass()
Expand Down

0 comments on commit ec7b6c0

Please sign in to comment.