diff --git a/dms_field/models/dms_field_template.py b/dms_field/models/dms_field_template.py
index d32294db8..ba95beac2 100644
--- a/dms_field/models/dms_field_template.py
+++ b/dms_field/models/dms_field_template.py
@@ -59,6 +59,16 @@ def _compute_model(self):
def _get_template_from_model(self, model):
return self.search([("model", "=", model)], limit=1)
+ @api.model_create_multi
+ def create(self, vals_list):
+ """Create dms directory automatically in the creation in install mode."""
+ result = super().create(vals_list)
+ if self.env.context.get("install_mode"):
+ for item in result:
+ item_ctx = item.with_context(res_model=item._name, res_id=item.id)
+ item_ctx.create_dms_directory()
+ return result
+
@api.model
def create_dms_directory(self):
"""According to the model, create the directory linked to that record
diff --git a/hr_dms_field/demo/dms_data.xml b/hr_dms_field/demo/dms_data.xml
index dafdbc9a7..20efbaad7 100644
--- a/hr_dms_field/demo/dms_data.xml
+++ b/hr_dms_field/demo/dms_data.xml
@@ -14,7 +14,4 @@
-
-
-
diff --git a/hr_dms_field/models/__init__.py b/hr_dms_field/models/__init__.py
index 9cf62bd2e..39b647b36 100644
--- a/hr_dms_field/models/__init__.py
+++ b/hr_dms_field/models/__init__.py
@@ -1,5 +1,4 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
-from . import dms_field_template
from . import hr_employee
from . import hr_employee_public
diff --git a/hr_dms_field/models/dms_field_template.py b/hr_dms_field/models/dms_field_template.py
deleted file mode 100644
index 22e325047..000000000
--- a/hr_dms_field/models/dms_field_template.py
+++ /dev/null
@@ -1,17 +0,0 @@
-# Copyright 2024 Tecnativa - Víctor Martínez
-# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-
-from odoo import models
-
-
-class DmsFieldTemplate(models.Model):
- _inherit = "dms.field.template"
-
- def _create_dms_directory(self):
- """Custom method to define the directory automatically in demo data avoiding
- error if it already exists."""
- self.ensure_one()
- if not self.dms_directory_ids:
- self.with_context(
- res_model=self._name, res_id=self.id
- ).create_dms_directory()