mirror of
https://github.com/OCA/knowledge.git
synced 2025-07-23 04:22:04 -06:00
[FIX] document_url: Improve the definition of mimetype=application/link only to records linked to a model to avoid errors with the developer model (with assets).
This commit is contained in:
parent
b20fd056b1
commit
22218ade21
@ -2,7 +2,7 @@
|
||||
# Copyright 2020 Tecnativa - Manuel Calero
|
||||
{
|
||||
"name": "URL attachment",
|
||||
"version": "14.0.1.0.0",
|
||||
"version": "14.0.1.1.0",
|
||||
"category": "Tools",
|
||||
"author": "Tecnativa, Odoo Community Association (OCA)",
|
||||
"website": "https://github.com/OCA/knowledge",
|
||||
|
24
document_url/migrations/14.0.1.1.0/post-migration.py
Normal file
24
document_url/migrations/14.0.1.1.0/post-migration.py
Normal file
@ -0,0 +1,24 @@
|
||||
# Copyright 2021 Tecnativa - Víctor Martínez
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
from openupgradelib import openupgrade
|
||||
|
||||
|
||||
@openupgrade.migrate()
|
||||
def migrate(env, version):
|
||||
openupgrade.logged_query(
|
||||
env.cr,
|
||||
"""
|
||||
UPDATE ir_attachment
|
||||
SET mimetype = 'text/css'
|
||||
WHERE mimetype = 'application/link' AND res_id = 0 AND name LIKE '%.%css'
|
||||
""",
|
||||
)
|
||||
openupgrade.logged_query(
|
||||
env.cr,
|
||||
"""
|
||||
UPDATE ir_attachment
|
||||
SET mimetype = 'application/javascript'
|
||||
WHERE mimetype = 'application/link' AND res_id = 0 AND name LIKE '%.js'
|
||||
""",
|
||||
)
|
@ -8,6 +8,6 @@ class IrAttachment(models.Model):
|
||||
_inherit = "ir.attachment"
|
||||
|
||||
def _compute_mimetype(self, values):
|
||||
if values.get("url"):
|
||||
if values.get("url") and values.get("res_model") and values.get("res_id"):
|
||||
return "application/link"
|
||||
return super()._compute_mimetype(values)
|
||||
|
@ -10,6 +10,7 @@
|
||||
<link
|
||||
href="/document_url/static/src/scss/document_url.scss"
|
||||
rel="stylesheet"
|
||||
type="text/scss"
|
||||
/>
|
||||
</xpath>
|
||||
</template>
|
||||
|
Loading…
Reference in New Issue
Block a user