This question has been flagged
1 Reply
4335 Views

I created a model and when I query the records for the model via shell I get the existing records, for example:

>>>env['model.name'].search([])

model.name(71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 140, 146, 147, 148, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163)

But if I create a new record by the web interface and query the model again by the shell, I still get the same records: 

>>>env['model.name'].search([])

model.name(71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 140, 146, 147, 148, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163)

It seems as if is querying the records from the cache.

Does anyone has happened this?

Is there any solution ?

Avatar
Discard
Author Best Answer

I found the answer! the current operation is within a transaction, therefore it must be committed and return to query the records in a new transaction.

>>>env['model.name'].search([])

>>>env.cr.commit()

>>>env['model.name'].search([])

Avatar
Discard