Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Xiaowu Zhang
erp5
Commits
c2051c80
Commit
c2051c80
authored
Mar 01, 2013
by
Aurel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cache entry must also be flushed at former movement's date
parent
86c95e10
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
70 additions
and
15 deletions
+70
-15
bt5/erp5_stock_cache/CatalogMethodTemplateItem/portal_catalog/erp5_mysql_innodb/SQLCatalog_trimInventoryCacheOnCatalog.xml
...5_mysql_innodb/SQLCatalog_trimInventoryCacheOnCatalog.xml
+7
-7
bt5/erp5_stock_cache/SkinTemplateItem/portal_skins/erp5_stock_cache/SimulationTool_zTrimInventoryCacheFromDateOnCatalog.xml
...e/SimulationTool_zTrimInventoryCacheFromDateOnCatalog.xml
+11
-3
bt5/erp5_stock_cache/bt/revision
bt5/erp5_stock_cache/bt/revision
+1
-1
product/ERP5/tests/testInventoryAPI.py
product/ERP5/tests/testInventoryAPI.py
+51
-4
No files found.
bt5/erp5_stock_cache/CatalogMethodTemplateItem/portal_catalog/erp5_mysql_innodb/SQLCatalog_trimInventoryCacheOnCatalog.xml
View file @
c2051c80
...
...
@@ -65,10 +65,10 @@ for loop_item in xrange(len(uid)):\n
min_date = min(min_date, getStartDate[loop_item])\n
else:\n
min_date = getStartDate[loop_item]\n
if min_date:
\n
try:\n
context.SimulationTool_zTrimInventoryCacheFromDateOnCatalog(
date=min_date)\n
except ProgrammingError:\n
\n
try:\n
context.SimulationTool_zTrimInventoryCacheFromDateOnCatalog(uid_list=uid, min_
date=min_date)\n
except ProgrammingError:\n
# Create table if it does not exits\n
# Then no need to flush an empty table\n
context.SimulationTool_zCreateInventoryCache()\n
...
...
bt5/erp5_stock_cache/SkinTemplateItem/portal_skins/erp5_stock_cache/SimulationTool_zTrimInventoryCacheFromDateOnCatalog.xml
View file @
c2051c80
...
...
@@ -8,7 +8,8 @@
<dictionary>
<item>
<key>
<string>
arguments_src
</string>
</key>
<value>
<string>
date
</string>
</value>
<value>
<string>
uid_list\r\n
min_date
</string>
</value>
</item>
<item>
<key>
<string>
connection_id
</string>
</key>
...
...
@@ -22,10 +23,17 @@
<key>
<string>
src
</string>
</key>
<value>
<string
encoding=
"cdata"
>
<![CDATA[
DELETE FROM \n
DELETE \n
FROM \n
inventory_cache \n
WHERE \n
date >
<dtml-sqlvar
expr=
"date"
type=
"datetime"
>
date >
(SELECT min(date) from stock where
<dtml-sqltest
uid_list
column=
uid
type=
int
multiple
>
)\n
<dtml-if
min_date
>
\n
OR\n
date >
<dtml-sqlvar
expr=
"min_date"
type=
"datetime"
>
\n
</dtml-if>
\n
\n
]]>
</string>
</value>
</item>
...
...
bt5/erp5_stock_cache/bt/revision
View file @
c2051c80
4
\ No newline at end of file
12
\ No newline at end of file
product/ERP5/tests/testInventoryAPI.py
View file @
c2051c80
...
...
@@ -2807,17 +2807,58 @@ class TestInventoryCacheTable(InventoryAPITestCase):
value
+
INVENTORY_QUANTITY_4
+
self
.
INVENTORY_QUANTITY_1
,
self
.
getInventory
(
**
inventory_kw
),
)
# Delete movement, so it gets unindexed
self
.
assertEquals
(
value
+
2
*
INVENTORY_QUANTITY_4
+
3
*
self
.
INVENTORY_QUANTITY_1
,
self
.
getInventory
(
optimisation__
=
False
,
**
inventory_kw
),
)
# Move movement's start date in the future and check cache is flushed
# at former date
movement
.
edit
(
start_date
=
self
.
NOW
-
1
)
self
.
tic
()
self
.
assertEquals
(
value
+
INVENTORY_QUANTITY_4
+
3
*
self
.
INVENTORY_QUANTITY_1
,
self
.
getInventory
(
**
inventory_kw
),
)
self
.
doubleStockValue
()
# Cache hit again
self
.
assertEquals
(
value
+
INVENTORY_QUANTITY_4
+
3
*
self
.
INVENTORY_QUANTITY_1
,
self
.
getInventory
(
**
inventory_kw
),
)
self
.
assertEquals
(
value
+
INVENTORY_QUANTITY_4
+
7
*
self
.
INVENTORY_QUANTITY_1
,
self
.
getInventory
(
optimisation__
=
False
,
**
inventory_kw
),
)
# Set date back in the past, cache is clear again
movement
.
edit
(
start_date
=
self
.
LAST_CACHED_MOVEMENT_DATE
)
self
.
tic
()
self
.
assertEquals
(
value
+
INVENTORY_QUANTITY_4
+
7
*
self
.
INVENTORY_QUANTITY_1
,
self
.
getInventory
(
**
inventory_kw
),
)
self
.
doubleStockValue
()
# Cache hit again
self
.
assertEquals
(
value
+
INVENTORY_QUANTITY_4
+
7
*
self
.
INVENTORY_QUANTITY_1
,
self
.
getInventory
(
**
inventory_kw
),
)
self
.
assertEquals
(
value
+
2
*
INVENTORY_QUANTITY_4
+
15
*
self
.
INVENTORY_QUANTITY_1
,
self
.
getInventory
(
optimisation__
=
False
,
**
inventory_kw
),
)
# Delete movement, so it gets unindexed and cache entry is flushed
self
.
folder
.
manage_delObjects
(
ids
=
[
movement
.
getId
(),
])
self
.
tic
()
self
.
assertEquals
(
value
+
3
*
self
.
INVENTORY_QUANTITY_1
,
value
+
15
*
self
.
INVENTORY_QUANTITY_1
,
self
.
getInventory
(
**
inventory_kw
),
)
self
.
doubleStockValue
()
# Cache hit again
self
.
assertEquals
(
value
+
3
*
self
.
INVENTORY_QUANTITY_1
,
value
+
15
*
self
.
INVENTORY_QUANTITY_1
,
self
.
getInventory
(
**
inventory_kw
),
)
...
...
@@ -2860,6 +2901,7 @@ class TestInventoryCacheTable(InventoryAPITestCase):
# Make sure it is dropped
self
.
assertRaises
(
ProgrammingError
,
self
.
portal
.
SimulationTool_zTrimInventoryCacheFromDateOnCatalog
,
uid_list
=
(
0
,),
date
=
DateTime
())
# Check that src__ call still works
inventory_kw
=
{
...
...
@@ -2870,6 +2912,7 @@ class TestInventoryCacheTable(InventoryAPITestCase):
# Table is still not created
self
.
assertRaises
(
ProgrammingError
,
self
.
portal
.
SimulationTool_zTrimInventoryCacheFromDateOnCatalog
,
uid_list
=
(
0
,),
date
=
DateTime
())
# This call should not fail
# It will create table, fill it and check optimisation is used
...
...
@@ -2887,6 +2930,7 @@ class TestInventoryCacheTable(InventoryAPITestCase):
# Make sure it is dropped
self
.
assertRaises
(
ProgrammingError
,
self
.
portal
.
SimulationTool_zTrimInventoryCacheFromDateOnCatalog
,
uid_list
=
(
0
,),
date
=
DateTime
())
# Create a new movement, indexation should not fail
INVENTORY_QUANTITY_4
=
5000
...
...
@@ -2928,12 +2972,15 @@ class TestInventoryCacheTable(InventoryAPITestCase):
# Make sure it is dropped
self
.
assertRaises
(
ProgrammingError
,
self
.
portal
.
SimulationTool_zTrimInventoryCacheFromDateOnCatalog
,
uid_list
=
(
0
,),
date
=
DateTime
())
# Delete movement
self
.
folder
.
manage_delObjects
(
ids
=
[
movement
.
getId
(),
])
self
.
tic
()
# This call must not fail as table has been created
self
.
portal
.
SimulationTool_zTrimInventoryCacheFromDateOnCatalog
(
date
=
DateTime
())
self
.
portal
.
SimulationTool_zTrimInventoryCacheFromDateOnCatalog
(
uid_list
=
(
0
,),
date
=
DateTime
())
# This call should not fail
# It will create table, fill it and check optimisation is used
...
...
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