diff --git a/energy_selfconsumption/__init__.py b/energy_selfconsumption/__init__.py
index 4ba79402084324083a9dd48c484d021467cbdb99..301c265b7da7e99b66d033d8fee7f6f79dba7b5e 100644
--- a/energy_selfconsumption/__init__.py
+++ b/energy_selfconsumption/__init__.py
@@ -1,3 +1,4 @@
 from . import models
 from . import wizards
 from . import controllers
+from . import tests
diff --git a/energy_selfconsumption/models/supply_point_assignation.py b/energy_selfconsumption/models/supply_point_assignation.py
index 38f3129af7e4393243271a4dcf0c5e7111884294..72fad332fc0d95b97ec3db246904690151179822 100644
--- a/energy_selfconsumption/models/supply_point_assignation.py
+++ b/energy_selfconsumption/models/supply_point_assignation.py
@@ -72,7 +72,7 @@ class SupplyPointAssignation(models.Model):
     @api.constrains("supply_point_id")
     def constraint_supply_point_id(self):
         for record in self:
-            supply_points = record.distribution_table_id.selfconsumption_project_id.inscription_ids.mapped(
+            supply_points = record.distribution_table_id.selfconsumption_project_id.project_id.inscription_ids.mapped(
                 "partner_id.supply_ids"
             )
             if record.supply_point_id.id not in supply_points.ids:
diff --git a/energy_selfconsumption/tests/__init__.py b/energy_selfconsumption/tests/__init__.py
new file mode 100644
index 0000000000000000000000000000000000000000..d51f710a56e87a9d4b0226d422cb502be41bfc8a
--- /dev/null
+++ b/energy_selfconsumption/tests/__init__.py
@@ -0,0 +1 @@
+from . import test_contract_generation_wizard
diff --git a/energy_selfconsumption/tests/test_contract_generation_wizard.py b/energy_selfconsumption/tests/test_contract_generation_wizard.py
new file mode 100644
index 0000000000000000000000000000000000000000..70dedb2aec7acbb6daaa5bd76b3c9d3084970963
--- /dev/null
+++ b/energy_selfconsumption/tests/test_contract_generation_wizard.py
@@ -0,0 +1,95 @@
+from datetime import datetime
+
+from odoo.exceptions import ValidationError
+from odoo.tests.common import TransactionCase
+
+
+class TestContractGenerationWizard(TransactionCase):
+    def setUp(self):
+        super().setUp()
+        self.partner = self.env["res.partner"].create({"name": "test partner"})
+        self.selfconsumption = self.env[
+            "energy_selfconsumption.selfconsumption"
+        ].create(
+            {
+                "name": "test Selfconsumption Project",
+                "type": self.env.ref(
+                    "energy_selfconsumption.selfconsumption_project_type"
+                ).id,
+                "code": "ES0397277816188340VL",
+                "cil": "001ES0397277816188340VL",
+                "state": "activation",
+                "power": 100,
+                "street": "Carrer de Sants, 79",
+                "zip": "08014",
+                "city": "Barcelona",
+                "state_id": self.env.ref("base.state_es_b").id,
+                "country_id": self.env.ref("base.es").id,
+            }
+        )
+        self.inscription = self.env["energy_project.inscription"].create(
+            {
+                "project_id": self.selfconsumption.project_id.id,
+                "partner_id": self.partner.id,
+                "effective_date": datetime.today(),
+            }
+        )
+        self.supply_point = self.env["energy_selfconsumption.supply_point"].create(
+            {
+                "code": "ES0029542181297829TM",
+                "street": "C. de Sta. Catalina",
+                "street2": "55º B",
+                "zip": "08014",
+                "city": "Barcelona",
+                "state_id": self.env.ref("base.state_es_b").id,
+                "country_id": self.env.ref("base.es").id,
+                "owner_id": self.partner.id,
+                "partner_id": self.partner.id,
+            }
+        )
+        self.distribution_table = self.env[
+            "energy_selfconsumption.distribution_table"
+        ].create(
+            {
+                "name": "DT001",
+                "selfconsumption_project_id": self.selfconsumption.id,
+                "type": "fixed",
+                "state": "process",
+            }
+        )
+        self.supply_point_assignation = self.env[
+            "energy_selfconsumption.supply_point_assignation"
+        ].create(
+            {
+                "distribution_table_id": self.distribution_table.id,
+                "supply_point_id": self.supply_point.id,
+                "coefficient": 1,
+            }
+        )
+        self.contract_generation_wizard = self.env[
+            "energy_selfconsumption.contract_generation.wizard"
+        ].create(
+            {
+                "price_energy": 0.1,
+                "recurring_interval": 1,
+                "recurring_rule_type": "monthly",
+                "selfconsumption_id": self.selfconsumption.id,
+            }
+        )
+
+    def test_generation_contracts(self):
+        res = self.contract_generation_wizard.generate_contracts_button()
+        self.assertEqual(res, True)
+
+        related_contract = self.env["contract.contract"].search(
+            [("project_id", "=", self.selfconsumption.project_id.id)]
+        )
+        contract_line = related_contract[0].contract_line_ids[0]
+        days_timedelta = (
+            contract_line.next_period_date_end - contract_line.next_period_date_start
+        )
+        expected_quantity = 100 * 1 * (days_timedelta.days + 1)
+        related_contract[0].recurring_create_invoice()
+        invoice = related_contract._get_related_invoices()
+        self.assertEqual(invoice.invoice_line_ids[0].quantity, expected_quantity)
+        self.assertEqual(invoice.invoice_line_ids[0].price_unit, 0.1)