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?
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
|Asked: 8/18/16, 4:16 AM|
|Seen: 109 times|
|Last updated: 8/18/16, 4:27 AM|