[ADD] Added the attachment_azure with db operations

This commit is contained in:
Hiren Pattani-SerpentCS
2021-11-03 08:43:28 -06:00
committed by Maxime Chambreuil
co-authored by Maxime Chambreuil
parent bf51e0a122
commit e4e0c2dc5d
4 changed files with 87 additions and 0 deletions
+19
View File
@@ -1 +1,20 @@
# Copyright 2016-2019 Camptocamp SA
# Copyright 2021 Open Source Integrators
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
import os
from . import models
from . import controllers
from odoo import api, SUPERUSER_ID
def _post_init_hook(cr, registry):
# create the Azure container after module installation
if os.environ.get("AZURE_STORAGE_CONNECTION_STRING", False):
env = api.Environment(cr, SUPERUSER_ID, {})
env["ir.attachment"]._get_azure_container()
env["ir.config_parameter"].create(
{"key": "ir_attachment.location", "value": "azure"}
)
env["ir.attachment"].force_storage()