Commit 0bed1d97 authored by Klaus Wölfel's avatar Klaus Wölfel Committed by Jérome Perrin

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 8a19c736
...@@ -133,6 +133,21 @@ else:\n ...@@ -133,6 +133,21 @@ else:\n
context.getPortalAccountingTransactionTypeList():\n context.getPortalAccountingTransactionTypeList():\n
new_category_dict[\'resource\'] = v\n new_category_dict[\'resource\'] = v\n
\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 # set specialise\n
new_category_dict[\'specialise\'] = trade_condition.getRelativeUrl()\n new_category_dict[\'specialise\'] = trade_condition.getRelativeUrl()\n
\n \n
......
...@@ -61,6 +61,12 @@ if packing_list.getSimulationState() == \'draft\':\n ...@@ -61,6 +61,12 @@ if packing_list.getSimulationState() == \'draft\':\n
title = related_order.getTitle()\n title = related_order.getTitle()\n
)\n )\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> ]]></string> </value>
......
...@@ -2698,6 +2698,44 @@ class TestOrder(TestOrderMixin, ERP5TypeTestCase): ...@@ -2698,6 +2698,44 @@ class TestOrder(TestOrderMixin, ERP5TypeTestCase):
self.assertEqual(10 + 20, order.getTotalQuantity()) self.assertEqual(10 + 20, order.getTotalQuantity())
self.assertEqual(10*4 + 20*5, order.getTotalPrice()) 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): def test_Order_viewAsODT(self):
# tests order printout # tests order printout
resource = self.portal.getDefaultModule( resource = self.portal.getDefaultModule(
......
...@@ -160,15 +160,33 @@ class TestApplyTradeCondition(TradeConditionTestCase): ...@@ -160,15 +160,33 @@ class TestApplyTradeCondition(TradeConditionTestCase):
self.assertEqual(self.client, self.order.getDestinationValue()) self.assertEqual(self.client, self.order.getDestinationValue())
self.assertEqual(self.currency, self.order.getPriceCurrencyValue()) 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.setPaymentConditionTradeDate('custom')
self.trade_condition.setPaymentConditionPaymentDate(DateTime(2001, 01, 01)) self.trade_condition.setPaymentConditionPaymentDate(DateTime(2001, 01, 01))
self.order.setSpecialiseValue(self.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.assertEqual(DateTime(2001, 01, 01),
self.order.asComposedDocument().getProperty('payment_condition_payment_date')) self.order.getPaymentConditionPaymentDate())
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)
def test_apply_trade_condition_with_payment_conditions_with_hierarchy(self): 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( other_trade_condition = self.trade_condition_module.newContent(
portal_type=self.trade_condition.getPortalType(), portal_type=self.trade_condition.getPortalType(),
title='Other Trade Condition') title='Other Trade Condition')
...@@ -178,9 +196,12 @@ class TestApplyTradeCondition(TradeConditionTestCase): ...@@ -178,9 +196,12 @@ class TestApplyTradeCondition(TradeConditionTestCase):
self.trade_condition.setSpecialiseValue(other_trade_condition) self.trade_condition.setSpecialiseValue(other_trade_condition)
self.order.setSpecialiseValue(self.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.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): def test_apply_trade_condition_twice_update_order(self):
self.trade_condition.setSourceSectionValue(self.vendor) self.trade_condition.setSourceSectionValue(self.vendor)
...@@ -200,9 +221,9 @@ class TestApplyTradeCondition(TradeConditionTestCase): ...@@ -200,9 +221,9 @@ class TestApplyTradeCondition(TradeConditionTestCase):
self.assertEqual(self.client, self.order.getDestinationSectionValue()) self.assertEqual(self.client, self.order.getDestinationSectionValue())
self.assertEqual(self.client, self.order.getDestinationValue()) self.assertEqual(self.client, self.order.getDestinationValue())
self.assertEqual(self.currency, self.order.getPriceCurrencyValue()) 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.assertEqual(DateTime(2001, 01, 01),
self.order.asComposedDocument().getProperty('payment_condition_payment_date')) self.order.getPaymentConditionPaymentDate())
new_vendor = self.portal.organisation_module.newContent( new_vendor = self.portal.organisation_module.newContent(
portal_type='Organisation', portal_type='Organisation',
...@@ -214,15 +235,14 @@ class TestApplyTradeCondition(TradeConditionTestCase): ...@@ -214,15 +235,14 @@ class TestApplyTradeCondition(TradeConditionTestCase):
payment_condition_payment_date=DateTime(2002, 2, 2)) payment_condition_payment_date=DateTime(2002, 2, 2))
self.order.Order_applyTradeCondition(new_trade_condition, force=1) self.order.Order_applyTradeCondition(new_trade_condition, force=1)
self.tic()
self.assertEqual(new_vendor, self.order.getSourceSectionValue()) self.assertEqual(new_vendor, self.order.getSourceSectionValue())
self.assertEqual(self.vendor, self.order.getSourceValue()) self.assertEqual(self.vendor, self.order.getSourceValue())
self.assertEqual(self.client, self.order.getDestinationSectionValue()) self.assertEqual(self.client, self.order.getDestinationSectionValue())
self.assertEqual(self.client, self.order.getDestinationValue()) self.assertEqual(self.client, self.order.getDestinationValue())
self.assertEqual(self.currency, self.order.getPriceCurrencyValue()) 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.assertEqual(DateTime(2002, 02, 02),
self.order.asComposedDocument().getProperty('payment_condition_payment_date')) self.order.getPaymentConditionPaymentDate())
class TestTradeConditionSupplyLine(TradeConditionTestCase): 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