Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5-Boxiang
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
Hamza
erp5-Boxiang
Commits
179c43bb
Commit
179c43bb
authored
Jun 10, 2016
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
inventory: some code cleanup
parent
a0b62b51
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
20 deletions
+17
-20
product/ERP5/Document/Inventory.py
product/ERP5/Document/Inventory.py
+17
-20
No files found.
product/ERP5/Document/Inventory.py
View file @
179c43bb
...
@@ -93,29 +93,28 @@ class Inventory(Delivery):
...
@@ -93,29 +93,28 @@ class Inventory(Delivery):
to have our own temp object constructor, this is usefull if we
to have our own temp object constructor, this is usefull if we
want to use some classes with some particular methods
want to use some classes with some particular methods
"""
"""
portal
=
self
.
getPortalObject
()
sql_catalog_id
=
kw
.
pop
(
"sql_catalog_id"
,
None
)
sql_catalog_id
=
kw
.
pop
(
"sql_catalog_id"
,
None
)
disable_archive
=
kw
.
pop
(
"disable_archive"
,
0
)
disable_archive
=
kw
.
pop
(
"disable_archive"
,
0
)
draft_state_list
=
list
(
self
.
getPortalDraftOrderStateList
()
)
state
=
self
.
getSimulationState
(
)
# we need reindex when cancelling inventories
# we need reindex when cancelling inventories
if
'cancelled'
in
draft_state_list
:
if
(
state
in
portal
.
getPortalDraftOrderStateList
()
and
draft_state_list
.
remove
(
'cancelled'
)
state
!=
'cancelled'
):
if
self
.
getSimulationState
()
in
draft_state_list
:
# this prevent from trying to calculate stock
# this prevent from trying to calculate stock
# with not all properties defined and thus making
# with not all properties defined and thus making
# request with no condition in mysql
# request with no condition in mysql
object_list
=
[
self
]
immediate_reindex_archive
=
sql_catalog_id
is
not
None
immediate_reindex_archive
=
sql_catalog_id
is
not
None
self
.
portal_catalog
.
catalogObjectList
(
object_list
,
portal
.
portal_catalog
.
catalogObjectList
([
self
]
,
sql_catalog_id
=
sql_catalog_id
,
sql_catalog_id
=
sql_catalog_id
,
disable_archive
=
disable_archive
,
disable_archive
=
disable_archive
,
immediate_reindex_archive
=
immediate_reindex_archive
)
immediate_reindex_archive
=
immediate_reindex_archive
)
return
return
connection_id
=
None
connection_id
=
None
if
sql_catalog_id
is
not
None
:
if
sql_catalog_id
is
not
None
:
# try to get connection used in the catalog
# try to get connection used in the catalog
catalog
=
self
.
portal_catalog
[
sql_catalog_id
]
catalog
=
portal
.
portal_catalog
[
sql_catalog_id
]
for
method
in
catalog
.
objectValues
():
for
method
in
catalog
.
objectValues
():
if
method
.
meta_type
==
"Z SQL Method"
:
if
method
.
meta_type
==
"Z SQL Method"
:
if
'deferred'
not
in
method
.
connection_id
\
if
'deferred'
not
in
method
.
connection_id
\
...
@@ -150,8 +149,7 @@ class Inventory(Delivery):
...
@@ -150,8 +149,7 @@ class Inventory(Delivery):
if
temp_constructor
is
None
:
if
temp_constructor
is
None
:
from
Products.ERP5Type.Document
import
newTempMovement
from
Products.ERP5Type.Document
import
newTempMovement
as
temp_constructor
temp_constructor
=
newTempMovement
stop_date
=
self
.
getStopDate
()
stop_date
=
self
.
getStopDate
()
stock_object_list
=
[]
stock_object_list
=
[]
...
@@ -162,7 +160,7 @@ class Inventory(Delivery):
...
@@ -162,7 +160,7 @@ class Inventory(Delivery):
# build a dict containing all inventory for this node
# build a dict containing all inventory for this node
# group by resource/variation and then subvariation
# group by resource/variation and then subvariation
current_inventory_list
=
\
current_inventory_list
=
\
self
.
getPortalObject
()
.
portal_simulation
.
getCurrentInventoryList
(
portal
.
portal_simulation
.
getCurrentInventoryList
(
to_date
=
stop_date
,
to_date
=
stop_date
,
connection_id
=
connection_id
,
connection_id
=
connection_id
,
**
inventory_calculation_dict
[
'inventory_params'
]
**
inventory_calculation_dict
[
'inventory_params'
]
...
@@ -326,23 +324,22 @@ class Inventory(Delivery):
...
@@ -326,23 +324,22 @@ class Inventory(Delivery):
stock_append
(
temp_delivery_line
)
stock_append
(
temp_delivery_line
)
# Reindex objects
# Reindex objects
object_list
=
[
self
]
immediate_reindex_archive
=
sql_catalog_id
is
not
None
immediate_reindex_archive
=
sql_catalog_id
is
not
None
self
.
portal_catalog
.
catalogObjectList
(
object_list
,
portal
.
portal_catalog
.
catalogObjectList
([
self
]
,
sql_catalog_id
=
sql_catalog_id
,
sql_catalog_id
=
sql_catalog_id
,
disable_archive
=
disable_archive
,
disable_archive
=
disable_archive
,
immediate_reindex_archive
=
immediate_reindex_archive
)
immediate_reindex_archive
=
immediate_reindex_archive
)
if
stock_object_list
:
if
stock_object_list
:
# Delete existing stock records and old inventory_cache first.
# Delete existing stock records and old inventory_cache first.
self
.
portal_catalog
.
catalogObjectList
(
portal
.
portal_catalog
.
catalogObjectList
(
stock_object_list
[:],
method_id_list
=
(
'z0_uncatalog_stock'
,
stock_object_list
[:],
method_id_list
=
(
'z0_uncatalog_stock'
,
'SQLCatalog_trimInventoryCacheOnCatalog'
,
),
'SQLCatalog_trimInventoryCacheOnCatalog'
,
),
sql_catalog_id
=
sql_catalog_id
,
sql_catalog_id
=
sql_catalog_id
,
disable_cache
=
1
,
check_uid
=
0
,
disable_archive
=
disable_archive
,
disable_cache
=
1
,
check_uid
=
0
,
disable_archive
=
disable_archive
,
immediate_reindex_archive
=
immediate_reindex_archive
)
immediate_reindex_archive
=
immediate_reindex_archive
)
# Then insert new records without delete.
# Then insert new records without delete.
self
.
portal_catalog
.
catalogObjectList
(
portal
.
portal_catalog
.
catalogObjectList
(
stock_object_list
[:],
method_id_list
=
(
'z_catalog_stock_list_without_delete_for_inventory_virtual_movement'
,
),
stock_object_list
[:],
method_id_list
=
(
'z_catalog_stock_list_without_delete_for_inventory_virtual_movement'
,
),
sql_catalog_id
=
sql_catalog_id
,
sql_catalog_id
=
sql_catalog_id
,
disable_cache
=
1
,
check_uid
=
0
,
disable_archive
=
disable_archive
,
disable_cache
=
1
,
check_uid
=
0
,
disable_archive
=
disable_archive
,
...
...
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