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
a54161d5
Commit
a54161d5
authored
Jun 14, 2023
by
Romain Courteaud
🐸
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos_accounting: no need to update open order period anymore
parent
73f9eecd
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
0 additions
and
350 deletions
+0
-350
master/bt5/slapos_accounting/PathTemplateItem/portal_alarms/slapos_update_open_sale_order_period.xml
...em/portal_alarms/slapos_update_open_sale_order_period.xml
+0
-113
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_accounting/Alarm_requestUpdateOpenSaleOrderPeriod.py
...apos_accounting/Alarm_requestUpdateOpenSaleOrderPeriod.py
+0
-11
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_accounting/Alarm_requestUpdateOpenSaleOrderPeriod.xml
...pos_accounting/Alarm_requestUpdateOpenSaleOrderPeriod.xml
+0
-62
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_accounting/OpenSaleOrder_updatePeriod.py
...tal_skins/slapos_accounting/OpenSaleOrder_updatePeriod.py
+0
-101
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_accounting/OpenSaleOrder_updatePeriod.xml
...al_skins/slapos_accounting/OpenSaleOrder_updatePeriod.xml
+0
-62
master/bt5/slapos_accounting/bt/template_path_list
master/bt5/slapos_accounting/bt/template_path_list
+0
-1
No files found.
master/bt5/slapos_accounting/PathTemplateItem/portal_alarms/slapos_update_open_sale_order_period.xml
deleted
100644 → 0
View file @
73f9eecd
<?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_requestUpdateOpenSaleOrderPeriod
</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_update_open_sale_order_period
</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>
Updates Open Sale Order period
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_accounting/Alarm_requestUpdateOpenSaleOrderPeriod.py
deleted
100644 → 0
View file @
73f9eecd
portal
=
context
.
getPortalObject
()
portal
.
portal_catalog
.
searchAndActivate
(
portal_type
=
'Open Sale Order'
,
validation_state
=
'validated'
,
children_portal_type
=
'Open Sale Order Line'
,
method_id
=
'OpenSaleOrder_updatePeriod'
,
activate_kw
=
{
'tag'
:
tag
},
packet_size
=
1
,
activity_count
=
100
)
context
.
activate
(
after_tag
=
tag
).
getId
()
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_accounting/Alarm_requestUpdateOpenSaleOrderPeriod.xml
deleted
100644 → 0
View file @
73f9eecd
<?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_requestUpdateOpenSaleOrderPeriod
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_accounting/OpenSaleOrder_updatePeriod.py
deleted
100644 → 0
View file @
73f9eecd
from
zExceptions
import
Unauthorized
if
REQUEST
is
not
None
:
raise
Unauthorized
from
erp5.component.module.DateUtils
import
addToDate
from
DateTime
import
DateTime
portal
=
context
.
getPortalObject
()
open_sale_order
=
context
now
=
DateTime
()
tag
=
'%s_%s'
%
(
open_sale_order
.
getUid
(),
script
.
id
)
activate_kw
=
{
'tag'
:
tag
}
if
portal
.
portal_activities
.
countMessageWithTag
(
tag
)
>
0
:
# nothing to do
return
def
storeWorkflowComment
(
document
,
comment
):
portal_workflow
=
document
.
portal_workflow
last_workflow_item
=
portal_workflow
.
getInfoFor
(
ob
=
document
,
name
=
'comment'
,
wf_id
=
'edit_workflow'
)
if
last_workflow_item
!=
comment
:
portal_workflow
.
doActionFor
(
document
,
action
=
'edit_action'
,
comment
=
comment
)
def
calculateOpenOrderLineStopDate
(
open_order_line
,
hosting_subscription
,
instance_tree
,
start_date_delta
,
next_stop_date_delta
=
0
):
end_date
=
instance_tree
.
InstanceTree_calculateSubscriptionStopDate
()
if
end_date
is
None
:
# Be sure that start date is different from stop date
# Consider the first period longer (delta), this allow us to change X days/months
# On a first invoice.
next_stop_date
=
hosting_subscription
.
getNextPeriodicalDate
(
hosting_subscription
.
HostingSubscription_calculateSubscriptionStartDate
()
+
start_date_delta
)
current_stop_date
=
next_stop_date
# Ensure the invoice is generated 15 days in advance of the next period.
while
next_stop_date
<
now
+
next_stop_date_delta
:
# Return result should be < now, it order to provide stability in simulation (destruction if it happen should be >= now)
current_stop_date
=
next_stop_date
next_stop_date
=
\
hosting_subscription
.
getNextPeriodicalDate
(
current_stop_date
)
return
addToDate
(
current_stop_date
,
to_add
=
{
'second'
:
-
1
})
else
:
stop_date
=
end_date
return
stop_date
if
open_sale_order
.
getValidationState
()
==
'validated'
:
person
=
open_sale_order
.
getDestinationDecisionValue
(
portal_type
=
"Person"
)
if
person
is
not
None
:
open_order_path_list
=
[]
for
line
in
open_sale_order
.
contentValues
(
portal_type
=
'Open Sale Order Line'
):
if
line
.
hasCellContent
(
base_id
=
'path'
):
open_order_path_list
.
extend
(
line
.
getCellValueList
(
base_id
=
'path'
))
else
:
open_order_path_list
.
append
(
line
)
for
open_order_line
in
open_order_path_list
:
current_start_date
=
open_order_line
.
getStartDate
()
current_stop_date
=
open_order_line
.
getStopDate
()
# Prevent mistakes
assert
current_start_date
is
not
None
assert
current_stop_date
is
not
None
assert
current_start_date
<
current_stop_date
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
()
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."
)
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_accounting/OpenSaleOrder_updatePeriod.xml
deleted
100644 → 0
View file @
73f9eecd
<?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>
REQUEST=None
</string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
OpenSaleOrder_updatePeriod
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
master/bt5/slapos_accounting/bt/template_path_list
View file @
a54161d5
...
@@ -26,7 +26,6 @@ portal_alarms/slapos_start_confirmed_aggregated_subscription_sale_packing_list
...
@@ -26,7 +26,6 @@ portal_alarms/slapos_start_confirmed_aggregated_subscription_sale_packing_list
portal_alarms/slapos_stop_confirmed_aggregated_sale_invoice_transaction
portal_alarms/slapos_stop_confirmed_aggregated_sale_invoice_transaction
portal_alarms/slapos_trigger_build
portal_alarms/slapos_trigger_build
portal_alarms/slapos_update_delivery_simulation
portal_alarms/slapos_update_delivery_simulation
portal_alarms/slapos_update_open_sale_order_period
portal_categories/trade_phase/slapos
portal_categories/trade_phase/slapos
portal_categories/trade_phase/slapos/**
portal_categories/trade_phase/slapos/**
portal_categories/trade_state/**
portal_categories/trade_state/**
...
...
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