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
c8acd609
Commit
c8acd609
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
c7922f3a
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 @
c8acd609
...
@@ -58,31 +58,33 @@ if open_sale_order.getValidationState() == 'validated':
...
@@ -58,31 +58,33 @@ if open_sale_order.getValidationState() == 'validated':
hosting_subscription
=
open_order_line
.
getAggregateValue
(
portal_type
=
'Hosting Subscription'
)
hosting_subscription
=
open_order_line
.
getAggregateValue
(
portal_type
=
'Hosting Subscription'
)
instance_tree
=
open_order_line
.
getAggregateValue
(
portal_type
=
'Instance Tree'
)
instance_tree
=
open_order_line
.
getAggregateValue
(
portal_type
=
'Instance Tree'
)
assert
current_start_date
==
hosting_subscription
.
HostingSubscription_calculateSubscriptionStartDate
()
assert
current_start_date
==
hosting_subscription
.
HostingSubscription_calculateSubscriptionStartDate
()
subscription_request
=
instance_tree
.
getAggregateRelatedValue
(
portal_type
=
"Subscription Request"
)
if
instance_tree
is
not
None
:
# Define the start date of the period, this can variates with the time.
subscription_request
=
instance_tree
.
getAggregateRelatedValue
(
portal_type
=
"Subscription Request"
)
next_stop_date_delta
=
0
# Define the start date of the period, this can variates with the time.
if
subscription_request
is
not
None
:
next_stop_date_delta
=
0
next_stop_date_delta
=
46
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
,
# First check if the instance tree has been correctly simulated (this script may run only once per year...)
start_date_delta
=
0
,
next_stop_date_delta
=
next_stop_date_delta
)
stop_date
=
calculateOpenOrderLineStopDate
(
open_order_line
,
hosting_subscription
,
instance_tree
,
if
current_stop_date
<
stop_date
:
start_date_delta
=
0
,
next_stop_date_delta
=
next_stop_date_delta
)
# Bingo, new subscription to generate
if
current_stop_date
<
stop_date
:
open_order_line
.
edit
(
# Bingo, new subscription to generate
stop_date
=
stop_date
,
open_order_line
.
edit
(
activate_kw
=
activate_kw
)
stop_date
=
stop_date
,
storeWorkflowComment
(
open_order_line
,
activate_kw
=
activate_kw
)
'Stop date updated to %s'
%
stop_date
)
storeWorkflowComment
(
open_order_line
,
'Stop date updated to %s'
%
stop_date
)
if
instance_tree
.
getSlapState
()
==
'destroy_requested'
:
# Line should be deleted
if
instance_tree
.
getSlapState
()
==
'destroy_requested'
:
assert
instance_tree
.
getCausalityState
()
==
'diverged'
# Line should be deleted
instance_tree
.
converge
(
comment
=
"Last open order: %s"
%
open_order_line
.
getRelativeUrl
())
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
())
open_sale_order
.
archive
()
elif
(
instance_tree
.
getCausalityState
()
==
'diverged'
):
storeWorkflowComment
(
open_sale_order
,
"Instance Tree destroyed: %s"
%
instance_tree
.
getRelativeUrl
())
instance_tree
.
converge
(
comment
=
"Nothing to do on open order."
)
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