diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4acca684ec8c5cda7b3ecd21b9e568ab03d57e8c..3efb4d9157dc36d84e372eec5fc21e7f4a417a58 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -12,11 +12,15 @@ exclude: | /static/(src/)?lib/| # Repos using Sphinx to generate docs don't need prettying ^docs/_templates/.*\.html$| + # Don't bother non-technical authors with formatting issues in docs + readme/.*\.(rst|md)$| + # Ignore build and dist directories in addons + /build/|/dist/| # You don't usually want a bot to modify your legal texts (LICENSE.*|COPYING.*) default_language_version: python: python3 - node: "14.13.0" + node: "16.17.0" repos: - repo: local hooks: @@ -33,40 +37,38 @@ repos: language: fail files: '[a-zA-Z0-9_]*/i18n/en\.po$' - repo: https://github.com/oca/maintainer-tools - rev: ab1d7f6 + rev: f71041f22b8cd68cf7c77b73a14ca8d8cd190a60 hooks: # update the NOT INSTALLABLE ADDONS section above - id: oca-update-pre-commit-excluded-addons - id: oca-fix-manifest-website args: ["https://le-filament.com"] - - repo: https://github.com/myint/autoflake - rev: v1.4 - hooks: - - id: autoflake + - id: oca-gen-addon-readme args: - - --expand-star-imports - - --ignore-init-module-imports - - --in-place - - --remove-all-unused-imports - - --remove-duplicate-keys - - --remove-unused-variables - - repo: https://github.com/psf/black - rev: 22.3.0 + - --addons-dir=. + - --branch=16.0 + - --org-name=lefilament + - --repo-name=template_module + - --if-source-changed + - --keep-source-digest + - repo: https://github.com/OCA/odoo-pre-commit-hooks + rev: v0.0.25 hooks: - - id: black + - id: oca-checks-odoo-module + - id: oca-checks-po - repo: https://github.com/pre-commit/mirrors-prettier - rev: v2.1.2 + rev: v2.7.1 hooks: - id: prettier name: prettier (with plugin-xml) additional_dependencies: - - "prettier@2.1.2" - - "@prettier/plugin-xml@0.12.0" + - "prettier@2.7.1" + - "@prettier/plugin-xml@2.2.0" args: - --plugin=@prettier/plugin-xml files: \.(css|htm|html|js|json|jsx|less|md|scss|toml|ts|xml|yaml|yml)$ - repo: https://github.com/pre-commit/mirrors-eslint - rev: v7.8.1 + rev: v8.24.0 hooks: - id: eslint verbose: true @@ -74,7 +76,7 @@ repos: - --color - --fix - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v3.2.0 + rev: v4.3.0 hooks: - id: trailing-whitespace # exclude autogenerated files @@ -95,27 +97,14 @@ repos: - id: check-xml - id: mixed-line-ending args: ["--fix=lf"] - - repo: https://github.com/asottile/pyupgrade - rev: v2.7.2 - hooks: - - id: pyupgrade - args: ["--keep-percent-format"] - - repo: https://github.com/PyCQA/isort - rev: 5.12.0 - hooks: - - id: isort - name: isort except __init__.py - args: - - --settings=. - exclude: /__init__\.py$ - - repo: https://github.com/PyCQA/flake8 - rev: 3.8.3 + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.1.3 hooks: - - id: flake8 - name: flake8 - additional_dependencies: ["flake8-bugbear==20.1.4"] + - id: ruff + args: [--fix, --exit-non-zero-on-fix] + - id: ruff-format - repo: https://github.com/OCA/pylint-odoo - rev: 7.0.2 + rev: v8.0.19 hooks: - id: pylint_odoo name: pylint with optional checks diff --git a/controllers/main.py b/controllers/main.py index b33e54c9f7c72efd82458385d66d4f4b9655809b..8b2cf3d354da892f2e6347f9010b3943d65e9433 100644 --- a/controllers/main.py +++ b/controllers/main.py @@ -2,10 +2,10 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). from odoo import http -from odoo.addons.oacc_portal.controllers.main import \ - CustomerPortal as CustomerPortal from odoo.http import request +from odoo.addons.oacc_portal.controllers.main import CustomerPortal as CustomerPortal + class CustomerPortal(CustomerPortal): def _get_data_date(self, is_data_cdc, operation=None): @@ -68,7 +68,7 @@ class CustomerPortal(CustomerPortal): self._get_data_date(render_values.get("isDataCdc"), operation) ) - partner_ids = operation.acc_delivery_ids.mapped("partner_id").sorted( + partner_ids = operation.acc_delivery_period_ids.mapped("partner_id").sorted( key=lambda p: p.name ) render_values.update( @@ -100,7 +100,7 @@ class CustomerPortal(CustomerPortal): self._get_data_date(render_values.get("isDataCdc"), operation) ) - partner_ids = operation.acc_injection_ids.mapped("partner_id").sorted( + partner_ids = operation.acc_injection_period_ids.mapped("partner_id").sorted( key=lambda p: p.name ) render_values.update( diff --git a/models/acc_operation.py b/models/acc_operation.py index 6bdaba5a791a6e862041bcf39dd70e7a627f32b0..ab0413f3101cdcf0879ce7f7ce54ce07c4346e4c 100644 --- a/models/acc_operation.py +++ b/models/acc_operation.py @@ -44,21 +44,21 @@ class AccOperation(models.Model): values = {} last_record = self.get_last_cdc_record() - date_day_start, date_day_end = self.get_last_day("day", last_record) + date_day_start, date_day_end = self.get_interval("day", last_record) date_day_start = date_day_start.strftime("%d/%m/%Y") date_day_end = date_day_end.strftime("%d/%m/%Y") - date_week_start, date_week_end = self.get_last_day("week", last_record) + date_week_start, date_week_end = self.get_interval("week", last_record) date_week_start = date_week_start.strftime("%d/%m/%Y") date_week_end = date_week_end.strftime("%d/%m/%Y") - date_month_start, date_month_end = self.get_last_day("month", last_record) + date_month_start, date_month_end = self.get_interval("month", last_record) date_month_start = date_month_start.strftime("%d/%m/%Y") date_month_end = date_month_end.strftime("%d/%m/%Y") - date_year_start, date_year_end = self.get_last_day("year", last_record) + date_year_start, date_year_end = self.get_interval("year", last_record) date_year_start = date_year_start.strftime("%d/%m/%Y") date_year_end = date_year_end.strftime("%d/%m/%Y") @@ -75,12 +75,3 @@ class AccOperation(models.Model): } return values - - def get_date_min_max(self): - self.ensure_one() - last_record = self.get_last_cdc_record() - date_deb, date_max = self.get_last_day("day", last_record) - date_max = date_max.strftime("%d/%m/%Y") - date_min = self.date_start_contract.strftime("%d/%m/%Y") - vals = {"date_min": date_min, "date_max": date_max} - return vals diff --git a/templates/operation_templates_page.xml b/templates/operation_templates_page.xml index c20674acf61b9ab31c316e2be81fb26059f61b7b..b7c0b9bd9e45bb32bba1745e5877b5c75eddadb8 100644 --- a/templates/operation_templates_page.xml +++ b/templates/operation_templates_page.xml @@ -15,26 +15,18 @@ </div> <div class="row bg-white pt-3 pb-3 text-center"> <div class="col-12 col-lg-6 p-3"> - <h2 class="sticky-top bg-white py-2">La Consommation</h2> - <t - t-call="oacc_portal_overview_cdc.profil_conso" - /> - <t - t-call="oacc_portal_overview_cdc.bilan_conso" - /> - <t - t-call="oacc_portal_overview_cdc.cdc_conso" - /> + <h2 + class="sticky-top bg-white py-2" + >La Consommation</h2> + <t t-call="oacc_portal_overview_cdc.profil_conso" /> + <t t-call="oacc_portal_overview_cdc.bilan_conso" /> + <t t-call="oacc_portal_overview_cdc.cdc_conso" /> </div> <div class="col-12 col-lg-6 p-3"> <h2 class="sticky-top bg-white py-2">La Production</h2> - <t - t-call="oacc_portal_overview_cdc.profil_prod" - /> - <t - t-call="oacc_portal_overview_cdc.bilan_prod" - /> + <t t-call="oacc_portal_overview_cdc.profil_prod" /> + <t t-call="oacc_portal_overview_cdc.bilan_prod" /> <t t-call="oacc_portal_overview_cdc.cdc_prod" /> </div> @@ -53,25 +45,17 @@ t-att-data-id="operation.id" > <div class="row"> - <t - t-call="oacc_portal_overview_cdc.nav_button" - /> + <t t-call="oacc_portal_overview_cdc.nav_button" /> </div> <div class="row mb32 bg-white op-detail"> <div class="col-12 col-lg-6 p-3"> - <t - t-call="oacc_portal_overview_cdc.profil_conso" - /> + <t t-call="oacc_portal_overview_cdc.profil_conso" /> </div> <div class="col-12 col-lg-6 p-3"> - <t - t-call="oacc_portal_overview_cdc.bilan_conso" - /> + <t t-call="oacc_portal_overview_cdc.bilan_conso" /> </div> <div class="col-12 p-3"> - <t - t-call="oacc_portal_overview_cdc.cdc_conso" - /> + <t t-call="oacc_portal_overview_cdc.cdc_conso" /> </div> </div> </div> @@ -88,26 +72,18 @@ t-att-data-id="operation.id" > <div class="row"> - <t - t-call="oacc_portal_overview_cdc.nav_button" - /> + <t t-call="oacc_portal_overview_cdc.nav_button" /> </div> <div class="row mb32 bg-white op-detail"> <div class="col-12 col-lg-6 p-3"> - <t - t-call="oacc_portal_overview_cdc.profil_prod" - /> + <t t-call="oacc_portal_overview_cdc.profil_prod" /> </div> <div class="col-12 col-lg-6 p-3"> - <t - t-call="oacc_portal_overview_cdc.bilan_prod" - /> + <t t-call="oacc_portal_overview_cdc.bilan_prod" /> </div> <div class="col-12 p-3"> - <t - t-call="oacc_portal_overview_cdc.cdc_prod" - /> + <t t-call="oacc_portal_overview_cdc.cdc_prod" /> </div> </div> </div> @@ -123,7 +99,9 @@ <t t-elif="type_data == 'prod' and len(partners) > 1"> <h3 class="title_cdc mt-2">Production globale</h3> </t> - <t t-elif="type_data in ('cons', 'prod') and len(partners) == 1"> + <t + t-elif="type_data in ('cons', 'prod') and len(partners) == 1" + > <h3 class="title_cdc mt-2"> <t t-out="partners[0].sudo().name" /> </h3> @@ -137,7 +115,9 @@ </div> <div class="col-10 col-xl-5"> <!-- Buttons period --> - <div class="btn-period-group d-flex justify-content-evenly flex-wrap"> + <div + class="btn-period-group d-flex justify-content-evenly flex-wrap" + > <button t-att-value="{'first_day': data_values['date_day_start'] or '', 'last_day': data_values['date_day_end' or '']}" name="day" @@ -195,24 +175,36 @@ <button id="previous-period" class="btn btn-light"> <i class="fa fa-angle-double-left" /> </button> - <input type="text" name="daterange" class="form-control text-center" /> + <input + type="text" + name="daterange" + class="form-control text-center" + /> <button id="next-period" class="btn btn-light"> <i class="fa fa-angle-double-right" /> </button> </div> </div> </div> - <div class="col-2 col-xl-1 align-self-center mt-4 mt-lg-0" t-if="partners"> + <div + class="col-2 col-xl-1 align-self-center mt-4 mt-lg-0" + t-if="partners" + > PRM ou contact </div> - <div class="col-10 col-xl-5 align-self-center mt-4 mt-lg-0" t-if="partners"> + <div + class="col-10 col-xl-5 align-self-center mt-4 mt-lg-0" + t-if="partners" + > <div class="prm-selection align-items-center d-flex"> <select class="form-select" aria-label="prm-selection" name="endpoint" > - <t t-if="len(partners) > 1 and type_data in ['cons', 'prod']"> + <t + t-if="len(partners) > 1 and type_data in ['cons', 'prod']" + > <option value="all" t-att-data-name="'Consommation globale' if type_data == 'cons' else 'Production globale'" @@ -229,20 +221,26 @@ <t t-set="prm_ids" t-if="type_data == 'cons'" - t-value="operation.acc_delivery_ids.filtered(lambda r: r.partner_id == p)" + t-value="operation.acc_delivery_period_ids.filtered(lambda r: r.partner_id == p).mapped('acc_counter_id')" /> <t t-set="prm_ids" t-if="type_data == 'prod'" - t-value="operation.acc_injection_ids.filtered(lambda r: r.partner_id == p)" + t-value="operation.acc_injection_period_ids.filtered(lambda r: r.partner_id == p).mapped('acc_counter_id')" /> - <t t-foreach="prm_ids" t-as="prm" class="nav-item"> + <t + t-foreach="prm_ids" + t-as="prm" + class="nav-item" + > <option t-att-value="prm.id" t-att-data-name="'PRM n°' + prm.name" t-att-data-prm-id="prm.id" > -    - <t t-out="(prm.street + ' - ' + prm.name) if prm.street else prm.name" /> +    - <t + t-out="(prm.street + ' - ' + prm.name) if prm.street else prm.name" + /> </option> </t> </t> @@ -250,7 +248,7 @@ </div> </div> </div> - <hr/> + <hr /> </div> </template> @@ -258,8 +256,8 @@ <template id="profil_conso"> <div class="text-center mb-4 p-3 shadow op-graph"> <h3>Profil</h3> - <p - >Cliquez sur les termes « AutoConso » ou « AlloConso »<br/>pour faire apparaître ou disparaître les données correspondantes.</p> + <p>Cliquez sur les termes « AutoConso » ou « AlloConso »<br + />pour faire apparaître ou disparaître les données correspondantes.</p> <div class="chart-container"> <canvas id="histo_chart_conso" @@ -288,7 +286,8 @@ <div class="js_curv_line text-center p-3 shadow op-graph"> <h3>Courbe de charge</h3> <p - >Cliquez sur les termes « Conso », « Production solaire » ou « AutoConso »<br/>pour faire apparaître ou disparaître les courbes correspondantes.</p> + >Cliquez sur les termes « Conso », « Production solaire » ou « AutoConso »<br + />pour faire apparaître ou disparaître les courbes correspondantes.</p> <div class="chart-container"> <canvas id="line_chart_conso" @@ -302,8 +301,8 @@ <template id="profil_prod"> <div class="text-center mb-4 p-3 shadow op-graph"> <h3>Profil</h3> - <p - >Cliquez sur les termes « AutoConso » ou « Surplus »<br/>pour faire apparaître ou disparaître les données correspondantes.</p> + <p>Cliquez sur les termes « AutoConso » ou « Surplus »<br + />pour faire apparaître ou disparaître les données correspondantes.</p> <div class="chart-container"> <canvas id="histo_chart_prod" @@ -331,8 +330,8 @@ <template id="cdc_prod"> <div class="js_curv_line text-center p-3 shadow op-graph"> <h3>Courbe de charge</h3> - <p - >Cliquez sur les termes « AutoConso » ou « Surplus »<br/>pour faire apparaître ou disparaître les courbes correspondantes.</p> + <p>Cliquez sur les termes « AutoConso » ou « Surplus »<br + />pour faire apparaître ou disparaître les courbes correspondantes.</p> <div class="chart-container"> <canvas id="line_chart_prod"