summaryrefslogtreecommitdiff
path: root/addons/website_sale_product_configurator/models
diff options
context:
space:
mode:
authorstephanchrst <stephanchrst@gmail.com>2022-05-10 21:51:50 +0700
committerstephanchrst <stephanchrst@gmail.com>2022-05-10 21:51:50 +0700
commit3751379f1e9a4c215fb6eb898b4ccc67659b9ace (patch)
treea44932296ef4a9b71d5f010906253d8c53727726 /addons/website_sale_product_configurator/models
parent0a15094050bfde69a06d6eff798e9a8ddf2b8c21 (diff)
initial commit 2
Diffstat (limited to 'addons/website_sale_product_configurator/models')
-rw-r--r--addons/website_sale_product_configurator/models/__init__.py3
-rw-r--r--addons/website_sale_product_configurator/models/sale_order.py25
2 files changed, 28 insertions, 0 deletions
diff --git a/addons/website_sale_product_configurator/models/__init__.py b/addons/website_sale_product_configurator/models/__init__.py
new file mode 100644
index 00000000..6064afee
--- /dev/null
+++ b/addons/website_sale_product_configurator/models/__init__.py
@@ -0,0 +1,3 @@
+# -*- coding: utf-8 -*-
+
+from . import sale_order
diff --git a/addons/website_sale_product_configurator/models/sale_order.py b/addons/website_sale_product_configurator/models/sale_order.py
new file mode 100644
index 00000000..3d25c8f9
--- /dev/null
+++ b/addons/website_sale_product_configurator/models/sale_order.py
@@ -0,0 +1,25 @@
+# -*- coding: utf-8 -*-
+# Part of Odoo. See LICENSE file for full copyright and licensing details.
+
+from odoo import api, models
+
+
+class SaleOrder(models.Model):
+ _inherit = "sale.order"
+
+ def _cart_find_product_line(self, product_id=None, line_id=None, **kwargs):
+ lines = super(SaleOrder, self)._cart_find_product_line(product_id, line_id, **kwargs)
+ if line_id: # in this case we get the exact line we want, so filtering below would be wrong
+ return lines
+
+ linked_line_id = kwargs.get('linked_line_id', False)
+ optional_product_ids = set(kwargs.get('optional_product_ids', []))
+
+ lines = lines.filtered(lambda line: line.linked_line_id.id == linked_line_id)
+ if optional_product_ids:
+ # only match the lines with the same chosen optional products on the existing lines
+ lines = lines.filtered(lambda line: optional_product_ids == set(line.mapped('option_line_ids.product_id.id')))
+ else:
+ lines = lines.filtered(lambda line: not line.option_line_ids)
+
+ return lines