Skip to content

Commit

Permalink
TA#64835 [IMP] Correct flake8 Errors
Browse files Browse the repository at this point in the history
  • Loading branch information
majouda committed Apr 17, 2024
1 parent 9e8d9d2 commit 6c941cd
Show file tree
Hide file tree
Showing 49 changed files with 120 additions and 122 deletions.
2 changes: 1 addition & 1 deletion project_enhanced/models/project.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# © 2023 Numigi (tm) and all its contributors (https://bit.ly/numigiens)
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

from odoo import fields, models, api
from odoo import fields, models


class Project(models.Model):
Expand Down
2 changes: 1 addition & 1 deletion project_enhanced/models/project_task.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# © 2023 Numigi (tm) and all its contributors (https://bit.ly/numigiens)
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

from odoo import fields, models, api
from odoo import fields, models


class ProjectTask(models.Model):
Expand Down
1 change: 0 additions & 1 deletion project_iteration/tests/test_followers_propagation.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# © 2022 Numigi (tm) and all its contributors (https://bit.ly/numigiens)
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

import pytest
from .common import ProjectIterationCase


Expand Down
1 change: 0 additions & 1 deletion project_iteration_parent_only/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
# © 2023 - Today Numigi (tm) and all its contributors (https://bit.ly/numigiens)
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

10 changes: 5 additions & 5 deletions project_material/models/project_task_material.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,8 @@ def _check_quantity_can_be_reduced(self):
if more_to_reduce_than_available:
raise ValidationError(
_(
"The quantity on the material line {line} can not be reduced to {new_quantity} "
"(it can not be lower than the delivered quantity).\n\n"
"The quantity on the material line {line} can not be reduced to "
"{new_quantity} (it can not be lower than the delivered quantity).\n\n"
"The line may not be reduced below a minimum of {minimum_qty} {uom}."
).format(
line=self.product_id.display_name,
Expand Down Expand Up @@ -288,12 +288,12 @@ def _get_total_move_qty(self):
)

def _get_first_step_moves(self):
moves = self.env["stock.move"]
_moves = self.env["stock.move"]

for moves in self._iter_procurement_moves():
for _moves in self._iter_procurement_moves():
pass

return moves
return _moves

def _cancel_moves_with_zero_quantity(self):
"""Cancel the stock moves related to this line with zero quantity.
Expand Down
2 changes: 1 addition & 1 deletion project_material/models/stock_warehouse.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright 2024 - today Numigi (tm) and all its contributors (https://bit.ly/numigiens)
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

from odoo import api, fields, models, SUPERUSER_ID, _
from odoo import api, fields, models, _


ONE_STEP_KEY = "one_step"
Expand Down
2 changes: 1 addition & 1 deletion project_milestone_enhanced/models/project_milestone.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# © 2023 - today Numigi (tm) and all its contributors (https://bit.ly/numigiens)
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

from odoo import api, models, fields
from odoo import models, fields


class ProjectMilestone(models.Model):
Expand Down
2 changes: 1 addition & 1 deletion project_milestone_enhanced/tests/test_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def test_copy_project(self):
project = self.project.copy({})
tasks = project.with_context(active_test=False).task_ids
milestone = project.milestone_ids.filtered(
lambda milestone: not "2" in milestone.name
lambda milestone: "2" not in milestone.name
)
assert tasks[0].milestone_id == milestone and tasks[1].milestone_id == milestone

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,36 +32,36 @@ def setUpClass(cls):
"project_id": cls.lot.id,
})
cls.task_a = cls.env["project.task"].create({
"name": "Task A",
"project_id": cls.lot.id,
"milestone_id": cls.milestone_a.id,
"planned_hours": 4,
"stage_id": cls.folded_stage.id,
"name": "Task A",
"project_id": cls.lot.id,
"milestone_id": cls.milestone_a.id,
"planned_hours": 4,
"stage_id": cls.folded_stage.id,
})
cls.task_b = cls.env["project.task"].create({
"name": "Task B",
"project_id": cls.lot.id,
"milestone_id": cls.milestone_b.id,
"planned_hours": 8,
"stage_id": cls.folded_stage.id,
})
"name": "Task B",
"project_id": cls.lot.id,
"milestone_id": cls.milestone_b.id,
"planned_hours": 8,
"stage_id": cls.folded_stage.id,
})
# Add timelines to created tasks
cls.timesheet_a = cls.env["account.analytic.line"].create({
"name": "Analyse",
"project_id": cls.lot.id,
"task_id": cls.task_a.id,
"unit_amount": 3,
"employee_id": 1,
"date": "2022-06-25",
})
"name": "Analyse",
"project_id": cls.lot.id,
"task_id": cls.task_a.id,
"unit_amount": 3,
"employee_id": 1,
"date": "2022-06-25",
})
cls.timesheet_b = cls.env["account.analytic.line"].create({
"name": "Conception",
"project_id": cls.lot.id,
"task_id": cls.task_b.id,
"unit_amount": 4,
"employee_id": 1,
"date": "2022-06-30",
})
"name": "Conception",
"project_id": cls.lot.id,
"task_id": cls.task_b.id,
"unit_amount": 4,
"employee_id": 1,
"date": "2022-06-30",
})
cls.report = cls.env["project.milestone.time.report"]

def test_amounts(self):
Expand Down
2 changes: 1 addition & 1 deletion project_outsourcing/models/project_task.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# © 2023 Numigi (tm) and all its contributors (https://bit.ly/numigiens)
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

from odoo import api, fields, models, _
from odoo import fields, models, _
from odoo.exceptions import ValidationError


Expand Down
1 change: 0 additions & 1 deletion project_outsourcing/models/purchase_order_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ def _prepare_account_move_line(self, move=False):
result["task_id"] = self.order_id.task_id.id
return result


@api.constrains("is_outsourcing", "product_id")
def _check_if_is_outsourcing__product_is_service(self):
outsourcing_lines = self.filtered(lambda l: l.is_outsourcing)
Expand Down
2 changes: 1 addition & 1 deletion project_outsourcing/tests/test_project_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def setUpClass(cls):
def test_outsourcing_line_ids(self):
self.task.outsourcing_line_ids.refresh()
assert self.task.outsourcing_line_ids == (
self.order.order_line | self.order_2.order_line
self.order.order_line | self.order_2.order_line
)

def test_outsourcing_po_count(self):
Expand Down
16 changes: 6 additions & 10 deletions project_outsourcing_timesheet_automation/models/project_task.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# © 2023 Numigi (tm) and all its contributors (https://bit.ly/numigiens)
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

from odoo import models, api, fields, _
from odoo import models, fields, _
from datetime import datetime


Expand All @@ -24,11 +24,11 @@ class ProjectTask(models.Model):
def _check_outsourcing_pol(self):
existing_pol = self.timesheet_ids.mapped('purchase_order_line_id')
outsourcing_pol = self.outsourcing_line_ids.filtered(
lambda pol: pol.order_id.is_outsourcing and
pol.state in ['purchase', 'done'] and
pol.partner_id.subcontracting_auto_time_entries and
pol.product_id.automate_time_entries and
pol.id not in existing_pol.ids
lambda pol: pol.order_id.is_outsourcing
and pol.state in ['purchase', 'done']
and pol.partner_id.subcontracting_auto_time_entries
and pol.product_id.automate_time_entries
and pol.id not in existing_pol.ids
)
if outsourcing_pol:
return outsourcing_pol
Expand Down Expand Up @@ -74,11 +74,7 @@ def write(self, vals):
for record in self:
if 'stage_id' in vals and self.env['project.task.type'].browse(
vals['stage_id']).create_subcontractors_time_entries:
print('====================stage name', self.env['project.task.type'].browse(
vals['stage_id']).name)
outsourcing_pol = record._check_outsourcing_pol()
print('====================outsourcing_pol',
outsourcing_pol)
if outsourcing_pol:
record._create_timesheet_line(outsourcing_pol)
return res
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# © 2023 Numigi (tm) and all its contributors (https://bit.ly/numigiens)
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

from odoo import models, api
from odoo import models


class PurchaseOrder(models.Model):
Expand Down
2 changes: 0 additions & 2 deletions project_outsourcing_timesheet_automation/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
# © 2023 Numigi (tm) and all its contributors (https://bit.ly/numigiens)
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).


Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ class TestProjectTask(OutsourcingCase):
def setUp(self):
super(TestProjectTask, self).setUp()


def test_create_timesheet_line_automatically(self):
self.task.outsourcing_line_ids.refresh()
self.task.write({"stage_id": self.stage_test.id})
Expand Down
9 changes: 6 additions & 3 deletions project_stage/models/project_stage.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,19 @@ class ProjectStage(models.Model):
active = fields.Boolean(default=True)
fold = fields.Boolean(
string='Folded in Kanban',
help='This stage is folded in the kanban view when there are no records in that stage to display.'
help="""This stage is folded in the kanban view when there are
no records in that stage to display."""
)


class ProjectWithStage(models.Model):
_inherit = 'project.project'

def compute_default_stage(self):
return self.env['project.stage'].search([('fold', '=', False)], order='sequence', limit=1).id
return self.env['project.stage'].search(
[('fold', '=', False)], order='sequence', limit=1).id

stage_id = fields.Many2one(
'project.stage', 'Stage', ondelete='restrict', index=True, default=compute_default_stage,
'project.stage', 'Stage', ondelete='restrict', index=True,
default=compute_default_stage,
tracking=True)
11 changes: 6 additions & 5 deletions project_stage_allow_timesheet/models/account_analytic_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ def _check_task_project_allow_timesheet(self):
return

error_message = _(
"You can't link a time sheet line to a task if its project's stage does not allow it. "
"(Task: {}, Project: {}, Project Stage: {})"
"You can't link a time sheet line to a task if its project's stage"
" does not allow it. (Task: {}, Project: {}, Project Stage: {})"
)
for rec in self:
task = rec.task_id
Expand All @@ -34,13 +34,14 @@ class ProjectTask(models.Model):

@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 _should_apply_constraints(self.env):
return

error_message = _(
"You cannot move a task linked to a timesheet line in a project if its stage does not allow it. "
"(Task: {}, Project: {}, Project Stage: {})"
"You cannot move a task linked to a timesheet line in a project if its stage"
" does not allow it. (Task: {}, Project: {}, Project Stage: {})"
)

for rec in self:
Expand Down
2 changes: 0 additions & 2 deletions project_stage_allow_timesheet/models/project_stage.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ class ProjectStage(models.Model):
)



class ProjectTaskType(models.Model):

_inherit = 'project.task.type'
Expand All @@ -22,4 +21,3 @@ class ProjectTaskType(models.Model):
string="Allow timesheets",
default=True,
)

5 changes: 2 additions & 3 deletions project_task_analytic_lines/models/account_analytic_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@ def _onchange_analytic_account_empty_task(self):
def _check_origin_task_and_project_match(self):
for line in self:
task_not_matching_project = (
line.origin_task_id
and line.origin_task_id.project_id.analytic_account_id
!= line.account_id
line.origin_task_id
and line.origin_task_id.project_id.analytic_account_id != line.account_id
)
if task_not_matching_project:
raise ValidationError(
Expand Down
3 changes: 1 addition & 2 deletions project_task_analytic_lines/models/account_move.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# © 2023 Numigi (tm) and all its contributors (https://bit.ly/numigiens)
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

from odoo import api, models, _
from odoo.exceptions import ValidationError
from odoo import models


class AccountMove(models.Model):
Expand Down
4 changes: 2 additions & 2 deletions project_task_analytic_lines/models/account_move_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ def _prepare_analytic_line(self):

def _check_task_matches_with_project(self):
task_not_matching_project = (
self.task_id
and self.task_id.project_id.analytic_account_id != self.analytic_account_id
self.task_id
and self.task_id.project_id.analytic_account_id != self.analytic_account_id
)
if task_not_matching_project:
raise ValidationError(
Expand Down
2 changes: 1 addition & 1 deletion project_task_analytic_lines/models/project_task.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# © 2023 Numigi (tm) and all its contributors (https://bit.ly/numigiens)
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

from odoo import api, models, _
from odoo import models, _
from odoo.exceptions import ValidationError


Expand Down
9 changes: 5 additions & 4 deletions project_task_analytic_lines/tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ def setUpClass(cls):
limit=1,
)


class InvoiceCase(AccountCase):
@classmethod
def setUpClass(cls):
Expand All @@ -78,16 +79,16 @@ def setUpClass(cls):
"name": "10% tax",
"amount_type": "percent",
"amount": 0.10,
#"account_id": cls.tax_account.id,
# "account_id": cls.tax_account.id,
}
)

cls.invoice = cls.env["account.move"].create(
{
"partner_id": cls.partner.id,
#"project_id": cls.project.id,
# "project_id": cls.project.id,
"move_type": "in_invoice",
#"account_id": cls.payable_account.id,
# "account_id": cls.payable_account.id,
"invoice_line_ids": [(0, 0, cls._get_invoice_line_vals())],
}
)
Expand All @@ -97,7 +98,7 @@ def _get_invoice_line_vals(cls, **kwargs):
defaults = {
"name": "/",
"quantity": 1,
#"uom_id": cls.env.ref("uom.product_uom_unit").id,
# "uom_id": cls.env.ref("uom.product_uom_unit").id,
"price_unit": 100,
"analytic_account_id": cls.analytic_account.id,
"task_id": cls.task.id,
Expand Down
Loading

0 comments on commit 6c941cd

Please sign in to comment.