Odoo is the world's easiest all-in-one management software. It includes hundreds of business apps:
CRM | e-Commerce | Accounting | Inventory | PoS | Project management | MRP | etc.
I have overwritten the create method for res.partner. Part of my custom functionality writes to a record of a custom model called x_vehicle (there is a many2many field in res.partner pointing to x_vehicle). The situation is such that I need this write to be an isolated transaction because I don't want it to be rolled back if an exception is thrown downstream. To solve this I open a new counter to write to this field as so:
# the 'id' parameter below is the database id of the x_vehicle object in the many2many
# field of the res.partner being created
with openerp.registry(self.env.cr.dbname).cursor() as new_cr:
new_env = api.Environment(new_cr, self.env.uid, self.env.context)
# You don't need close your cr because is closed when finish "with"
# You don't need clear caches because is cleared when finish "with"
Odoo gets stuck with loading bar for an indefinite period of time. No output in the logs on debug level.
Trying to write to some other model with the same method works.
Trying to write to x_vehicle model but to any other record works. It seems that odoo doesn't like that in the above case I'm trying to write the the record which is supposed to be linked to the current res.partner being created. Perhaps the problem happens because I'm trying to access the record with the counter from self.env and the new_cr at the same time?
Thoughts and ideas?
About This Community
This platform 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.Register
Odoo Training Center
Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.Test it now
|Asked: 8/18/16, 4:16 AM|
|Seen: 556 times|
|Last updated: 8/18/16, 4:27 AM|