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