mirror of
https://github.com/OCA/knowledge.git
synced 2025-07-29 03:46:29 -06:00
[MIG] document_url: Migration to 15.0
This commit is contained in:
parent
e0ea0452e3
commit
1ddca69a2d
@ -2,16 +2,18 @@
|
||||
# Copyright 2020 Tecnativa - Manuel Calero
|
||||
{
|
||||
"name": "URL attachment",
|
||||
"version": "14.0.1.1.0",
|
||||
"version": "15.0.1.0.0",
|
||||
"category": "Tools",
|
||||
"author": "Tecnativa, Odoo Community Association (OCA)",
|
||||
"website": "https://github.com/OCA/knowledge",
|
||||
"license": "AGPL-3",
|
||||
"depends": ["mail"],
|
||||
"data": [
|
||||
"view/document_url_view.xml",
|
||||
"security/ir.model.access.csv",
|
||||
],
|
||||
"qweb": ["static/src/xml/url.xml"],
|
||||
"data": ["view/document_url_view.xml", "security/ir.model.access.csv"],
|
||||
"assets": {
|
||||
"web.assets_backend": [
|
||||
"document_url/static/src/js/url.js",
|
||||
],
|
||||
"web.assets_qweb": ["document_url/static/src/xml/url.xml"],
|
||||
},
|
||||
"installable": True,
|
||||
}
|
||||
|
@ -1,16 +0,0 @@
|
||||
# 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 = 'application/link'
|
||||
WHERE type = 'link'
|
||||
""",
|
||||
)
|
@ -1,24 +0,0 @@
|
||||
# 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'
|
||||
""",
|
||||
)
|
@ -7,14 +7,12 @@ class TestDocumentUrl(common.TransactionCase):
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
wizard_add_url = self.env["ir.attachment.add_url"]
|
||||
ctx = {
|
||||
"active_model": "res.users",
|
||||
"active_id": self.env.ref("base.user_demo").id,
|
||||
"active_ids": [self.env.ref("base.user_demo").id],
|
||||
}
|
||||
self.wizard_add_url = wizard_add_url.with_context(ctx).create(
|
||||
{"name": "Demo User (Website)", "url": "http://www.odoodemouser.com"}
|
||||
)
|
||||
|
||||
self.wizard_add_url = wizard_add_url.with_context(
|
||||
active_model="res.users",
|
||||
active_id=self.env.ref("base.user_demo").id,
|
||||
active_ids=[self.env.ref("base.user_demo").id],
|
||||
).create({"name": "Demo User (Website)", "url": "http://www.odoodemouser.com"})
|
||||
|
||||
def test_add_url_attachment(self):
|
||||
self.wizard_add_url.action_add_url()
|
||||
|
@ -1,25 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<odoo>
|
||||
<template
|
||||
id="assets_backend"
|
||||
name="document_url assets"
|
||||
inherit_id="web.assets_backend"
|
||||
>
|
||||
<xpath expr="." position="inside">
|
||||
<script type="text/javascript" src="/document_url/static/src/js/url.js" />
|
||||
<link
|
||||
href="/document_url/static/src/scss/document_url.scss"
|
||||
rel="stylesheet"
|
||||
type="text/scss"
|
||||
/>
|
||||
</xpath>
|
||||
</template>
|
||||
<record model="ir.actions.act_window" id='action_ir_attachment_add_url'>
|
||||
<field name="name">Add URL</field>
|
||||
<field name="res_model">ir.attachment.add_url</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="target">new</field>
|
||||
<field name="view_mode">form</field>
|
||||
<record model='ir.actions.act_window' id='action_ir_attachment_add_url'>
|
||||
<field name='name'>Add URL</field>
|
||||
<field name='res_model'>ir.attachment.add_url</field>
|
||||
<field name='type'>ir.actions.act_window</field>
|
||||
<field name='target'>new</field>
|
||||
<field name='view_mode'>form</field>
|
||||
</record>
|
||||
<record model="ir.ui.view" id="view_ir_attachment_add_url_form">
|
||||
<field name="name">ir.attachment.add_url.form</field>
|
||||
|
@ -10,7 +10,7 @@ class AddUrlWizard(models.TransientModel):
|
||||
_name = "ir.attachment.add_url"
|
||||
_description = "Wizard to add URL attachment"
|
||||
|
||||
name = fields.Char("Name", required=True)
|
||||
name = fields.Char(required=True)
|
||||
url = fields.Char("URL", required=True)
|
||||
|
||||
def action_add_url(self):
|
||||
|
Loading…
Reference in New Issue
Block a user