diff --git a/l10n_fr_cog/__manifest__.py b/l10n_fr_cog/__manifest__.py index 531267bac8..404170f34c 100644 --- a/l10n_fr_cog/__manifest__.py +++ b/l10n_fr_cog/__manifest__.py @@ -1,11 +1,11 @@ -# Copyright 2020-2021 Akretion France (http://www.akretion.com/) +# Copyright 2020-2023 Akretion France (http://www.akretion.com/) # @author: Alexis de Lattre # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). { "name": "Code Officiel Géographique", "summary": "Add Code Officiel Géographique (COG) on countries", - "version": "14.0.1.0.0", + "version": "15.0.1.0.0", "category": "French Localization", "author": "Akretion,Odoo Community Association (OCA)", "maintainers": ["alexis-via"], diff --git a/l10n_fr_cog/post_install.py b/l10n_fr_cog/post_install.py index 698a4cde2f..bcc5346390 100644 --- a/l10n_fr_cog/post_install.py +++ b/l10n_fr_cog/post_install.py @@ -25,15 +25,14 @@ def set_fr_cog(cr, registry): if xfield.attrib and xfield.attrib.get("name") == "fr_cog": data[xmlid] = int(xfield.text) logger.debug("set_fr_cog data=%s", data) - with api.Environment.manage(): - env = api.Environment(cr, SUPERUSER_ID, {}) - for xmlid, fr_cog in data.items(): - country = env.ref(xmlid) - country.fr_cog = fr_cog - logger.debug( - "Country ID %d xmlid %s updated with fr_cog=%d", - country.id, - xmlid, - fr_cog, - ) + env = api.Environment(cr, SUPERUSER_ID, {}) + for xmlid, fr_cog in data.items(): + country = env.ref(xmlid) + country.fr_cog = fr_cog + logger.debug( + "Country ID %d xmlid %s updated with fr_cog=%d", + country.id, + xmlid, + fr_cog, + ) return diff --git a/l10n_fr_cog/views/country.xml b/l10n_fr_cog/views/country.xml index a6c46eedb4..8f81cec619 100644 --- a/l10n_fr_cog/views/country.xml +++ b/l10n_fr_cog/views/country.xml @@ -1,6 +1,6 @@ @@ -18,5 +18,15 @@ + + res.country + + + + + + + + diff --git a/l10n_fr_das2/__manifest__.py b/l10n_fr_das2/__manifest__.py index d45dfd41c3..9723ca573a 100644 --- a/l10n_fr_das2/__manifest__.py +++ b/l10n_fr_das2/__manifest__.py @@ -1,10 +1,10 @@ -# Copyright 2020-2021 Akretion France (http://www.akretion.com/) +# Copyright 2020-2023 Akretion France (http://www.akretion.com/) # @author: Alexis de Lattre # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). { "name": "DAS2", - "version": "14.0.2.0.0", + "version": "15.0.1.0.0", "category": "Invoicing Management", "license": "AGPL-3", "summary": "DAS2 (France)", diff --git a/l10n_fr_das2/models/l10n_fr_das2.py b/l10n_fr_das2/models/l10n_fr_das2.py index 819783ca7d..28e2ca4764 100644 --- a/l10n_fr_das2/models/l10n_fr_das2.py +++ b/l10n_fr_das2/models/l10n_fr_das2.py @@ -61,13 +61,14 @@ class L10nFrDas2(models.Model): _inherit = ["mail.thread", "mail.activity.mixin"] _order = "year desc" _description = "DAS2" + _check_company_auto = True year = fields.Integer( - string="Year", required=True, states={"done": [("readonly", True)]}, tracking=True, default=lambda self: self._default_year(), + index=True, ) state = fields.Selection( [ @@ -76,12 +77,11 @@ class L10nFrDas2(models.Model): ], default="draft", readonly=True, - string="State", tracking=True, + index=True, ) company_id = fields.Many2one( "res.company", - string="Company", ondelete="cascade", required=True, states={"done": [("readonly", True)]}, @@ -89,7 +89,6 @@ class L10nFrDas2(models.Model): ) currency_id = fields.Many2one( related="company_id.currency_id", - readonly=True, store=True, string="Company Currency", ) @@ -100,6 +99,7 @@ class L10nFrDas2(models.Model): default=lambda self: self._default_payment_journals(), domain="[('company_id', '=', company_id)]", states={"done": [("readonly", True)]}, + check_company=True, ) line_ids = fields.One2many( "l10n.fr.das2.line", @@ -131,7 +131,7 @@ class L10nFrDas2(models.Model): help="Contact in the company for the fiscal administration: the name, " "email and phone number of this partner will be used in the file.", ) - attachment_id = fields.Many2one("ir.attachment", string="Attachment", readonly=True) + attachment_id = fields.Many2one("ir.attachment", readonly=True) attachment_datas = fields.Binary( related="attachment_id.datas", string="File Export" ) @@ -239,15 +239,20 @@ def generate_lines(self): if company.country_id.code not in FRANCE_CODES: raise UserError( _( - "Company '%s' is configured in country '%s'. The DAS2 is " - "only for France and it's oversea territories." + "Company '%(company)s' is configured in country '%(country)s'. " + "The DAS2 is only for France and it's oversea territories.", + company=company.display_name, + country=company.country_id.name, ) - % (company.display_name, company.country_id.name) ) if company.currency_id != self.env.ref("base.EUR"): raise UserError( - _("Company '%s' is configured with currency '%s'. " "It should be EUR.") - % (company.display_name, company.currency_id.name) + _( + "Company '%(company)s' is configured with currency '%(currency)s'. " + "It should be EUR.", + company=company.display_name, + currency=company.currency_id.name, + ) ) if company.fr_das2_partner_declare_threshold <= 0: raise UserError( @@ -292,12 +297,13 @@ def _prepare_line(self, partner, base_domain): for mline in mlines: amount += mline.balance note.append( - _("Payment dated %s in journal '%s': " "%.2f € (journal entry %s)") - % ( - mline.date, - mline.journal_id.display_name, - mline.balance, - mline.move_id.name, + _( + "Payment dated %(date)s in journal '%(journal)s': " + "%(amount).2f € (journal entry %(move_name)s)", + date=mline.date, + journal=mline.journal_id.display_name, + amount=mline.balance, + move_name=mline.move_id.name, ) ) res = False @@ -387,20 +393,27 @@ def _prepare_field( if not isinstance(value, int): try: value = int(value) - except Exception: + except Exception as e: raise UserError( - _("Failed to convert field '%s' (partner %s) " "to integer.") - % (field_name, partner.display_name) - ) + _( + "Failed to convert field '%(field_name)s' " + "(partner %(partner)s) to integer.", + field_name=field_name, + partner=partner.display_name, + ) + ) from e value = str(value) if len(value) > size: raise UserError( _( - "Field %s (partner %s) has value %s: " - "it is bigger than the maximum size " - "(%d characters)" + "Field %(field_name)s (partner %(partner)s) has value " + "%(value)s: it is bigger than the maximum size " + "(%(size)d characters).", + field_name=field_name, + partner=partner.display_name, + value=value, + size=size, ) - % (field_name, partner.display_name, value, size) ) if len(value) < size: value = value.rjust(size, "0") @@ -408,10 +421,11 @@ def _prepare_field( if required and not value: raise UserError( _( - "The field '%s' (partner %s) is empty or 0. " - "It should have a non-null value." + "The field '%(field_name)s' (partner %(partner)s) is empty or 0. " + "It should have a non-null value.", + field_name=field_name, + partner=partner.display_name, ) - % (field_name, partner.display_name) ) if not value: value = " " * size @@ -673,10 +687,11 @@ def _prepare_file(self): if len(fline) != 672: raise UserError( _( - "One of the lines has a length of %d. " - "All lines should have a length of 672. Line: %s." + "One of the lines has a length of %(length)d. " + "All lines should have a length of 672. Line: %(line_content)s.", + length=len(fline), + line_content=fline, ) - % (len(fline), fline) ) file_content = "\r\n".join(flines) + "\r\n" return file_content @@ -722,14 +737,14 @@ def generate_file(self, encryption="prod"): file_content = self._prepare_file() try: file_content_encoded = file_content.encode("latin1") - except UnicodeEncodeError: + except UnicodeEncodeError as e: raise UserError( _( "A special character in the DAS2 file is not in the latin1 " "table. Please locate this special character and replace " "it by a standard character and try again." ) - ) + ) from e if encryption in ("prod", "test"): prefix = "DSAL_" @@ -798,13 +813,10 @@ class L10nFrDas2Line(models.Model): partner_siret = fields.Char( string="SIRET", size=14, states={"done": [("readonly", True)]} ) - company_id = fields.Many2one( - related="parent_id.company_id", store=True, readonly=True - ) + company_id = fields.Many2one(related="parent_id.company_id", store=True) currency_id = fields.Many2one( related="parent_id.company_id.currency_id", store=True, - readonly=True, string="Company Currency", ) fee_amount = fields.Integer( @@ -842,12 +854,11 @@ class L10nFrDas2Line(models.Model): ) total_amount = fields.Integer( compute="_compute_total_amount", - string="Total Amount", store=True, readonly=True, ) to_declare = fields.Boolean( - compute="_compute_total_amount", string="To Declare", readonly=True, store=True + compute="_compute_total_amount", readonly=True, store=True ) allowance_fixed = fields.Boolean( "Allocation forfaitaire", states={"done": [("readonly", True)]} @@ -873,7 +884,7 @@ class L10nFrDas2Line(models.Model): benefits_in_kind_nict = fields.Boolean( "Outils issus des NTIC", states={"done": [("readonly", True)]} ) - state = fields.Selection(related="parent_id.state", store=True, readonly=True) + state = fields.Selection(related="parent_id.state", store=True) note = fields.Text() job = fields.Char( string="Profession", size=30, states={"done": [("readonly", True)]} diff --git a/l10n_fr_das2/readme/CONFIGURE.rst b/l10n_fr_das2/readme/CONFIGURE.rst index d9c8d38a71..89a6765e78 100644 --- a/l10n_fr_das2/readme/CONFIGURE.rst +++ b/l10n_fr_das2/readme/CONFIGURE.rst @@ -8,3 +8,11 @@ On the supplier form view, in the *Accounting* tab, you will see a section *DAS2 On the company configuration form, the APE code, SIRET and address must be set. For the user responsible for the declaration, the phone number and email must be set on his related partner form (name, email and phone number are used in the DAS2 declaration file). + +If you want to encrypt the declaration file with the DGFiP's **test** PGP key, ensure that your Odoo server configuration file has the following parameter: + +.. code:: + + running_env = test + +Otherwise, Odoo will use DGFiP's **production** PGP key. diff --git a/l10n_fr_das2/views/l10n_fr_das2.xml b/l10n_fr_das2/views/l10n_fr_das2.xml index 95af9d2e71..d293de566d 100644 --- a/l10n_fr_das2/views/l10n_fr_das2.xml +++ b/l10n_fr_das2/views/l10n_fr_das2.xml @@ -11,7 +11,7 @@ l10n.fr.das2.form l10n.fr.das2 -
+