diff --git a/l10n_fr_siret/__manifest__.py b/l10n_fr_siret/__manifest__.py
index ff4e37d99..5f88de45f 100644
--- a/l10n_fr_siret/__manifest__.py
+++ b/l10n_fr_siret/__manifest__.py
@@ -16,6 +16,7 @@
"data": [
"views/res_partner.xml",
"views/res_company.xml",
+ "views/res_country.xml",
],
"demo": ["demo/partner_demo.xml"],
"post_init_hook": "set_siren_nic",
diff --git a/l10n_fr_siret/i18n/fr.po b/l10n_fr_siret/i18n/fr.po
index e9e68acdf..d688a274e 100644
--- a/l10n_fr_siret/i18n/fr.po
+++ b/l10n_fr_siret/i18n/fr.po
@@ -89,6 +89,12 @@ msgstr "Partenaire avec le même SIREN"
msgid "SIREN"
msgstr "SIREN"
+#. module: l10n_fr_siret
+#: model:ir.model.fields,field_description:l10n_fr_siret.field_res_partner__show_siret_fields
+#: model:ir.model.fields,field_description:l10n_fr_siret.field_res_users__show_siret_fields
+msgid "Show siret fields"
+msgstr "Afficher les champs SIRET"
+
#. module: l10n_fr_siret
#: model:ir.model.fields,field_description:l10n_fr_siret.field_res_company__siret
#: model:ir.model.fields,field_description:l10n_fr_siret.field_res_partner__siret
diff --git a/l10n_fr_siret/i18n/l10n_fr_siret.pot b/l10n_fr_siret/i18n/l10n_fr_siret.pot
index 83aabd1a6..513da403c 100644
--- a/l10n_fr_siret/i18n/l10n_fr_siret.pot
+++ b/l10n_fr_siret/i18n/l10n_fr_siret.pot
@@ -85,6 +85,12 @@ msgstr ""
msgid "SIREN"
msgstr ""
+#. module: l10n_fr_siret
+#: model:ir.model.fields,field_description:l10n_fr_siret.field_res_partner__show_siret_fields
+#: model:ir.model.fields,field_description:l10n_fr_siret.field_res_users__show_siret_fields
+msgid "Show siret fields"
+msgstr ""
+
#. module: l10n_fr_siret
#: model:ir.model.fields,field_description:l10n_fr_siret.field_res_company__siret
#: model:ir.model.fields,field_description:l10n_fr_siret.field_res_partner__siret
diff --git a/l10n_fr_siret/models/__init__.py b/l10n_fr_siret/models/__init__.py
index e2356f517..566d0c23a 100644
--- a/l10n_fr_siret/models/__init__.py
+++ b/l10n_fr_siret/models/__init__.py
@@ -1,2 +1,3 @@
from . import res_partner
from . import res_company
+from . import res_country
diff --git a/l10n_fr_siret/models/res_country.py b/l10n_fr_siret/models/res_country.py
new file mode 100644
index 000000000..d0fd5bcb9
--- /dev/null
+++ b/l10n_fr_siret/models/res_country.py
@@ -0,0 +1,11 @@
+# Copyright 2024 Foodles (https://www.foodles.co/).
+# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
+
+
+from odoo import fields, models
+
+
+class ResCountry(models.Model):
+ _inherit = "res.country"
+
+ show_siret_fields = fields.Boolean(default=True)
diff --git a/l10n_fr_siret/models/res_partner.py b/l10n_fr_siret/models/res_partner.py
index 99c12a423..6b77d2853 100644
--- a/l10n_fr_siret/models/res_partner.py
+++ b/l10n_fr_siret/models/res_partner.py
@@ -137,6 +137,17 @@ def _address_fields(self):
string="Partner with same SIREN",
compute_sudo=True,
)
+ show_siret_fields = fields.Boolean(compute="_compute_show_siret_fields")
+
+ @api.depends("country_id", "is_company", "parent_is_company")
+ def _compute_show_siret_fields(self):
+ countries_show_siret = self.env["res.country"].search(
+ [("show_siret_fields", "=", True)]
+ )
+ for record in self:
+ record.show_siret_fields = record.country_id in countries_show_siret and (
+ record.is_company or record.parent_is_company
+ )
@api.depends("siren", "company_id")
def _compute_same_siren_partner_id(self):
diff --git a/l10n_fr_siret/readme/USAGE.rst b/l10n_fr_siret/readme/USAGE.rst
index 1c637b14b..66944c404 100644
--- a/l10n_fr_siret/readme/USAGE.rst
+++ b/l10n_fr_siret/readme/USAGE.rst
@@ -8,3 +8,6 @@ The warning banner is displayed on the partner form view if another partner:
- has the same SIREN,
- if the partner is attached to a specific company: is in the same company or is not attached to a specific company,
- if the partner is not attached to a specific company: is in any company or not attached to a specific company.
+
+On the country form, users will be able to select if SIREN/SIRET fields have to be displayed or not
+on the partner's form when the country is selected.
diff --git a/l10n_fr_siret/tests/test_fr_siret.py b/l10n_fr_siret/tests/test_fr_siret.py
index 62f52bb1e..79337253a 100644
--- a/l10n_fr_siret/tests/test_fr_siret.py
+++ b/l10n_fr_siret/tests/test_fr_siret.py
@@ -30,6 +30,19 @@ def setUp(self):
.id
)
+ def test_show_siret_fields(self):
+ partner1 = self.env["res.partner"].create(
+ {"name": "Test partner1", "country_id": self.env.ref("base.fr").id}
+ )
+ self.assertTrue(partner1.show_siret_fields)
+
+ def test_show_siret_fields_on_not_configured_country(self):
+ self.env.ref("base.be").show_siret_fields = False
+ partner1 = self.env["res.partner"].create(
+ {"name": "Test partner1", "country_id": self.env.ref("base.be").id}
+ )
+ self.assertFalse(partner1.show_siret_fields)
+
def test_siret(self):
partner1 = self.env["res.partner"].create(
{
diff --git a/l10n_fr_siret/views/res_country.xml b/l10n_fr_siret/views/res_country.xml
new file mode 100644
index 000000000..db495d785
--- /dev/null
+++ b/l10n_fr_siret/views/res_country.xml
@@ -0,0 +1,19 @@
+
+
+
+
+ res.country.form.siret
+ res.country
+
+ 100
+
+
+
+
+
+
+
+
diff --git a/l10n_fr_siret/views/res_partner.xml b/l10n_fr_siret/views/res_partner.xml
index 4283e84be..6e1770a89 100644
--- a/l10n_fr_siret/views/res_partner.xml
+++ b/l10n_fr_siret/views/res_partner.xml
@@ -7,15 +7,18 @@
res.partner
+
+
+
{'invisible': [('is_company', '=', False), ('parent_is_company', '=', False)]}
+ >{'invisible': [('show_siret_fields', '=', False)]}