From 41ad0b1155789a3fda4924885f1a889861c5e93f Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Thu, 6 Jun 2024 22:17:49 +0200 Subject: [PATCH] l10n_fr_das2: move declaration threshold to pyfrdas2 Move the partner declaration threashold to the pyfrdas2 lib. This configuration parameter should never be changed by the use anyway. With the encryption that change every year, we will release every year a new lib, so we can change the result of get_partner_declaration_threshold() if the tax administration changes the amount. --- l10n_fr_das2/__init__.py | 1 - l10n_fr_das2/__manifest__.py | 3 +-- l10n_fr_das2/models/__init__.py | 1 - l10n_fr_das2/models/l10n_fr_das2.py | 18 ++++++------- l10n_fr_das2/models/res_company.py | 21 --------------- l10n_fr_das2/views/res_config_settings.xml | 29 --------------------- l10n_fr_das2/wizards/__init__.py | 1 - l10n_fr_das2/wizards/res_config_settings.py | 13 --------- requirements.txt | 2 +- 9 files changed, 10 insertions(+), 79 deletions(-) delete mode 100644 l10n_fr_das2/models/res_company.py delete mode 100644 l10n_fr_das2/views/res_config_settings.xml delete mode 100644 l10n_fr_das2/wizards/__init__.py delete mode 100644 l10n_fr_das2/wizards/res_config_settings.py diff --git a/l10n_fr_das2/__init__.py b/l10n_fr_das2/__init__.py index aee8895e7..0650744f6 100644 --- a/l10n_fr_das2/__init__.py +++ b/l10n_fr_das2/__init__.py @@ -1,2 +1 @@ from . import models -from . import wizards diff --git a/l10n_fr_das2/__manifest__.py b/l10n_fr_das2/__manifest__.py index 7f1dbc5c9..210171694 100644 --- a/l10n_fr_das2/__manifest__.py +++ b/l10n_fr_das2/__manifest__.py @@ -16,14 +16,13 @@ "l10n_fr_cog", ], "external_dependencies": { - "python": ["stdnum", "pyfrdas2"], + "python": ["stdnum", "pyfrdas2>=0.4"], }, "data": [ "security/das2_security.xml", "security/ir.model.access.csv", "views/l10n_fr_das2.xml", "views/res_partner.xml", - "views/res_config_settings.xml", ], "demo": ["demo/demo.xml"], "installable": True, diff --git a/l10n_fr_das2/models/__init__.py b/l10n_fr_das2/models/__init__.py index cb3d3203f..b203fb1b8 100644 --- a/l10n_fr_das2/models/__init__.py +++ b/l10n_fr_das2/models/__init__.py @@ -1,3 +1,2 @@ from . import l10n_fr_das2 from . import res_partner -from . import res_company diff --git a/l10n_fr_das2/models/l10n_fr_das2.py b/l10n_fr_das2/models/l10n_fr_das2.py index eedcf7b79..525ba6af9 100644 --- a/l10n_fr_das2/models/l10n_fr_das2.py +++ b/l10n_fr_das2/models/l10n_fr_das2.py @@ -7,7 +7,11 @@ from datetime import datetime from markupsafe import Markup -from pyfrdas2 import format_street_block, generate_file +from pyfrdas2 import ( + format_street_block, + generate_file, + get_partner_declaration_threshold, +) from stdnum.fr.siret import is_valid from odoo import _, api, fields, models, tools @@ -240,15 +244,9 @@ def generate_lines(self): currency=company.currency_id.name, ) ) - if company.fr_das2_partner_declare_threshold <= 0: - raise UserError( - _( - "The DAS2 partner declaration threshold is not set on " - "company '%s'." - ) - % company.display_name - ) - self.partner_declare_threshold = company.fr_das2_partner_declare_threshold + self.write( + {"partner_declare_threshold": get_partner_declaration_threshold(self.year)} + ) das2_partners = self.env["res.partner"].search( [("parent_id", "=", False), ("fr_das2_type", "!=", False)] ) diff --git a/l10n_fr_das2/models/res_company.py b/l10n_fr_das2/models/res_company.py deleted file mode 100644 index dc55313aa..000000000 --- a/l10n_fr_das2/models/res_company.py +++ /dev/null @@ -1,21 +0,0 @@ -# Copyright 2020-2021 Akretion France (http://www.akretion.com/) -# @author: Alexis de Lattre -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). - -from odoo import fields, models - - -class ResCompany(models.Model): - _inherit = "res.company" - - fr_das2_partner_declare_threshold = fields.Integer( - string="DAS2 Partner Declaration Threshold", default=1200 - ) - - _sql_constraints = [ - ( - "fr_das2_partner_declare_threshold_positive", - "CHECK(fr_das2_partner_declare_threshold >= 0)", - "The DAS2 partner declaration threshold must be positive!", - ) - ] diff --git a/l10n_fr_das2/views/res_config_settings.xml b/l10n_fr_das2/views/res_config_settings.xml deleted file mode 100644 index 98635392a..000000000 --- a/l10n_fr_das2/views/res_config_settings.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - das2.res.config.settings.form - res.config.settings - - - - - - - - - - - - - - diff --git a/l10n_fr_das2/wizards/__init__.py b/l10n_fr_das2/wizards/__init__.py deleted file mode 100644 index 0deb68c46..000000000 --- a/l10n_fr_das2/wizards/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from . import res_config_settings diff --git a/l10n_fr_das2/wizards/res_config_settings.py b/l10n_fr_das2/wizards/res_config_settings.py deleted file mode 100644 index ff3f48b84..000000000 --- a/l10n_fr_das2/wizards/res_config_settings.py +++ /dev/null @@ -1,13 +0,0 @@ -# Copyright 2020-2021 Akretion France (http://www.akretion.com/) -# @author: Alexis de Lattre -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). - -from odoo import fields, models - - -class ResConfigSettings(models.TransientModel): - _inherit = "res.config.settings" - - fr_das2_partner_declare_threshold = fields.Integer( - related="company_id.fr_das2_partner_declare_threshold", readonly=False - ) diff --git a/requirements.txt b/requirements.txt index 0230dee4c..65d33753b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ # generated from manifests external_dependencies -pyfrdas2 +pyfrdas2>=0.4 python-stdnum python-stdnum>=1.18 requests_oauthlib