Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Titouan Soulard
slapos.core
Commits
07918d75
Commit
07918d75
authored
Jun 20, 2023
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos_accounting: add an alarm to close the open order
parent
8acc38fa
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
306 additions
and
6 deletions
+306
-6
master/bt5/slapos_accounting/PathTemplateItem/portal_alarms/slapos_archive_open_sale_order_with_unused_item.xml
...larms/slapos_archive_open_sale_order_with_unused_item.xml
+113
-0
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_accounting/Alarm_archiveOpenSaleOrderWithUnusedItem.py
...os_accounting/Alarm_archiveOpenSaleOrderWithUnusedItem.py
+9
-0
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_accounting/Alarm_archiveOpenSaleOrderWithUnusedItem.xml
...s_accounting/Alarm_archiveOpenSaleOrderWithUnusedItem.xml
+62
-0
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_accounting/OpenSaleOrder_archiveIfUnusedItem.py
...ns/slapos_accounting/OpenSaleOrder_archiveIfUnusedItem.py
+42
-0
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_accounting/OpenSaleOrder_archiveIfUnusedItem.xml
...s/slapos_accounting/OpenSaleOrder_archiveIfUnusedItem.xml
+62
-0
master/bt5/slapos_accounting/WorkflowTemplateItem/portal_workflow/slapos_accounting_interaction_workflow/interaction_InstanceTree_changePromiseState.xml
..._workflow/interaction_InstanceTree_changePromiseState.xml
+4
-2
master/bt5/slapos_accounting/WorkflowTemplateItem/portal_workflow/slapos_accounting_interaction_workflow/script_Base_diverge.py
...os_accounting_interaction_workflow/script_Base_diverge.py
+0
-3
master/bt5/slapos_accounting/WorkflowTemplateItem/portal_workflow/slapos_accounting_interaction_workflow/script_Base_triggerArchiveOpenSaleOrderAlarm.py
..._workflow/script_Base_triggerArchiveOpenSaleOrderAlarm.py
+6
-0
master/bt5/slapos_accounting/WorkflowTemplateItem/portal_workflow/slapos_accounting_interaction_workflow/script_Base_triggerArchiveOpenSaleOrderAlarm.xml
...workflow/script_Base_triggerArchiveOpenSaleOrderAlarm.xml
+7
-1
master/bt5/slapos_accounting/bt/template_path_list
master/bt5/slapos_accounting/bt/template_path_list
+1
-0
No files found.
master/bt5/slapos_accounting/PathTemplateItem/portal_alarms/slapos_archive_open_sale_order_with_unused_item.xml
0 → 100644
View file @
07918d75
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"Alarm"
module=
"erp5.portal_type"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
active_sense_method_id
</string>
</key>
<value>
<string>
Alarm_archiveOpenSaleOrderWithUnusedItem
</string>
</value>
</item>
<item>
<key>
<string>
automatic_solve
</string>
</key>
<value>
<int>
0
</int>
</value>
</item>
<item>
<key>
<string>
description
</string>
</key>
<value>
<none/>
</value>
</item>
<item>
<key>
<string>
enabled
</string>
</key>
<value>
<int>
1
</int>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
slapos_archive_open_sale_order_with_unused_item
</string>
</value>
</item>
<item>
<key>
<string>
periodicity_day_frequency
</string>
</key>
<value>
<int>
1
</int>
</value>
</item>
<item>
<key>
<string>
periodicity_hour
</string>
</key>
<value>
<tuple>
<int>
4
</int>
</tuple>
</value>
</item>
<item>
<key>
<string>
periodicity_hour_frequency
</string>
</key>
<value>
<none/>
</value>
</item>
<item>
<key>
<string>
periodicity_minute
</string>
</key>
<value>
<tuple>
<int>
4
</int>
</tuple>
</value>
</item>
<item>
<key>
<string>
periodicity_minute_frequency
</string>
</key>
<value>
<none/>
</value>
</item>
<item>
<key>
<string>
periodicity_month
</string>
</key>
<value>
<tuple/>
</value>
</item>
<item>
<key>
<string>
periodicity_month_day
</string>
</key>
<value>
<tuple/>
</value>
</item>
<item>
<key>
<string>
periodicity_start_date
</string>
</key>
<value>
<object>
<klass>
<global
name=
"_reconstructor"
module=
"copy_reg"
/>
</klass>
<tuple>
<global
name=
"DateTime"
module=
"DateTime.DateTime"
/>
<global
name=
"object"
module=
"__builtin__"
/>
<none/>
</tuple>
<state>
<tuple>
<float>
-4861728000.0
</float>
<string>
GMT
</string>
</tuple>
</state>
</object>
</value>
</item>
<item>
<key>
<string>
periodicity_week
</string>
</key>
<value>
<tuple/>
</value>
</item>
<item>
<key>
<string>
portal_type
</string>
</key>
<value>
<string>
Alarm
</string>
</value>
</item>
<item>
<key>
<string>
title
</string>
</key>
<value>
<string>
Archive Open Sale Order
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_accounting/Alarm_archiveOpenSaleOrderWithUnusedItem.py
0 → 100644
View file @
07918d75
portal
=
context
.
getPortalObject
()
portal
.
portal_catalog
.
searchAndActivate
(
portal_type
=
'Open Sale Order'
,
validation_state
=
'validated'
,
ledger__uid
=
portal
.
portal_categories
.
ledger
.
automated
.
getUid
(),
method_id
=
'OpenSaleOrder_archiveIfUnusedItem'
,
activate_kw
=
{
'tag'
:
tag
}
)
context
.
activate
(
after_tag
=
tag
).
getId
()
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_accounting/Alarm_archiveOpenSaleOrderWithUnusedItem.xml
0 → 100644
View file @
07918d75
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"PythonScript"
module=
"Products.PythonScripts.PythonScript"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
_bind_names
</string>
</key>
<value>
<object>
<klass>
<global
name=
"_reconstructor"
module=
"copy_reg"
/>
</klass>
<tuple>
<global
name=
"NameAssignments"
module=
"Shared.DC.Scripts.Bindings"
/>
<global
name=
"object"
module=
"__builtin__"
/>
<none/>
</tuple>
<state>
<dictionary>
<item>
<key>
<string>
_asgns
</string>
</key>
<value>
<dictionary>
<item>
<key>
<string>
name_container
</string>
</key>
<value>
<string>
container
</string>
</value>
</item>
<item>
<key>
<string>
name_context
</string>
</key>
<value>
<string>
context
</string>
</value>
</item>
<item>
<key>
<string>
name_m_self
</string>
</key>
<value>
<string>
script
</string>
</value>
</item>
<item>
<key>
<string>
name_subpath
</string>
</key>
<value>
<string>
traverse_subpath
</string>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key>
<string>
_params
</string>
</key>
<value>
<string>
tag, fixit, params
</string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
Alarm_archiveOpenSaleOrderWithUnusedItem
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_accounting/OpenSaleOrder_archiveIfUnusedItem.py
0 → 100644
View file @
07918d75
open_sale_order
=
context
if
open_sale_order
.
getValidationState
()
!=
'validated'
:
return
if
open_sale_order
.
getLedger
()
!=
'automated'
:
raise
ValueError
(
'Can only archive automated open sale order'
)
for
open_order_line
in
open_sale_order
.
contentValues
(
portal_type
=
'Open Sale Order Line'
):
content_list
=
open_order_line
.
contentValues
()
if
len
(
content_list
)
==
0
:
content_list
=
[
open_order_line
]
for
open_order_cell
in
content_list
:
item
=
open_order_cell
.
getAggregateValue
(
portal_type
=
[
'Instance Tree'
,
'Compute Node'
,
'Project'
])
if
item
is
None
:
raise
AssertionError
(
'No matching item on: %s'
%
open_order_cell
.
getRelativeUrl
())
elif
item
.
getPortalType
()
==
'Instance Tree'
:
if
item
.
getSlapState
()
!=
'destroy_requested'
:
# Do not touch if the instance is still started/stopped
return
elif
item
.
getPortalType
()
==
'Compute Node'
:
# XXX TODO how to officially close a Compute Node
#raise NotImplementedError('what is the finished state for Compute Node')
return
elif
item
.
getPortalType
()
==
'Project'
:
# Do not close project for now
return
else
:
raise
KeyError
(
'Unexpected portal type: %s on %s'
%
(
item
.
getPortalType
(),
open_order_cell
.
getRelativeUrl
()))
# if the script didn't return before, we can archive the open sale order
now
=
DateTime
()
open_sale_order
.
edit
(
stop_date
=
now
)
open_sale_order
.
archive
(
comment
=
'No item in used anymore'
)
return
open_sale_order
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_accounting/OpenSaleOrder_archiveIfUnusedItem.xml
0 → 100644
View file @
07918d75
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"PythonScript"
module=
"Products.PythonScripts.PythonScript"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
_bind_names
</string>
</key>
<value>
<object>
<klass>
<global
name=
"_reconstructor"
module=
"copy_reg"
/>
</klass>
<tuple>
<global
name=
"NameAssignments"
module=
"Shared.DC.Scripts.Bindings"
/>
<global
name=
"object"
module=
"__builtin__"
/>
<none/>
</tuple>
<state>
<dictionary>
<item>
<key>
<string>
_asgns
</string>
</key>
<value>
<dictionary>
<item>
<key>
<string>
name_container
</string>
</key>
<value>
<string>
container
</string>
</value>
</item>
<item>
<key>
<string>
name_context
</string>
</key>
<value>
<string>
context
</string>
</value>
</item>
<item>
<key>
<string>
name_m_self
</string>
</key>
<value>
<string>
script
</string>
</value>
</item>
<item>
<key>
<string>
name_subpath
</string>
</key>
<value>
<string>
traverse_subpath
</string>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key>
<string>
_params
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
OpenSaleOrder_archiveIfUnusedItem
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
master/bt5/slapos_accounting/WorkflowTemplateItem/portal_workflow/slapos_accounting_interaction_workflow/interaction_InstanceTree_changePromiseState.xml
View file @
07918d75
...
...
@@ -10,7 +10,7 @@
<key>
<string>
categories
</string>
</key>
<value>
<tuple>
<string>
after_script/portal_workflow/slapos_accounting_interaction_workflow/script_Base_
diverge
</string>
<string>
after_script/portal_workflow/slapos_accounting_interaction_workflow/script_Base_
triggerArchiveOpenSaleOrderAlarm
</string>
</tuple>
</value>
</item>
...
...
@@ -31,7 +31,9 @@
<item>
<key>
<string>
portal_type_filter
</string>
</key>
<value>
<tuple/>
<tuple>
<string>
Instance Tree
</string>
</tuple>
</value>
</item>
<item>
...
...
master/bt5/slapos_accounting/WorkflowTemplateItem/portal_workflow/slapos_accounting_interaction_workflow/script_Base_diverge.py
deleted
100644 → 0
View file @
8acc38fa
document
=
state_change
[
"object"
]
if
document
.
getPortalObject
().
portal_workflow
.
isTransitionPossible
(
document
,
'diverge'
):
document
.
diverge
()
master/bt5/slapos_accounting/WorkflowTemplateItem/portal_workflow/slapos_accounting_interaction_workflow/script_Base_triggerArchiveOpenSaleOrderAlarm.py
0 → 100644
View file @
07918d75
base
=
state_change
[
'object'
]
portal
=
base
.
getPortalObject
()
tag
=
script
.
id
base
.
reindexObject
(
activate_kw
=
{
'tag'
:
tag
})
context
.
Alarm_safeTrigger
(
portal
.
portal_alarms
.
slapos_archive_open_sale_order_with_unused_item
,
{
'after_tag'
:
tag
})
master/bt5/slapos_accounting/WorkflowTemplateItem/portal_workflow/slapos_accounting_interaction_workflow/script_Base_
diverge
.xml
→
master/bt5/slapos_accounting/WorkflowTemplateItem/portal_workflow/slapos_accounting_interaction_workflow/script_Base_
triggerArchiveOpenSaleOrderAlarm
.xml
View file @
07918d75
...
...
@@ -52,9 +52,15 @@
<key>
<string>
_params
</string>
</key>
<value>
<string>
state_change
</string>
</value>
</item>
<item>
<key>
<string>
description
</string>
</key>
<value>
<none/>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
script_Base_
diverge
</string>
</value>
<value>
<string>
script_Base_
triggerArchiveOpenSaleOrderAlarm
</string>
</value>
</item>
<item>
<key>
<string>
portal_type
</string>
</key>
...
...
master/bt5/slapos_accounting/bt/template_path_list
View file @
07918d75
...
...
@@ -16,6 +16,7 @@ business_process_module/slapos_ultimate_business_process/**
currency_module/CNY
currency_module/EUR
portal_alarms/slapos_accounting_generate_packing_list_from_tioxml
portal_alarms/slapos_archive_open_sale_order_with_unused_item
portal_alarms/slapos_cancel_sale_invoice_transaction_paied_payment_list
portal_alarms/slapos_contract_request_validation_payment
portal_alarms/slapos_manage_building_calculating_delivery
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment