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