Commit 38570101 authored by Jérome Perrin's avatar Jérome Perrin

pdm/trade: make price from trade conditions only apply if the trade condition is used in this order

parent 0cb72f9b
......@@ -95,6 +95,7 @@
<list>
<string>my_destination_title</string>
<string>my_resource_title</string>
<string>my_product_line</string>
<string>my_priced_quantity</string>
<string>my_base_unit_price</string>
<string>my_quantity_unit</string>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ProxyField" module="Products.ERP5Form.ProxyField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>delegated_list</string> </key>
<value>
<list>
<string>editable</string>
</list>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>my_product_line</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
<value>
<dictionary>
<item>
<key> <string>external_validator_failed</string> </key>
<value> <string>The input failed the external validator.</string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>editable</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>editable</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>field_id</string> </key>
<value> <string>my_product_line</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>Base_viewPDMFieldLibrary</string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string>Click to edit the target</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="TALESMethod" module="Products.Formulator.TALESField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>not: context/hasResource</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -84,6 +84,7 @@
<value>
<list>
<string>my_resource_title</string>
<string>my_product_line</string>
<string>my_source_title</string>
<string>my_source_reference</string>
<string>my_priced_quantity</string>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ProxyField" module="Products.ERP5Form.ProxyField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>delegated_list</string> </key>
<value>
<list>
<string>editable</string>
</list>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>my_product_line</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
<value>
<dictionary>
<item>
<key> <string>external_validator_failed</string> </key>
<value> <string>The input failed the external validator.</string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>editable</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>editable</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>field_id</string> </key>
<value> <string>my_product_line</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>Base_viewPDMFieldLibrary</string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string>Click to edit the target</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="TALESMethod" module="Products.Formulator.TALESField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>not: context/hasResource</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -95,6 +95,7 @@
<list>
<string>my_destination_title</string>
<string>my_resource_title</string>
<string>my_product_line</string>
<string>my_destination_reference</string>
<string>my_priced_quantity</string>
<string>your_quantity_unit</string>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ProxyField" module="Products.ERP5Form.ProxyField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>delegated_list</string> </key>
<value>
<list>
<string>editable</string>
</list>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>my_product_line</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
<value>
<dictionary>
<item>
<key> <string>external_validator_failed</string> </key>
<value> <string>The input failed the external validator.</string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>editable</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>editable</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>field_id</string> </key>
<value> <string>my_product_line</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>Base_viewPDMFieldLibrary</string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string>Click to edit the target</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="TALESMethod" module="Products.Formulator.TALESField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>not: context/hasResource</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -66,6 +66,19 @@ if context.getSource():\n
if context.getDestination():\n
base_category_tuple += (\'destination\',)\n
\n
if context.getParentValue().getParentValue().getPortalType() in (\n
## XXX There is no portal type group for trade conditions.\n
\'Sale Trade Condition\',\n
\'Purchase Trade Condition\',\n
\'Internal Trade Condition\'):\n
# Supply Lines from trade conditions are set as specialise to this trade condition,\n
# so that we can apply a predicate on movements later. Supply Lines from trade condition\n
# only apply on movements using these trade conditions.\n
category_list = context.getCategoryList() + [\'specialise/%s\' % context.getParentValue().getParentValue().getRelativeUrl()]\n
context = context.asContext(categories=category_list)\n
base_category_tuple += (\'specialise\', )\n
\n
\n
#backwards compatibility\n
mapped_value_property_list = context.getMappedValuePropertyList()\n
if not \'priced_quantity\' in mapped_value_property_list:\n
......
......@@ -68,6 +68,18 @@ if context.getSource():\n
if context.getDestination():\n
base_category_tuple += (\'destination\',)\n
\n
if context.getParentValue().getPortalType() in (\n
## XXX There is no portal type group for trade conditions.\n
\'Sale Trade Condition\',\n
\'Purchase Trade Condition\',\n
\'Internal Trade Condition\'):\n
# Supply Lines from trade conditions are set as specialise to this trade condition,\n
# so that we can apply a predicate on movements later. Supply Lines from trade condition\n
# only apply on movements using these trade conditions.\n
category_list = context.getCategoryList() + [\'specialise/%s\' % context.getParentValue().getRelativeUrl()]\n
context = context.asContext(categories=category_list)\n
base_category_tuple += (\'specialise\', )\n
\n
#backwards compatibility\n
mapped_value_property_list = context.getMappedValuePropertyList()\n
if not \'priced_quantity\' in mapped_value_property_list:\n
......
......@@ -143,6 +143,8 @@ except AttributeError:\n
# Sometime, movements doesn\'t have an explanation.\n
explanation = None\n
\n
specialise_set = set()\n
\n
if explanation is not None:\n
explanation_type = explanation.getPortalType()\n
high_priority_supply_line_list = []\n
......@@ -157,6 +159,7 @@ if explanation is not None:\n
high_priority_supply_line_list.extend(list(supply_cell_list))\n
else:\n
high_priority_supply_line_list.append(supply_line)\n
specialise_set.add(supply_line.getParentValue().getRelativeUrl())\n
\n
# XXX FIXME: Hardcoded values\n
if "Internal" in explanation_type:\n
......@@ -171,6 +174,9 @@ if explanation is not None:\n
\n
resource = context.getResourceValue()\n
\n
if specialise_set:\n
kw[\'categories\'] = kw.get(\'categories\', []) + [\'specialise/%s\' % x for x in specialise_set]\n
\n
if resource is not None:\n
if isPricingOptimise():\n
return getOptimisedPriceCalculationOperandDict(default=default, context=context, **kw)\n
......
......@@ -479,6 +479,24 @@ class TestTradeConditionSupplyLine(TradeConditionTestCase):
# not using the supply line inside trade condition
self.assertEqual(1, line.getPrice())
def test_supply_line_in_other_trade_condition_does_not_apply(self):
"""Supply lines from trade condition not related to an order does not apply.
"""
supply_line = self.trade_condition.newContent(
portal_type=self.supply_line_type,
resource_value=self.resource,
base_price=2)
self.assertEqual(None, self.order.getSpecialiseValue())
self.order.setSourceSectionValue(self.vendor)
self.order.setDestinationSectionValue(self.client)
self.tic()
line = self.order.newContent(portal_type=self.order_line_type,
resource_value=self.resource,
quantity=1)
# not using the supply line inside trade condition
self.assertEqual(None, line.getPrice())
# TODO: move to testSupplyLine ! (which does not exist yet)
def test_supply_line_section(self):
......
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