Commit 647142e5 authored by Klaus Wölfel's avatar Klaus Wölfel Committed by Xiaowu Zhang

erp5_trade: Temporarly Revert "stop copying (deprecated) Payment Condition...

erp5_trade: 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 58ab2596
......@@ -79,6 +79,22 @@ else:
context.getPortalAccountingTransactionTypeList():
new_category_dict['resource'] = v
def copyPaymentCondition(order, trade_condition):
filter_dict = {'portal_type': 'Payment Condition'}
to_copy = trade_condition.contentIds(filter=filter_dict)
if len(to_copy) > 0 :
copy_data = trade_condition.manage_copyObjects(ids=to_copy)
order.manage_pasteObjects(copy_data)
for other_trade_condition in trade_condition.getSpecialiseValueList():
copyPaymentCondition(order, other_trade_condition)
filter_dict = {'portal_type': 'Payment Condition'}
if force:
order.manage_delObjects(list(order.contentIds(filter=filter_dict)))
if len(order.contentIds(filter=filter_dict)) == 0:
copyPaymentCondition(order, trade_condition)
# set specialise
new_category_dict['specialise'] = trade_condition.getRelativeUrl()
......
......@@ -6,3 +6,10 @@ if packing_list.getSimulationState() == 'draft':
comment = related_order.getComment(),
title = related_order.getTitle()
)
# copy order's payment conditions
payment_condition_copy_id_list = related_order.contentIds(filter={'portal_type':'Payment Condition'})
if len(payment_condition_copy_id_list) > 0:
clipboard = related_order.manage_copyObjects(
ids=payment_condition_copy_id_list)
packing_list.manage_pasteObjects(clipboard)
......@@ -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