Commit 7505e054 authored by Xiaowu Zhang's avatar Xiaowu Zhang

erp5_invoicing: enable "Merge Deliveries" action on accounting module

/reviewed-on !876
parents 17c0aa5a d2f4dd44
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ActionInformation" module="Products.CMFCore.ActionInformation"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>action</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>action_type/object_action</string>
</tuple>
</value>
</item>
<item>
<key> <string>category</string> </key>
<value> <string>object_action</string> </value>
</item>
<item>
<key> <string>condition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>icon</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>merge_delivery_list</string> </value>
</item>
<item>
<key> <string>permissions</string> </key>
<value>
<tuple>
<string>Add portal content</string>
</tuple>
</value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Action Information</string> </value>
</item>
<item>
<key> <string>priority</string> </key>
<value> <float>5.0</float> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Merge Deliveries</string> </value>
</item>
<item>
<key> <string>visible</string> </key>
<value> <int>1</int> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="Expression" module="Products.CMFCore.Expression"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>text</string> </key>
<value> <string>string:${object_url}/DeliveryModule_mergeDeliveryList</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
Accounting Transaction Module | merge_delivery_list
Invoice Line | price Invoice Line | price
Invoice Line | quantity Invoice Line | quantity
Invoice Line | view Invoice Line | view
......
...@@ -5,12 +5,15 @@ delivery_list = [] ...@@ -5,12 +5,15 @@ delivery_list = []
for o in object_list: for o in object_list:
delivery_list.append(o) delivery_list.append(o)
Base_translateString = context.Base_translateString
if len(delivery_list) < 2: if len(delivery_list) < 2:
ret_url = context.absolute_url() + '/' + form_id message = Base_translateString('Please select more than one items.')
qs = '?portal_status_message=Please+select+more+than+one+items.'
else: else:
ret_url = context.absolute_url() + '/' + form_id error_list = context.portal_simulation.mergeDeliveryList(delivery_list)
qs = '?portal_status_message=Merged.' if not error_list:
context.portal_simulation.mergeDeliveryList(delivery_list) message = Base_translateString('Merged.')
else:
message = ' '.join([str(x) for x in error_list])
return REQUEST.RESPONSE.redirect( ret_url + qs ) return context.Base_redirect('view',keep_items={'portal_status_message': message})
This diff is collapsed.
...@@ -2471,6 +2471,63 @@ self.portal.getDefaultModule(self.packing_list_portal_type).newContent( ...@@ -2471,6 +2471,63 @@ self.portal.getDefaultModule(self.packing_list_portal_type).newContent(
self.assertEqual([], packing_list.getDivergenceList()) self.assertEqual([], packing_list.getDivergenceList())
self.assertEqual('solved', packing_list.getCausalityState()) self.assertEqual('solved', packing_list.getCausalityState())
def test_merge_accounting_invoice(
self, quiet=quiet):
sequence_list = SequenceList()
sequence = sequence_list.addSequenceString(self.PACKING_LIST_DEFAULT_SEQUENCE)
sequence_list.play(self, quiet=quiet)
packing_list = sequence.get('packing_list')
packing_list_line = packing_list.getMovementList()[0]
quantity = packing_list_line.getQuantity()
resource = packing_list_line.getResource()
price = packing_list_line.getPrice()
packing_list.setReady()
packing_list.start()
packing_list.stop()
self.tic()
self.default_quantity = self.default_quantity + 10
self.default_price = self.default_price + 10
self.tic()
sequence_list.play(self, quiet=quiet)
packing_list_2 = sequence.get('packing_list')
packing_list_line = packing_list_2.getMovementList()[0]
quantity_2 = packing_list_line.getQuantity()
resource_2 = packing_list_line.getResource()
price_2 = packing_list_line.getPrice()
packing_list_2.setReady()
packing_list_2.start()
packing_list_2.stop()
self.tic()
self.stepInvoiceBuilderAlarm()
self.tic()
self.default_quantity = self.default_quantity - 10
self.default_price = self.default_price - 10
invoice = packing_list.getCausalityRelatedValue(
portal_type=self.invoice_portal_type)
invoice_2 = packing_list_2.getCausalityRelatedValue(
portal_type=self.invoice_portal_type)
self.assertNotEquals(invoice, None)
self.assertNotEquals(invoice_2, None)
self.tic()
error_list = self.portal.portal_simulation.mergeDeliveryList([invoice, invoice_2])
self.tic()
self.assertEqual(0, len(error_list))
self.assertEqual(invoice.getSimulationState(), 'confirmed')
# MergeDeliveryList change the first delivery to diverged
# Make sure it works as expected
self.assertEqual(invoice.getCausalityState(), 'diverged')
self.assertEqual(invoice_2.getSimulationState(), 'cancelled')
self.assertEqual(len(invoice.getMovementList()), 2)
expected_set = set([
(resource,quantity,price),
(resource_2, quantity_2,price_2)])
result_set = set(sorted(
[(x.getResource(), x.getQuantity(), x.getPrice()) for x in invoice.getMovementList()],
key=lambda x: x[1]))
self.assertEqual(expected_set, result_set)
def test_subcontent_reindexing(self): def test_subcontent_reindexing(self):
"""Tests, that modification on Order are propagated to lines and cells """Tests, that modification on Order are propagated to lines and cells
......
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