Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

The environment in Odoo shell it's not consistent with the external operations to the database

By
Manuel A. Márquez
on 10/4/16, 7:28 PM 172 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 ?

0
Manuel A. Márquez
On 10/9/16, 8:01 AM

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([])

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 10/4/16, 7:28 PM
Seen: 172 times
Last updated: 10/9/16, 8:01 AM