diff --git a/account_payment_portal/README.rst b/account_payment_portal/README.rst
index 49854c0..d02b1f3 100644
--- a/account_payment_portal/README.rst
+++ b/account_payment_portal/README.rst
@@ -35,6 +35,7 @@ Changelog
- 16.0.1.0.0: Initial module
- 16.0.1.0.1: Fix security rules
- 16.0.1.0.2: Add tests
+- 16.0.1.0.3: Add and use default image field
Bug Tracker
===========
diff --git a/account_payment_portal/readme/HISTORY.rst b/account_payment_portal/readme/HISTORY.rst
index 9af7916..7eb0678 100644
--- a/account_payment_portal/readme/HISTORY.rst
+++ b/account_payment_portal/readme/HISTORY.rst
@@ -1,3 +1,4 @@
- 16.0.1.0.0: Initial module
- 16.0.1.0.1: Fix security rules
- 16.0.1.0.2: Add tests
+- 16.0.1.0.3: Add and use default image field
diff --git a/account_payment_portal/static/description/index.html b/account_payment_portal/static/description/index.html
index 4659bfb..4ae463d 100644
--- a/account_payment_portal/static/description/index.html
+++ b/account_payment_portal/static/description/index.html
@@ -390,6 +390,7 @@ ul.auto-toc {
16.0.1.0.0: Initial module
16.0.1.0.1: Fix security rules
16.0.1.0.2: Add tests
+16.0.1.0.3: Add and use default image field
diff --git a/data_nature_importer/README.rst b/data_nature_importer/README.rst
index 1adf31f..3cbb83c 100644
--- a/data_nature_importer/README.rst
+++ b/data_nature_importer/README.rst
@@ -41,6 +41,7 @@ Changelog
- 16.0.1.0.0: Initial module.
- 16.0.1.0.1: Catch empty metadata response in _get_dn_metadata
- 16.0.1.1.0: Add Queue Job support and move to server action
+- 16.0.1.0.2: Use default image as product image
Bug Tracker
===========
diff --git a/data_nature_importer/__manifest__.py b/data_nature_importer/__manifest__.py
index beddded..458e1b5 100644
--- a/data_nature_importer/__manifest__.py
+++ b/data_nature_importer/__manifest__.py
@@ -4,7 +4,7 @@
"author": "BAKEUP",
"website": "https://www.bakeup.org",
"category": "product",
- "version": "16.0.1.0.1",
+ "version": "16.0.1.0.2",
"depends": ["product", "queue_job"],
"data": [
"security/ir.model.access.csv",
diff --git a/data_nature_importer/models/product_template.py b/data_nature_importer/models/product_template.py
index 4b0c1a7..002a041 100644
--- a/data_nature_importer/models/product_template.py
+++ b/data_nature_importer/models/product_template.py
@@ -24,7 +24,14 @@ class ProductTemplate(models.Model):
metadata = self._get_dn_metadata()
if not metadata or not metadata.get("images"):
return False
- image_id = metadata.get("images")[0].get("id")
+ images = metadata.get("images")
+ if not images:
+ return False
+ image_id = None
+ for img in images:
+ if img.get("default") == "true":
+ image_id = img.get("id")
+ break
image_data = dn_utils.get_datanature_image(self, image_id, token=None)
if image_data:
return image_data
diff --git a/data_nature_importer/readme/HISTORY.rst b/data_nature_importer/readme/HISTORY.rst
index 2244b12..bbebf27 100644
--- a/data_nature_importer/readme/HISTORY.rst
+++ b/data_nature_importer/readme/HISTORY.rst
@@ -1,3 +1,4 @@
- 16.0.1.0.0: Initial module.
- 16.0.1.0.1: Catch empty metadata response in _get_dn_metadata
- 16.0.1.1.0: Add Queue Job support and move to server action
+- 16.0.1.0.2: Use default image as product image
diff --git a/data_nature_importer/static/description/index.html b/data_nature_importer/static/description/index.html
index 76ffedc..cce3dcf 100644
--- a/data_nature_importer/static/description/index.html
+++ b/data_nature_importer/static/description/index.html
@@ -384,6 +384,7 @@ ul.auto-toc {
16.0.1.0.0: Initial module.
16.0.1.0.1: Catch empty metadata response in _get_dn_metadata
16.0.1.1.0: Add Queue Job support and move to server action
+16.0.1.0.2: Use default image as product image
diff --git a/data_nature_importer/utils.py b/data_nature_importer/utils.py
index 6da515f..8fd586f 100644
--- a/data_nature_importer/utils.py
+++ b/data_nature_importer/utils.py
@@ -86,6 +86,7 @@ def _parse_products(xml_bytes):
"mime_type": img.findtext(
"dn:mime_type", default="", namespaces=ns
),
+ "default": img.findtext("dn:default", default="", namespaces=ns),
"size": img.findtext("dn:size", default="", namespaces=ns),
"img_width": img.findtext(
"dn:img_width", default="", namespaces=ns