diff --git a/base_attachment_object_storage/models/ir_attachment.py b/base_attachment_object_storage/models/ir_attachment.py index e8b17f5..9f0605f 100644 --- a/base_attachment_object_storage/models/ir_attachment.py +++ b/base_attachment_object_storage/models/ir_attachment.py @@ -260,22 +260,21 @@ class IrAttachment(models.Model): Using a new Odoo Environment thus a new PG transaction. """ - with api.Environment.manage(): - if new_cr: - registry = odoo.modules.registry.Registry.new(self.env.cr.dbname) - with closing(registry.cursor()) as cr: - try: - yield self.env(cr=cr) - except Exception: - cr.rollback() - raise - else: - # disable pylint error because this is a valid commit, - # we are in a new env - cr.commit() # pylint: disable=invalid-commit - else: - # make a copy - yield self.env() + if new_cr: + registry = odoo.modules.registry.Registry.new(self.env.cr.dbname) + with closing(registry.cursor()) as cr: + try: + yield self.env(cr=cr) + except Exception: + cr.rollback() + raise + else: + # disable pylint error because this is a valid commit, + # we are in a new env + cr.commit() # pylint: disable=invalid-commit + else: + # make a copy + yield self.env() def _move_attachment_to_store(self): self.ensure_one()