From 47800c94fc38947bb49ab2b4ec255b45278c737d Mon Sep 17 00:00:00 2001
From: Oskar Kosobucki <43652764+Kosaaaaa@users.noreply.github.com>
Date: Thu, 9 May 2024 19:21:34 +0200
Subject: [PATCH 1/2] [FIX] delivery_multii_desination: set dummy product if no
products from child_ids
---
delivery_multi_destination/__manifest__.py | 2 +-
.../data/product_product.xml | 14 ++++++++++++++
.../models/delivery_carrier.py | 2 +-
3 files changed, 16 insertions(+), 2 deletions(-)
create mode 100644 delivery_multi_destination/data/product_product.xml
diff --git a/delivery_multi_destination/__manifest__.py b/delivery_multi_destination/__manifest__.py
index 811e5042a5..8df9e28203 100644
--- a/delivery_multi_destination/__manifest__.py
+++ b/delivery_multi_destination/__manifest__.py
@@ -13,5 +13,5 @@
"installable": True,
"depends": ["delivery"],
"demo": ["demo/delivery_carrier_demo.xml"],
- "data": ["views/delivery_carrier_view.xml"],
+ "data": ["data/product_product.xml", "views/delivery_carrier_view.xml"],
}
diff --git a/delivery_multi_destination/data/product_product.xml b/delivery_multi_destination/data/product_product.xml
new file mode 100644
index 0000000000..2f6dbbb3d0
--- /dev/null
+++ b/delivery_multi_destination/data/product_product.xml
@@ -0,0 +1,14 @@
+
+
+
+
+ DUMMY Shipping Product
+ service
+
+
+
+ 0.0
+ order
+
+
+
\ No newline at end of file
diff --git a/delivery_multi_destination/models/delivery_carrier.py b/delivery_multi_destination/models/delivery_carrier.py
index b6d424cdee..d5154f4336 100644
--- a/delivery_multi_destination/models/delivery_carrier.py
+++ b/delivery_multi_destination/models/delivery_carrier.py
@@ -30,7 +30,7 @@ class DeliveryCarrier(models.Model):
def _onchange_destination_type(self):
"""Define the corresponding value to avoid creation error with UX."""
if self.destination_type == "multi" and self.child_ids and not self.product_id:
- self.product_id = fields.first(self.child_ids.product_id)
+ self.product_id = fields.first(self.child_ids.product_id) or self.env.ref('delivery_multi_destination.dummy_shipping_product')
def search(self, args, offset=0, limit=None, order=None, count=False):
"""Don't show by default children carriers."""
From 7db2fb0f77fc13caebb3dd3b145fadaf6205460d Mon Sep 17 00:00:00 2001
From: Oskar Kosobucki <43652764+Kosaaaaa@users.noreply.github.com>
Date: Thu, 9 May 2024 19:30:09 +0200
Subject: [PATCH 2/2] [FIX] delivery_multii_desination: set dummy product if no
products from child_ids
---
delivery_multi_destination/data/product_product.xml | 4 ++--
delivery_multi_destination/models/delivery_carrier.py | 4 +++-
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/delivery_multi_destination/data/product_product.xml b/delivery_multi_destination/data/product_product.xml
index 2f6dbbb3d0..9f54579f05 100644
--- a/delivery_multi_destination/data/product_product.xml
+++ b/delivery_multi_destination/data/product_product.xml
@@ -1,4 +1,4 @@
-
+
@@ -11,4 +11,4 @@
order
-
\ No newline at end of file
+
diff --git a/delivery_multi_destination/models/delivery_carrier.py b/delivery_multi_destination/models/delivery_carrier.py
index d5154f4336..b34dd65746 100644
--- a/delivery_multi_destination/models/delivery_carrier.py
+++ b/delivery_multi_destination/models/delivery_carrier.py
@@ -30,7 +30,9 @@ class DeliveryCarrier(models.Model):
def _onchange_destination_type(self):
"""Define the corresponding value to avoid creation error with UX."""
if self.destination_type == "multi" and self.child_ids and not self.product_id:
- self.product_id = fields.first(self.child_ids.product_id) or self.env.ref('delivery_multi_destination.dummy_shipping_product')
+ self.product_id = fields.first(self.child_ids.product_id) or self.env.ref(
+ "delivery_multi_destination.dummy_shipping_product"
+ )
def search(self, args, offset=0, limit=None, order=None, count=False):
"""Don't show by default children carriers."""