[Erp5-dev] Delayed reindex, workflow script and acquisition
bartek
bartek at gorny.edu.pl
Fri Nov 12 13:46:41 CET 2010
Hi
I ran into a tricky issue caused by delayed reindexing and
fast-clicking users. Here is the scenario:
- there is a Document, which has some Lines
- Document is a member of a Category
- Lines acquire membership of a Category from their parent (Document)
- he Document belongs to a Workflow
- upon transition, the Workflow triggers a Script
- the Script iterates over Lines doing something to which it uses
Category
Now what happens is:
- a user changes Category on Document and saves it
- then he executes workflow transition
The result is that the Script in most cases uses the new value of
Category, but sometimes it uses the old value. This is because
acquisition goes through portal catalog. If a users clicks through
workflow transition fast enough, before the reindexing is complete
(which is not uncommon), the outcome is confusion: scripts are ok, they
pass all tests, user did everything right, all data is correct, only
the goods went to a wrong warehouse.
Now, the only way I found to prevent it is to make the Script get a
category explicitly from parent (.getParent().getThisCategory()),
though it is only a workaround. The question is, where is the real
problem? I wrote a simple code, using legal techniques and basic API,
the application passed every test, the result was bad. Therefore, there
is a flaw in the core which we should nail down and fix.
Bartek
More information about the Erp5-dev
mailing list