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
1
Merge Requests
1
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
Romain Courteaud
slapos.core
Commits
fa6949dd
Commit
fa6949dd
authored
Sep 22, 2022
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos_accounting: do not crash if open order line is not linked to an instance
parent
a6c987e0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
26 deletions
+28
-26
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_accounting/OpenSaleOrder_updatePeriod.py
...tal_skins/slapos_accounting/OpenSaleOrder_updatePeriod.py
+28
-26
No files found.
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_accounting/OpenSaleOrder_updatePeriod.py
View file @
fa6949dd
...
...
@@ -58,31 +58,33 @@ if open_sale_order.getValidationState() == 'validated':
hosting_subscription
=
open_order_line
.
getAggregateValue
(
portal_type
=
'Hosting Subscription'
)
instance_tree
=
open_order_line
.
getAggregateValue
(
portal_type
=
'Instance Tree'
)
assert
current_start_date
==
hosting_subscription
.
HostingSubscription_calculateSubscriptionStartDate
()
subscription_request
=
instance_tree
.
getAggregateRelatedValue
(
portal_type
=
"Subscription Request"
)
# Define the start date of the period, this can variates with the time.
next_stop_date_delta
=
0
if
subscription_request
is
not
None
:
next_stop_date_delta
=
46
# First check if the instance tree has been correctly simulated (this script may run only once per year...)
stop_date
=
calculateOpenOrderLineStopDate
(
open_order_line
,
hosting_subscription
,
instance_tree
,
start_date_delta
=
0
,
next_stop_date_delta
=
next_stop_date_delta
)
if
current_stop_date
<
stop_date
:
# Bingo, new subscription to generate
open_order_line
.
edit
(
stop_date
=
stop_date
,
activate_kw
=
activate_kw
)
storeWorkflowComment
(
open_order_line
,
'Stop date updated to %s'
%
stop_date
)
if
instance_tree
.
getSlapState
()
==
'destroy_requested'
:
# Line should be deleted
assert
instance_tree
.
getCausalityState
()
==
'diverged'
instance_tree
.
converge
(
comment
=
"Last open order: %s"
%
open_order_line
.
getRelativeUrl
())
open_sale_order
.
archive
()
storeWorkflowComment
(
open_sale_order
,
"Instance Tree destroyed: %s"
%
instance_tree
.
getRelativeUrl
())
elif
(
instance_tree
.
getCausalityState
()
==
'diverged'
):
instance_tree
.
converge
(
comment
=
"Nothing to do on open order."
)
if
instance_tree
is
not
None
:
subscription_request
=
instance_tree
.
getAggregateRelatedValue
(
portal_type
=
"Subscription Request"
)
# Define the start date of the period, this can variates with the time.
next_stop_date_delta
=
0
if
subscription_request
is
not
None
:
next_stop_date_delta
=
46
# First check if the instance tree has been correctly simulated (this script may run only once per year...)
stop_date
=
calculateOpenOrderLineStopDate
(
open_order_line
,
hosting_subscription
,
instance_tree
,
start_date_delta
=
0
,
next_stop_date_delta
=
next_stop_date_delta
)
if
current_stop_date
<
stop_date
:
# Bingo, new subscription to generate
open_order_line
.
edit
(
stop_date
=
stop_date
,
activate_kw
=
activate_kw
)
storeWorkflowComment
(
open_order_line
,
'Stop date updated to %s'
%
stop_date
)
if
instance_tree
.
getSlapState
()
==
'destroy_requested'
:
# Line should be deleted
assert
instance_tree
.
getCausalityState
()
==
'diverged'
instance_tree
.
converge
(
comment
=
"Last open order: %s"
%
open_order_line
.
getRelativeUrl
())
open_sale_order
.
archive
()
storeWorkflowComment
(
open_sale_order
,
"Instance Tree destroyed: %s"
%
instance_tree
.
getRelativeUrl
())
elif
(
instance_tree
.
getCausalityState
()
==
'diverged'
):
instance_tree
.
converge
(
comment
=
"Nothing to do on open order."
)
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