Commit 7a2a0544 authored by Romain Courteaud's avatar Romain Courteaud

Use the invoicing workflow on Hosting Subscription.

Simplify the logic to find which Hosting Subscription changed.
parent 0756f69b
......@@ -51,12 +51,11 @@
<item>
<key> <string>_body</string> </key>
<value> <string>portal = context.getPortalObject()\n
path_list = [q.PATH for q in portal.Base_getHostingSubscriptionForOpenSaleOrderLine(hosting_subscription_validation_state=\'validated\', open_sale_order_line_validation_state=\'validated\')]\n
path_list.extend([q.PATH for q in portal.Base_getHostingSubscriptionForOpenSaleOrderLine(hosting_subscription_validation_state=\'archived\', open_sale_order_line_validation_state=\'invalidated\')])\n
\n
portal.portal_catalog.searchAndActivate(\n
method_id=\'HostingSubscription_requestUpdateOpenSaleOrder\',\n
path=path_list,\n
portal_type="Hosting Subscription",\n
causality_state="diverged",\n
activate_kw={\'tag\': tag},\n
packet_size=1, # HostingSubscription_trigger_Person_storeOpenSaleOrderJournal\n
)\n
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="SQL" module="Products.ZSQLMethods.SQL"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>allow_simple_one_argument_traversal</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>arguments_src</string> </key>
<value> <string>hosting_subscription_validation_state\r\n
open_sale_order_line_validation_state</string> </value>
</item>
<item>
<key> <string>cache_time_</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>class_file_</string> </key>
<value> <string>ZSQLCatalog.zsqlbrain</string> </value>
</item>
<item>
<key> <string>class_name_</string> </key>
<value> <string>ZSQLBrain</string> </value>
</item>
<item>
<key> <string>connection_hook</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>connection_id</string> </key>
<value> <string>erp5_sql_connection</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Base_getHostingSubscriptionForOpenSaleOrderLine</string> </value>
</item>
<item>
<key> <string>max_cache_</string> </key>
<value> <int>100</int> </value>
</item>
<item>
<key> <string>max_rows_</string> </key>
<value> <int>1000</int> </value>
</item>
<item>
<key> <string>src</string> </key>
<value> <string encoding="cdata"><![CDATA[
SELECT\n
catalog.uid, catalog.path\n
FROM catalog\n
LEFT JOIN category ON category.category_uid=catalog.uid AND category.base_category_uid=<dtml-var "portal_categories.aggregate.getUid()">\n
LEFT JOIN catalog AS order_catalog ON order_catalog.uid=category.uid AND order_catalog.portal_type=\'Open Sale Order Line\' AND order_catalog.validation_state=<dtml-sqlvar open_sale_order_line_validation_state type="string">\n
WHERE catalog.portal_type=\'Hosting Subscription\' and catalog.validation_state=<dtml-sqlvar hosting_subscription_validation_state type="string">\n
GROUP BY catalog.uid\n
HAVING count(order_catalog.uid) = 0\n
]]></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -53,6 +53,7 @@
<value> <string>person = context.getDestinationSectionValue()\n
if person is not None:\n
person.Person_storeOpenSaleOrderJournal()\n
context.converge()\n
</string> </value>
</item>
<item>
......
......@@ -83,11 +83,10 @@ class TestOpenSaleOrderAlarm(testSlapOSMixin):
for q in open_sale_order_template.getCategoryList()]))
@simulateHostingSubscription_requestUpdateOpenSaleOrder
def test_alarm_HS_validated(self):
def test_alarm_HS_diverged(self):
subscription = self.portal.hosting_subscription_module\
.template_hosting_subscription.Base_createCloneDocument(batch_mode=1)
subscription.edit(reference='TESTHS-%s' % self.generateNewId())
self.portal.portal_workflow._jumpToStateFor(subscription, 'validated')
self.tic()
self.portal.portal_alarms\
......@@ -98,114 +97,6 @@ class TestOpenSaleOrderAlarm(testSlapOSMixin):
'Visited by HostingSubscription_requestUpdateOpenSaleOrder',
subscription.workflow_history['edit_workflow'][-1]['comment'])
@simulateHostingSubscription_requestUpdateOpenSaleOrder
def test_alarm_HS_validated_OSO_invalidated(self):
subscription = self.portal.hosting_subscription_module\
.template_hosting_subscription.Base_createCloneDocument(batch_mode=1)
subscription.edit(reference='TESTHS-%s' % self.generateNewId())
self.portal.portal_workflow._jumpToStateFor(subscription, 'validated')
open_sale_order = self.portal.open_sale_order_module\
.template_open_sale_order.Base_createCloneDocument(batch_mode=1)
open_sale_order.edit(reference='TESTOSO-%s' % self.generateNewId())
open_sale_order.newContent(portal_type='Open Sale Order Line',
aggregate=subscription.getRelativeUrl())
self.portal.portal_workflow._jumpToStateFor(open_sale_order, 'invalidated')
self.tic()
self.portal.portal_alarms\
.slapos_request_update_hosting_subscription_open_sale_order\
.activeSense()
self.tic()
self.assertEqual(
'Visited by HostingSubscription_requestUpdateOpenSaleOrder',
subscription.workflow_history['edit_workflow'][-1]['comment'])
@simulateHostingSubscription_requestUpdateOpenSaleOrder
def test_alarm_HS_archived(self):
subscription = self.portal.hosting_subscription_module\
.template_hosting_subscription.Base_createCloneDocument(batch_mode=1)
subscription.edit(reference='TESTHS-%s' % self.generateNewId())
self.portal.portal_workflow._jumpToStateFor(subscription, 'archived')
self.tic()
self.portal.portal_alarms\
.slapos_request_update_hosting_subscription_open_sale_order\
.activeSense()
self.tic()
self.assertEqual(
'Visited by HostingSubscription_requestUpdateOpenSaleOrder',
subscription.workflow_history['edit_workflow'][-1]['comment'])
@simulateHostingSubscription_requestUpdateOpenSaleOrder
def test_alarm_HS_archived_OSO_validated(self):
subscription = self.portal.hosting_subscription_module\
.template_hosting_subscription.Base_createCloneDocument(batch_mode=1)
subscription.edit(reference='TESTHS-%s' % self.generateNewId())
self.portal.portal_workflow._jumpToStateFor(subscription, 'archived')
open_sale_order = self.portal.open_sale_order_module\
.template_open_sale_order.Base_createCloneDocument(batch_mode=1)
open_sale_order.edit(reference='TESTOSO-%s' % self.generateNewId())
open_sale_order.newContent(portal_type='Open Sale Order Line',
aggregate=subscription.getRelativeUrl())
self.portal.portal_workflow._jumpToStateFor(open_sale_order, 'validated')
self.tic()
self.portal.portal_alarms\
.slapos_request_update_hosting_subscription_open_sale_order\
.activeSense()
self.tic()
self.assertEqual(
'Visited by HostingSubscription_requestUpdateOpenSaleOrder',
subscription.workflow_history['edit_workflow'][-1]['comment'])
@simulateHostingSubscription_requestUpdateOpenSaleOrder
def test_alarm_HS_validated_OSO_validated(self):
subscription = self.portal.hosting_subscription_module\
.template_hosting_subscription.Base_createCloneDocument(batch_mode=1)
subscription.edit(reference='TESTHS-%s' % self.generateNewId())
self.portal.portal_workflow._jumpToStateFor(subscription, 'validated')
open_sale_order = self.portal.open_sale_order_module\
.template_open_sale_order.Base_createCloneDocument(batch_mode=1)
open_sale_order.edit(reference='TESTOSO-%s' % self.generateNewId())
open_sale_order.newContent(portal_type='Open Sale Order Line',
aggregate=subscription.getRelativeUrl())
self.portal.portal_workflow._jumpToStateFor(open_sale_order, 'validated')
self.tic()
self.portal.portal_alarms\
.slapos_request_update_hosting_subscription_open_sale_order\
.activeSense()
self.tic()
self.assertNotEqual(
'Visited by HostingSubscription_requestUpdateOpenSaleOrder',
subscription.workflow_history['edit_workflow'][-1]['comment'])
@simulateHostingSubscription_requestUpdateOpenSaleOrder
def test_alarm_HS_archived_OSO_invalidated(self):
subscription = self.portal.hosting_subscription_module\
.template_hosting_subscription.Base_createCloneDocument(batch_mode=1)
subscription.edit(reference='TESTHS-%s' % self.generateNewId())
self.portal.portal_workflow._jumpToStateFor(subscription, 'archived')
open_sale_order = self.portal.open_sale_order_module\
.template_open_sale_order.Base_createCloneDocument(batch_mode=1)
open_sale_order.edit(reference='TESTOSO-%s' % self.generateNewId())
open_sale_order.newContent(portal_type='Open Sale Order Line',
aggregate=subscription.getRelativeUrl())
self.portal.portal_workflow._jumpToStateFor(open_sale_order, 'invalidated')
self.tic()
self.portal.portal_alarms\
.slapos_request_update_hosting_subscription_open_sale_order\
.activeSense()
self.tic()
self.assertNotEqual(
'Visited by HostingSubscription_requestUpdateOpenSaleOrder',
subscription.workflow_history['edit_workflow'][-1]['comment'])
class TestHostingSubscription_requestUpdateOpenSaleOrder(testSlapOSMixin):
def test_empty_HostingSubscription(self):
person = self.portal.person_module.template_member\
......@@ -220,6 +111,7 @@ class TestHostingSubscription_requestUpdateOpenSaleOrder(testSlapOSMixin):
subscription.HostingSubscription_requestUpdateOpenSaleOrder()
self.tic()
self.assertEqual(subscription.getCausalityState(), 'solved')
open_sale_order_list = self.portal.portal_catalog(
portal_type='Open Sale Order',
......@@ -273,6 +165,7 @@ class TestHostingSubscription_requestUpdateOpenSaleOrder(testSlapOSMixin):
subscription.HostingSubscription_requestUpdateOpenSaleOrder()
self.tic()
self.assertEqual(subscription.getCausalityState(), 'solved')
open_sale_order_list = self.portal.portal_catalog(
portal_type='Open Sale Order',
......@@ -320,6 +213,7 @@ class TestHostingSubscription_requestUpdateOpenSaleOrder(testSlapOSMixin):
'time': destroy_time,
'action': 'request_destroy'
})
subscription.diverge()
self.tic()
subscription.HostingSubscription_requestUpdateOpenSaleOrder()
......@@ -401,6 +295,7 @@ class TestHostingSubscription_requestUpdateOpenSaleOrder(testSlapOSMixin):
subscription.HostingSubscription_requestUpdateOpenSaleOrder()
self.tic()
self.assertEqual(subscription.getCausalityState(), 'solved')
open_sale_order_list = self.portal.portal_catalog(
portal_type='Open Sale Order',
......@@ -460,6 +355,7 @@ class TestHostingSubscription_requestUpdateOpenSaleOrder(testSlapOSMixin):
subscription.HostingSubscription_requestUpdateOpenSaleOrder()
self.tic()
self.assertEqual(subscription.getCausalityState(), 'solved')
open_sale_order_list = self.portal.portal_catalog(
portal_type='Open Sale Order',
......
71
\ No newline at end of file
72
\ No newline at end of file
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