Commit 17b98031 authored by Klaus Wölfel's avatar Klaus Wölfel Committed by Xiaowu Zhang

Temporarly Revert "stop copying (deprecated) Payment Condition documents from...

Temporarly Revert "stop copying (deprecated) Payment Condition documents from Trade Condition to Order, and from Order to Packing List."

This reverts commit eb5fdbe3.

Conflicts:
	bt5/erp5_trade/bt/revision
	product/ERP5/tests/testTradeCondition.py
parent bede105b
......@@ -48,6 +48,114 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string encoding="cdata"><![CDATA[
order = context\n
\n
# copy categories\n
category_list = [\n
\'source\', \'source_section\', \'source_decision\',\n
\'source_administration\', \'source_payment\', \'source_project\',\n
\'source_carrier\', \'source_referral\', \'source_function\',\n
\'source_trade\',\n
\'destination\', \'destination_section\', \'destination_decision\',\n
\'destination_administration\', \'destination_payment\', \'destination_project\',\n
\'destination_carrier\', \'destination_referral\', \'destination_function\',\n
\'destination_trade\',\n
\'price_currency\', \'incoterm\', \'delivery_mode\',\n
]\n
new_category_dict = {}\n
\n
\n
def getPropertyFromTradeCondition(trade_condition, property_name):\n
"""Get a property from the trade condition, or from a specialised trade\n
condition\n
"""\n
v = trade_condition.getProperty(property_name)\n
if v:\n
return v\n
for specialised_trade_condition in trade_condition.getSpecialiseValueList():\n
v = getPropertyFromTradeCondition(\n
specialised_trade_condition, property_name)\n
if v:\n
return v\n
\n
if not reverse_arrow_category:\n
for category in category_list:\n
if force or not order.getPropertyList(category):\n
v = getPropertyFromTradeCondition(trade_condition, category)\n
if v:\n
new_category_dict[category] = v\n
# for accounting transactions, we also initialize resource with the price\n
# currency\n
if category == \'price_currency\' and \\\n
context.getPortalType() in \\\n
context.getPortalAccountingTransactionTypeList():\n
new_category_dict[\'resource\'] = v\n
else:\n
# Reverse source and destination\n
# This is useful for Returned Sale/Purchase XXX types.\n
reverse_dict = {\n
\'source\':\'destination\',\n
\'source_section\':\'destination_section\',\n
\'source_decision\':\'destination_decision\',\n
\'source_administration\':\'destination_administration\',\n
\'source_payment\':\'destination_payment\',\n
\'source_project\':\'destination_project\',\n
\'source_carrier\':\'destination_carrier\',\n
\'source_referral\':\'destination_referral\',\n
\'source_function\':\'destination_function\',\n
\'destination\':\'source\',\n
\'destination_section\':\'source_section\',\n
\'destination_decision\':\'source_decision\',\n
\'destination_administration\':\'source_administration\',\n
\'destination_payment\':\'source_payment\',\n
\'destination_project\':\'source_project\',\n
\'destination_carrier\':\'source_carrier\',\n
\'destination_referral\':\'source_referral\',\n
\'destination_function\':\'source_function\',\n
}\n
for category in category_list:\n
if force or not order.getPropertyList(category):\n
if category in reverse_dict:\n
trade_condition_category = reverse_dict[category]\n
else:\n
trade_condition_category = category\n
v = getPropertyFromTradeCondition(trade_condition, trade_condition_category)\n
if v:\n
new_category_dict[category] = v\n
# for accounting transactions, we also initialize resource with the price\n
# currency\n
if category == \'price_currency\' and \\\n
context.getPortalType() in \\\n
context.getPortalAccountingTransactionTypeList():\n
new_category_dict[\'resource\'] = v\n
\n
def copyPaymentCondition(order, trade_condition):\n
filter_dict = {\'portal_type\': \'Payment Condition\'}\n
to_copy = trade_condition.contentIds(filter=filter_dict)\n
if len(to_copy) > 0 :\n
copy_data = trade_condition.manage_copyObjects(ids=to_copy)\n
order.manage_pasteObjects(copy_data)\n
for other_trade_condition in trade_condition.getSpecialiseValueList():\n
copyPaymentCondition(order, other_trade_condition)\n
\n
filter_dict = {\'portal_type\': \'Payment Condition\'}\n
if force:\n
order.manage_delObjects(list(order.contentIds(filter=filter_dict)))\n
if len(order.contentIds(filter=filter_dict)) == 0:\n
copyPaymentCondition(order, trade_condition)\n
\n
# set specialise\n
new_category_dict[\'specialise\'] = trade_condition.getRelativeUrl()\n
\n
order.edit(**new_category_dict)\n
]]></string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>trade_condition, force=0, reverse_arrow_category=0</string> </value>
......
......@@ -48,6 +48,29 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string encoding="cdata"><![CDATA[
packing_list = context\n
related_order = packing_list.getCausalityValue()\n
\n
if packing_list.getSimulationState() == \'draft\':\n
packing_list.edit(\n
comment = related_order.getComment(),\n
title = related_order.getTitle()\n
)\n
\n
# copy order\'s payment conditions\n
payment_condition_copy_id_list = related_order.contentIds(filter={\'portal_type\':\'Payment Condition\'})\n
if len(payment_condition_copy_id_list) > 0:\n
clipboard = related_order.manage_copyObjects(\n
ids=payment_condition_copy_id_list)\n
packing_list.manage_pasteObjects(clipboard)\n
]]></string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
......
......@@ -2720,6 +2720,44 @@ class TestOrder(TestOrderMixin, ERP5TypeTestCase):
self.assertEqual(10 + 20, order.getTotalQuantity())
self.assertEqual(10*4 + 20*5, order.getTotalPrice())
def test_order_payment_condition_copied(self):
# Payment Condition should be copied in the packing list
resource = self.portal.getDefaultModule(
self.resource_portal_type).newContent(
portal_type=self.resource_portal_type,
title='Resource',)
client = self.portal.organisation_module.newContent(
portal_type='Organisation', title='Client')
vendor = self.portal.organisation_module.newContent(
portal_type='Organisation', title='Vendor')
order = self.portal.getDefaultModule(self.order_portal_type).newContent(
portal_type=self.order_portal_type,
specialise=self.business_process,
title='Order',
start_date=self.datetime,
source_value=vendor,
source_section_value=vendor,
destination_value=client,
destination_section_value=client)
line = order.newContent(portal_type=self.order_line_portal_type,
resource_value=resource,
quantity=10,
price=3)
# set properties, on the default payment condition
order.setDefaultPaymentConditionQuantity(10)
self.assertEqual(1, len(order.contentValues(
portal_type='Payment Condition')))
order.confirm()
self.tic()
self.stepPackingListBuilderAlarm()
self.tic()
related_packing_list = order.getCausalityRelatedValue(
portal_type=self.packing_list_portal_type)
self.assertNotEquals(related_packing_list, None)
self.assertEqual(1, len(related_packing_list.contentValues(
portal_type='Payment Condition')))
def test_Order_viewAsODT(self):
# tests order printout
resource = self.portal.getDefaultModule(
......
......@@ -160,15 +160,33 @@ class TestApplyTradeCondition(TradeConditionTestCase):
self.assertEqual(self.client, self.order.getDestinationValue())
self.assertEqual(self.currency, self.order.getPriceCurrencyValue())
def test_apply_trade_condition_with_payment_conditions(self):
def test_apply_trade_condition_copy_subobjects(self):
self.trade_condition.setPaymentConditionTradeDate('custom')
self.trade_condition.setPaymentConditionPaymentDate(DateTime(2001, 01, 01))
self.order.setSpecialiseValue(self.trade_condition)
self.assertEqual('custom', self.order.asComposedDocument().getProperty('payment_condition_trade_date'))
self.order.Order_applyTradeCondition(self.trade_condition, force=1)
self.assertEqual('custom', self.order.getPaymentConditionTradeDate())
self.assertEqual(DateTime(2001, 01, 01),
self.order.asComposedDocument().getProperty('payment_condition_payment_date'))
self.order.getPaymentConditionPaymentDate())
def test_apply_trade_condition_with_payment_conditions_with_hierarchy(self):
def test_apply_twice_trade_condition_copy_subobjects(self):
self.trade_condition.setPaymentConditionTradeDate('custom')
self.trade_condition.setPaymentConditionPaymentDate(DateTime(2001, 01, 01))
self.order.setSpecialiseValue(self.trade_condition)
self.order.Order_applyTradeCondition(self.trade_condition, force=1)
self.assertEqual(1, len(self.order.contentValues(
portal_type='Payment Condition')))
self.assertEqual('custom', self.order.getPaymentConditionTradeDate())
self.assertEqual(DateTime(2001, 01, 01),
self.order.getPaymentConditionPaymentDate())
self.order.Order_applyTradeCondition(self.trade_condition, force=1)
self.assertEqual(1, len(self.order.contentValues(
portal_type='Payment Condition')))
def test_apply_trade_condition_copy_subobjects_with_hierarchy(self):
other_trade_condition = self.trade_condition_module.newContent(
portal_type=self.trade_condition.getPortalType(),
title='Other Trade Condition')
......@@ -178,9 +196,12 @@ class TestApplyTradeCondition(TradeConditionTestCase):
self.trade_condition.setSpecialiseValue(other_trade_condition)
self.order.setSpecialiseValue(self.trade_condition)
self.assertEqual('custom', self.order.asComposedDocument().getProperty('payment_condition_trade_date'))
self.order.Order_applyTradeCondition(self.trade_condition, force=1)
self.assertEqual('custom', self.order.getPaymentConditionTradeDate())
self.assertEqual(DateTime(2001, 01, 01),
self.order.asComposedDocument().getProperty('payment_condition_payment_date'))
self.order.getPaymentConditionPaymentDate())
def test_apply_trade_condition_twice_update_order(self):
self.trade_condition.setSourceSectionValue(self.vendor)
......@@ -200,9 +221,9 @@ class TestApplyTradeCondition(TradeConditionTestCase):
self.assertEqual(self.client, self.order.getDestinationSectionValue())
self.assertEqual(self.client, self.order.getDestinationValue())
self.assertEqual(self.currency, self.order.getPriceCurrencyValue())
self.assertEqual('custom', self.order.asComposedDocument().getProperty('payment_condition_trade_date'))
self.assertEqual('custom', self.order.getPaymentConditionTradeDate())
self.assertEqual(DateTime(2001, 01, 01),
self.order.asComposedDocument().getProperty('payment_condition_payment_date'))
self.order.getPaymentConditionPaymentDate())
new_vendor = self.portal.organisation_module.newContent(
portal_type='Organisation',
......@@ -214,15 +235,14 @@ class TestApplyTradeCondition(TradeConditionTestCase):
payment_condition_payment_date=DateTime(2002, 2, 2))
self.order.Order_applyTradeCondition(new_trade_condition, force=1)
self.tic()
self.assertEqual(new_vendor, self.order.getSourceSectionValue())
self.assertEqual(self.vendor, self.order.getSourceValue())
self.assertEqual(self.client, self.order.getDestinationSectionValue())
self.assertEqual(self.client, self.order.getDestinationValue())
self.assertEqual(self.currency, self.order.getPriceCurrencyValue())
self.assertEqual('custom', self.order.asComposedDocument().getProperty('payment_condition_trade_date'))
self.assertEqual('custom', self.order.getPaymentConditionTradeDate())
self.assertEqual(DateTime(2002, 02, 02),
self.order.asComposedDocument().getProperty('payment_condition_payment_date'))
self.order.getPaymentConditionPaymentDate())
class TestTradeConditionSupplyLine(TradeConditionTestCase):
......
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