Initial commit: OCA Technical packages (595 packages)

This commit is contained in:
Ernad Husremovic 2025-08-29 15:43:03 +02:00
commit 2cc02aac6e
24950 changed files with 2318079 additions and 0 deletions

View file

@ -0,0 +1,3 @@
from . import dms_file
from . import ir_attachment
from . import ir_binary

View file

@ -0,0 +1,19 @@
# Copyright 2023 Tecnativa - Víctor Martínez
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import models
class DmsFile(models.Model):
_inherit = "dms.file"
def _prepare_ir_attachment_values(self):
return {
"dms_file_id": self.id,
"name": self.name,
"res_model": self.env.context.get("active_model"),
"res_id": self.env.context.get("active_id"),
}
def action_create_attachment_from_record(self):
return self.env["ir.attachment"].create(self._prepare_ir_attachment_values())

View file

@ -0,0 +1,19 @@
# Copyright 2023 Tecnativa - Víctor Martínez
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import api, fields, models
class IrAttachment(models.Model):
_inherit = "ir.attachment"
dms_file_id = fields.Many2one(comodel_name="dms.file")
@api.depends("dms_file_id", "dms_file_id.content")
def _compute_datas(self):
"""Get the contents of the attachment directly from the DMS file."""
_self = self.filtered("dms_file_id")
res = super(IrAttachment, (self - _self))._compute_datas()
for item in _self:
item.datas = item.dms_file_id.content
return res

View file

@ -0,0 +1,15 @@
# Copyright 2024 Tecnativa - Víctor Martínez
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
from odoo import models
class IrBinary(models.AbstractModel):
_inherit = "ir.binary"
def _record_to_stream(self, record, field_name):
"""We need to overwrite for the download and preview to be correct."""
if record._name == "ir.attachment" and record.dms_file_id:
record = record.dms_file_id
field_name = "content"
return super()._record_to_stream(record=record, field_name=field_name)