Maybe this is a off-topic, when I tried the script above to migrate the invoice report cache to the filestore, but only half of the invoices are processed, hence I have to run the same script many times. Has anyone encountered this peculiar situation? Could there be a bug or limitation where records don’t get fetched completely while being modified at the same time?
It is maybe because the order of records is not stable. Adding an explicit stable order should fix that.
I have added the clause
order=[('id', 'ASC')] as suggested but it is still not really working. I tested again over my backup DB with original invoice report cached in DB and still processes only half on a the first run. I will debug a bit to figure out what is the problem.
I think the culprit of the problem is the
offset, since we are modifying the criteria to which we are querying the records, i.e. fetching those invoices which the
None once we updated the first batch of invoices, for the next batch of invoices, the query will not return the same original list, but instead a new list where the invoices from first batch are not present because they have been processed already in the previous loop. So when we specify an offset, this offset basically skips invoices which need to be migrated. So at the end we ended up that not all invoices are processed as expected. The solution is to just remove the
offset clause from the query and just use the limit; here the
order clause is optional.
This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.