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

Supply Lines from draft trade condition should not apply

In some configurations this might be incorrect, but for most cases it is not a
good idea that a price that is currently beeing edited gets applied.
parent b2b4c444
......@@ -50,7 +50,9 @@
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>if getattr(context, \'getValidationState\', lambda: "")() in (\'invalidated\', \'deleted\'):\n
<value> <string>if context.getParentValue().getParentValue().getPortalType() not in context.getPortalResourceTypeList() \\\n
and getattr(context, \'getValidationState\', lambda: "")() in (\'invalidated\', \'deleted\', \'draft\'):\n
# If this supply cell is contained in a supply or trade condition that is not validated, it does not apply.\n
return None\n
\n
base_category_tuple = (\'resource\', \'price_currency\')\n
......
......@@ -50,9 +50,12 @@
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>if getattr(context, \'getValidationState\', lambda: "")() in (\'invalidated\', \'deleted\'):\n
<value> <string>if context.getParentValue().getPortalType() not in context.getPortalResourceTypeList() \\\n
and getattr(context, \'getValidationState\', lambda: "")() in (\'invalidated\', \'deleted\', \'draft\'):\n
# If this supply line is contained in a supply or trade condition that is not validated, it does not apply.\n
return None\n
\n
\n
base_category_tuple = (\'resource\', \'price_currency\')\n
\n
if context.getSourceSection():\n
......
576
577
\ No newline at end of file
......@@ -456,6 +456,7 @@ class TestDomainTool(TestPredicateMixIn):
source_section_value=supplier,
destination_section_value=shop,
price_currency_value=jpy)
supply1.validate()
supply1.newContent(portal_type='Sale Supply Line',
resource_value=product1)
supply1.newContent(portal_type='Sale Supply Line',
......@@ -465,12 +466,14 @@ class TestDomainTool(TestPredicateMixIn):
source_section_value=supplier,
destination_section_value=company,
price_currency_value=jpy)
supply2.validate()
supply2.newContent(portal_type='Sale Supply Line',
resource_value=product2)
supply3 = supply_module.newContent(portal_type='Sale Supply',
title='Supply3',
source_section_value=supplier,
price_currency_value=euro)
supply3.validate()
supply3.newContent(portal_type='Sale Supply Line',
resource_value=product1)
......
......@@ -739,6 +739,7 @@ class TestResource(ERP5TypeTestCase):
portal_type=self.sale_supply_portal_type,
title='FakeSupply%s' % i,
destination_section_value=node)
supply.validate()
self.logMessage("Creating fake supply line %s..." % i, tab=1)
supply_line = supply.newContent(
portal_type=self.sale_supply_line_portal_type,
......@@ -779,6 +780,7 @@ class TestResource(ERP5TypeTestCase):
generic_supply = supply_module.newContent(
portal_type=self.sale_supply_portal_type,
title='FakeGenericSupply',)
generic_supply.validate()
# Create empty supply line
supply_line = generic_supply.newContent(
portal_type=self.sale_supply_line_portal_type)
......@@ -803,6 +805,7 @@ class TestResource(ERP5TypeTestCase):
portal_type=self.sale_supply_portal_type,
title='FakeSupply%s' % i,
destination_section_value=node)
supply.validate()
if 0:
# XXX if both a supply line for the resource and a supply cell for
......
......@@ -115,6 +115,7 @@ class TestSaleSupply(TestSupplyMixin, SubcontentReindexingWrapper,
supply = self._makeSupply(start_date_range_min='2009/01/01',
start_date_range_max='2009/01/31')
supply.validate()
supply_line = self._makeSupplyLine(supply)
supply_cell = self._makeSupplyCell(supply_line)
......@@ -169,6 +170,7 @@ class TestSaleSupply(TestSupplyMixin, SubcontentReindexingWrapper,
self.assertNotEquals(original_date, new_date)
supply = self._makeSupply(start_date_range_min=original_date)
supply.validate()
supply_line = self._makeSupplyLine(supply)
kw = {}
......@@ -201,6 +203,7 @@ class TestSaleSupply(TestSupplyMixin, SubcontentReindexingWrapper,
original_date = DateTime().earliestTime()
supply = self._makeSupply(start_date_range_min=original_date)
supply.validate()
supply_line = self._makeSupplyLine(supply)
self.tic()
......@@ -223,6 +226,7 @@ class TestSaleSupply(TestSupplyMixin, SubcontentReindexingWrapper,
supply_line
"""
supply = self._makeSupply(start_date_range_min=DateTime())
supply.validate()
supply_line = self._makeSupplyLine(supply)
supply_line.setSourceReference('my_source_reference')
self.assertEquals(supply_line.getSourceReference(), 'my_source_reference')
......@@ -326,6 +330,7 @@ class TestSaleSupply(TestSupplyMixin, SubcontentReindexingWrapper,
product = self.portal.product_module.newContent(portal_type="Product",
title=self.id())
supply = self._makeSupply()
supply.validate()
supply_line = self._makeSupplyLine(supply, resource_value=product)
another_supply_line = self._makeSupplyLine(supply, resource_value=product)
......
......@@ -63,6 +63,7 @@ class TradeConditionTestCase(ERP5TypeTestCase, SubcontentReindexingWrapper):
self.trade_condition = self.trade_condition_module.newContent(
portal_type=self.trade_condition_type,
title='Trade Condition')
self.trade_condition.validate()
self.order_module = self.portal.getDefaultModule(
self.order_type)
self.order = self.order_module.newContent(
......@@ -282,6 +283,7 @@ class TestTradeConditionSupplyLine(TradeConditionTestCase):
resource_value=self.resource,
source_section_value=self.vendor,
destination_section_value=self.client)
other_supply.validate()
other_supply_line = other_supply.newContent(
portal_type=self.supply_line_type,
base_price=1)
......@@ -307,6 +309,7 @@ class TestTradeConditionSupplyLine(TradeConditionTestCase):
resource_value=self.resource,
source_section_value=self.vendor,
destination_section_value=self.client)
other_supply.validate()
other_supply_line = other_supply.newContent(
portal_type=self.supply_line_type,
base_price=1)
......@@ -317,9 +320,7 @@ class TestTradeConditionSupplyLine(TradeConditionTestCase):
self.order.setSpecialiseValue(self.trade_condition)
self.order.setSourceSectionValue(self.vendor)
self.order.setDestinationSectionValue(self.client)
self.tic()
self.trade_condition.validate()
self.trade_condition.invalidate()
self.tic()
......@@ -339,6 +340,7 @@ class TestTradeConditionSupplyLine(TradeConditionTestCase):
supply = self.portal.getDefaultModule(self.supply_type
).newContent(portal_type=self.supply_type,
resource_value=self.resource,)
supply.validate()
supply_line = supply.newContent(
portal_type=self.supply_line_type,
base_price=1)
......@@ -348,6 +350,7 @@ class TestTradeConditionSupplyLine(TradeConditionTestCase):
resource_value=self.resource,
destination_section_value=self.client,
source_section_value=self.vendor)
other_supply.validate()
other_supply_line = other_supply.newContent(
portal_type=self.supply_line_type,
base_price=2)
......
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