Skip to content
Extraits de code Groupes Projets
Valider 69faf132 rédigé par Benjamin - Le Filament's avatar Benjamin - Le Filament
Parcourir les fichiers

[CLEAN] pre-commit

parent 30ba296e
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -6,6 +6,8 @@ exclude: | ...@@ -6,6 +6,8 @@ exclude: |
^setup/|/static/description/index\.html$| ^setup/|/static/description/index\.html$|
# We don't want to mess with tool-generated files # We don't want to mess with tool-generated files
.svg$|/tests/([^/]+/)?cassettes/|^.copier-answers.yml$|^.github/| .svg$|/tests/([^/]+/)?cassettes/|^.copier-answers.yml$|^.github/|
# Maybe reactivate this when all README files include prettier ignore tags?
^README\.md$|
# Library files can have extraneous formatting (even minimized) # Library files can have extraneous formatting (even minimized)
/static/(src/)?lib/| /static/(src/)?lib/|
# Repos using Sphinx to generate docs don't need prettying # Repos using Sphinx to generate docs don't need prettying
...@@ -25,8 +27,13 @@ repos: ...@@ -25,8 +27,13 @@ repos:
entry: found forbidden files; remove them entry: found forbidden files; remove them
language: fail language: fail
files: "\\.rej$" files: "\\.rej$"
- id: en-po-files
name: en.po files cannot exist
entry: found a en.po file
language: fail
files: '[a-zA-Z0-9_]*/i18n/en\.po$'
- repo: https://github.com/oca/maintainer-tools - repo: https://github.com/oca/maintainer-tools
rev: 7d8a9f9ad73db0976fb03cbee43d953bc29b89e9 rev: ab1d7f6
hooks: hooks:
# update the NOT INSTALLABLE ADDONS section above # update the NOT INSTALLABLE ADDONS section above
- id: oca-update-pre-commit-excluded-addons - id: oca-update-pre-commit-excluded-addons
...@@ -48,7 +55,7 @@ repos: ...@@ -48,7 +55,7 @@ repos:
hooks: hooks:
- id: black - id: black
- repo: https://github.com/pre-commit/mirrors-prettier - repo: https://github.com/pre-commit/mirrors-prettier
rev: v2.6.2 rev: v2.1.2
hooks: hooks:
- id: prettier - id: prettier
name: prettier (with plugin-xml) name: prettier (with plugin-xml)
...@@ -59,7 +66,7 @@ repos: ...@@ -59,7 +66,7 @@ repos:
- --plugin=@prettier/plugin-xml - --plugin=@prettier/plugin-xml
files: \.(css|htm|html|js|json|jsx|less|md|scss|toml|ts|xml|yaml|yml)$ files: \.(css|htm|html|js|json|jsx|less|md|scss|toml|ts|xml|yaml|yml)$
- repo: https://github.com/pre-commit/mirrors-eslint - repo: https://github.com/pre-commit/mirrors-eslint
rev: v8.15.0 rev: v7.8.1
hooks: hooks:
- id: eslint - id: eslint
verbose: true verbose: true
...@@ -67,7 +74,7 @@ repos: ...@@ -67,7 +74,7 @@ repos:
- --color - --color
- --fix - --fix
- repo: https://github.com/pre-commit/pre-commit-hooks - repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.2.0 rev: v3.2.0
hooks: hooks:
- id: trailing-whitespace - id: trailing-whitespace
# exclude autogenerated files # exclude autogenerated files
...@@ -89,37 +96,33 @@ repos: ...@@ -89,37 +96,33 @@ repos:
- id: mixed-line-ending - id: mixed-line-ending
args: ["--fix=lf"] args: ["--fix=lf"]
- repo: https://github.com/asottile/pyupgrade - repo: https://github.com/asottile/pyupgrade
rev: v2.32.1 rev: v2.7.2
hooks: hooks:
- id: pyupgrade - id: pyupgrade
args: ["--keep-percent-format"] args: ["--keep-percent-format"]
- repo: https://github.com/PyCQA/isort - repo: https://github.com/PyCQA/isort
rev: 5.10.1 rev: 5.12.0
hooks: hooks:
- id: isort - id: isort
name: isort except __init__.py name: isort except __init__.py
args: args:
- --settings=. - --settings=.
exclude: /__init__\.py$ exclude: /__init__\.py$
- repo: https://gitlab.com/PyCQA/flake8 - repo: https://github.com/PyCQA/flake8
rev: 3.9.2 rev: 3.8.3
hooks: hooks:
- id: flake8 - id: flake8
name: flake8 name: flake8
additional_dependencies: ["flake8-bugbear==20.1.4"] additional_dependencies: ["flake8-bugbear==20.1.4"]
- repo: https://github.com/PyCQA/pylint - repo: https://github.com/OCA/pylint-odoo
rev: v2.11.1 rev: 7.0.2
hooks: hooks:
- id: pylint - id: pylint_odoo
name: pylint with optional checks name: pylint with optional checks
args: args:
- --rcfile=.pylintrc - --rcfile=.pylintrc
- --exit-zero - --exit-zero
verbose: true verbose: true
additional_dependencies: &pylint_deps - id: pylint_odoo
- pylint-odoo==5.0.5
- id: pylint
name: pylint with mandatory checks
args: args:
- --rcfile=.pylintrc-mandatory - --rcfile=.pylintrc-mandatory
additional_dependencies: *pylint_deps
# © 2019 Le Filament (<http://www.le-filament.com>) # © 2019 Le Filament (<http://www.le-filament.com>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import models from . import models, wizard
from . import wizard
...@@ -128,49 +128,64 @@ class ScopHrTimesheetSheet(models.Model): ...@@ -128,49 +128,64 @@ class ScopHrTimesheetSheet(models.Model):
# Retourne les lignes de la Fdt avec les totaux par projet # Retourne les lignes de la Fdt avec les totaux par projet
# ------------------------------------------------------ # ------------------------------------------------------
def _to_duration(self, infloat): def _to_duration(self, infloat):
return '{0:02.0f}:{1:02.0f}'.format(*divmod(infloat * 60, 60)) return "{:02.0f}:{:02.0f}".format(*divmod(infloat * 60, 60))
def _get_timesheet_line_act(self): def _get_timesheet_line_act(self):
for sheet in self: for sheet in self:
lines = sheet.timesheet_line_ids.sorted(key=lambda b: (b.project_id.name, b.date)) lines = sheet.timesheet_line_ids.sorted(
key=lambda b: (b.project_id.name, b.date)
)
rows = [] rows = []
last_project = False last_project = False
tot_project = 0 tot_project = 0
for line in lines: for line in lines:
# On insère un total intermédiaire # On insère un total intermédiaire
if last_project != line.project_id.name and tot_project != 0: if last_project != line.project_id.name and tot_project != 0:
rows.append({ rows.append(
'total': 1, {
'name': False, "total": 1,
'partner': False, "name": False,
'project': False, "partner": False,
'date': False, "project": False,
'ur_financial_system': 'Total ' + last_project + ' : ' + self._to_duration(tot_project), "date": False,
'unit_amount': False, "ur_financial_system": "Total "
}) + last_project
+ " : "
+ self._to_duration(tot_project),
"unit_amount": False,
}
)
tot_project = 0 tot_project = 0
# On insère la ligne lue # On insère la ligne lue
rows.append({ rows.append(
'total': 0, {
'name': line.name, "total": 0,
'partner': line.partner_id.name, "name": line.name,
'project': line.project_id.name, "partner": line.partner_id.name,
'date': line.date, "project": line.project_id.name,
'ur_financial_system': line.ur_financial_system_id.name, "date": line.date,
'unit_amount': self._to_duration(line.unit_amount), "ur_financial_system": line.ur_financial_system_id.name,
}) "unit_amount": self._to_duration(line.unit_amount),
}
)
last_project = line.project_id.name last_project = line.project_id.name
tot_project = tot_project + line.unit_amount tot_project = tot_project + line.unit_amount
# On insère le dernier total # On insère le dernier total
rows.append({ rows.append(
'total': 1, {
'name': False, "total": 1,
'partner': False, "name": False,
'project': False, "partner": False,
'date': False, "project": False,
'ur_financial_system': 'Total ' + last_project + ' : ' + self._to_duration(tot_project), "date": False,
'unit_amount': False, "ur_financial_system": "Total "
}) + last_project
+ " : "
+ self._to_duration(tot_project),
"unit_amount": False,
}
)
return rows return rows
...@@ -5,7 +5,9 @@ ...@@ -5,7 +5,9 @@
<t t-call="web.external_layout"> <t t-call="web.external_layout">
<div class="page"> <div class="page">
<h2> <h2>
Feuille de Temps par activité <t t-if="o.state == 'draft'"> - Brouillon</t> Feuille de Temps par activité <t
t-if="o.state == 'draft'"
> - Brouillon</t>
</h2> </h2>
<h3> <h3>
<t t-esc="o.name" /> <t t-esc="o.name" />
...@@ -50,10 +52,7 @@ ...@@ -50,10 +52,7 @@
</tr> </tr>
</thead> </thead>
<tbody class="invoice_tbody"> <tbody class="invoice_tbody">
<t <t t-foreach="o._get_timesheet_line_act()" t-as="line">
t-foreach="o._get_timesheet_line_act()"
t-as="line"
>
<tr> <tr>
<td><span><t t-esc="line['project']" /></span></td> <td><span><t t-esc="line['project']" /></span></td>
<td><span><t t-esc="line['date']" /></span></td> <td><span><t t-esc="line['date']" /></span></td>
...@@ -126,8 +125,12 @@ ...@@ -126,8 +125,12 @@
<field name="name">CG Scop - Feuille de Temps par activité</field> <field name="name">CG Scop - Feuille de Temps par activité</field>
<field name="model">cgscop.timesheet.sheet</field> <field name="model">cgscop.timesheet.sheet</field>
<field name="report_type">qweb-pdf</field> <field name="report_type">qweb-pdf</field>
<field name="report_name">cgscop_timesheet.report_timesheet_sheet_act</field> <field
<field name="report_file">cgscop_timesheet.report_timesheet_sheet_act</field> name="report_name"
>cgscop_timesheet.report_timesheet_sheet_act</field>
<field
name="report_file"
>cgscop_timesheet.report_timesheet_sheet_act</field>
<field name="paperformat_id" ref="cgscop_paperformat_a4_landscape" /> <field name="paperformat_id" ref="cgscop_paperformat_a4_landscape" />
</record> </record>
......
...@@ -3,4 +3,3 @@ ...@@ -3,4 +3,3 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import cgscop_timesheet_print_wizard from . import cgscop_timesheet_print_wizard
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
# © 2020 Confédération Générale des Scop (<https://www.les-scop.coop>) # © 2020 Confédération Générale des Scop (<https://www.les-scop.coop>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import _, api, exceptions, fields, models from odoo import api, fields, models
class CgscopTimesheetPrintWizard(models.TransientModel): class CgscopTimesheetPrintWizard(models.TransientModel):
...@@ -32,9 +32,9 @@ class CgscopTimesheetPrintWizard(models.TransientModel): ...@@ -32,9 +32,9 @@ class CgscopTimesheetPrintWizard(models.TransientModel):
def valid_wizard(self): def valid_wizard(self):
report_name = "cgscop_timesheet.cgscop_timesheet_sheet_report" report_name = "cgscop_timesheet.cgscop_timesheet_sheet_report"
if self.print_type == '0': if self.print_type == "0":
report_name = "cgscop_timesheet.cgscop_timesheet_sheet_report" report_name = "cgscop_timesheet.cgscop_timesheet_sheet_report"
elif self.print_type == '1': elif self.print_type == "1":
report_name = "cgscop_timesheet.cgscop_timesheet_sheet_report_act" report_name = "cgscop_timesheet.cgscop_timesheet_sheet_report_act"
return self.env.ref(report_name).report_action(self.timesheet_id) return self.env.ref(report_name).report_action(self.timesheet_id)
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter