Commit 296679c3 authored by Jérome Perrin's avatar Jérome Perrin

fixup! pdm/trade: Support supply line for a product_line

Accept subcategories correctly
parent c11b988c
...@@ -67,6 +67,9 @@ if context.getDestination():\n ...@@ -67,6 +67,9 @@ if context.getDestination():\n
base_category_tuple += (\'destination\',)\n base_category_tuple += (\'destination\',)\n
\n \n
if context.hasProductLine():\n if context.hasProductLine():\n
category_list = context.getCategoryList() + [\n
pl.getRelativeUrl() for pl in context.getProductLineValue().getCategoryChildValueList()]\n
context = context.asContext(categories=category_list)\n
base_category_tuple += (\'product_line\', )\n base_category_tuple += (\'product_line\', )\n
\n \n
if context.getParentValue().getParentValue().getPortalType() in (\n if context.getParentValue().getParentValue().getPortalType() in (\n
......
...@@ -69,6 +69,9 @@ if context.getDestination():\n ...@@ -69,6 +69,9 @@ if context.getDestination():\n
base_category_tuple += (\'destination\',)\n base_category_tuple += (\'destination\',)\n
\n \n
if context.hasProductLine():\n if context.hasProductLine():\n
category_list = context.getCategoryList() + [\n
pl.getRelativeUrl() for pl in context.getProductLineValue().getCategoryChildValueList()]\n
context = context.asContext(categories=category_list)\n
base_category_tuple += (\'product_line\', )\n base_category_tuple += (\'product_line\', )\n
\n \n
if context.getParentValue().getPortalType() in (\n if context.getParentValue().getPortalType() in (\n
......
...@@ -192,6 +192,9 @@ class TestResource(ERP5TypeTestCase): ...@@ -192,6 +192,9 @@ class TestResource(ERP5TypeTestCase):
product_line.newContent( product_line.newContent(
id='a', id='a',
portal_type='Category') portal_type='Category')
product_line.a.newContent(
id='a1',
portal_type='Category')
if product_line._getOb('b', None) is None: if product_line._getOb('b', None) is None:
product_line.newContent( product_line.newContent(
id='b', id='b',
...@@ -1092,6 +1095,9 @@ class TestResource(ERP5TypeTestCase): ...@@ -1092,6 +1095,9 @@ class TestResource(ERP5TypeTestCase):
resource_a = self.portal.getDefaultModule(self.product_portal_type)\ resource_a = self.portal.getDefaultModule(self.product_portal_type)\
.newContent(portal_type=self.product_portal_type) .newContent(portal_type=self.product_portal_type)
resource_a.setProductLineValue(self.portal.portal_categories.product_line.a) resource_a.setProductLineValue(self.portal.portal_categories.product_line.a)
resource_a_1 = self.portal.getDefaultModule(self.product_portal_type)\
.newContent(portal_type=self.product_portal_type)
resource_a_1.setProductLineValue(self.portal.portal_categories.product_line.a.a1)
resource_b = self.portal.getDefaultModule(self.product_portal_type)\ resource_b = self.portal.getDefaultModule(self.product_portal_type)\
.newContent(portal_type=self.product_portal_type) .newContent(portal_type=self.product_portal_type)
resource_b.setProductLineValue(self.portal.portal_categories.product_line.b) resource_b.setProductLineValue(self.portal.portal_categories.product_line.b)
...@@ -1105,6 +1111,14 @@ class TestResource(ERP5TypeTestCase): ...@@ -1105,6 +1111,14 @@ class TestResource(ERP5TypeTestCase):
# resource_a is member of product_line/a, so our supply line applies. # resource_a is member of product_line/a, so our supply line applies.
self.assertEqual(1000, sale_order_line.getPrice()) self.assertEqual(1000, sale_order_line.getPrice())
sale_order_line = self.portal.getDefaultModule("Sale Order").newContent(
portal_type='Sale Order').newContent(
portal_type=self.sale_order_line_portal_type,
resource_value=resource_a_1,
quantity=1)
# resource_a_1 is member of product_line/a/a1, so our supply line applies.
self.assertEqual(1000, sale_order_line.getPrice())
sale_order_line = self.portal.getDefaultModule("Sale Order").newContent( sale_order_line = self.portal.getDefaultModule("Sale Order").newContent(
portal_type='Sale Order').newContent( portal_type='Sale Order').newContent(
portal_type=self.sale_order_line_portal_type, portal_type=self.sale_order_line_portal_type,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment