Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions website_external_javascripts/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Odoo, an open source suite of business apps
# This module copyright (C) 2015 bloopark systems (<http://bloopark.de>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from . import models
40 changes: 40 additions & 0 deletions website_external_javascripts/__openerp__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Odoo, an open source suite of business apps
# This module copyright (C) 2015 bloopark systems (<http://bloopark.de>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
{
'name': 'Website External JavaScripts',
'category': 'Website',
'summary': 'Allow to embed external JavaScripts.',
'version': '1.0',
'author': "bloopark systems GmbH & Co. KG, "
"Odoo Community Association (OCA)",
'website': "http://www.bloopark.de",
'license': 'AGPL-3',
'depends': [
'website'
],
'data': [
'views/website_extern_javascript_view.xml',
'views/assets_website.xml',
'security/ir.model.access.csv',
],
'installable': True,
'auto_install': False,
}
22 changes: 22 additions & 0 deletions website_external_javascripts/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Odoo, an open source suite of business apps
# This module copyright (C) 2015 bloopark systems (<http://bloopark.de>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from . import ir_ui_view
from . import website_extern_javascript
42 changes: 42 additions & 0 deletions website_external_javascripts/models/ir_ui_view.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Odoo, an open source suite of business apps
# This module copyright (C) 2015 bloopark systems (<http://bloopark.de>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from openerp import models


class IrUiView(models.Model):

_inherit = 'ir.ui.view'

def render(self, cr, uid, id_or_xml_id, values=None, engine='ir.qweb',
context=None):
if not values:
values = {}

website_externjs = self.pool.get('website.extern.javascript')

js_ids = website_externjs.search(
cr, uid, [('activated', '=', True)], context=context)

values['javascripts'] = website_externjs.browse(cr, uid, js_ids,
context=context)

return super(IrUiView, self).render(cr, uid, id_or_xml_id, values,
engine, context)
43 changes: 43 additions & 0 deletions website_external_javascripts/models/website_extern_javascript.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Odoo, an open source suite of business apps
# This module copyright (C) 2015 bloopark systems (<http://bloopark.de>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from openerp import fields, models


class WebsiteExternJavaScript(models.Model):

_name = 'website.extern.javascript'

_order = 'sequence'

activated = fields.Boolean('Activated')

sequence = fields.Integer('Sequence',
help='Used for the order of the JavaScripts. '
'The higher the number the later the code '
'is embedded.')

description = fields.Char('Description')

type = fields.Selection([('url', 'URL'), ('code', 'Code')], 'Type')

url = fields.Char('URL', help='URL of the JavaScript to embed.')

code = fields.Text('Code', help='JavaScript to embed into the html code.')
3 changes: 3 additions & 0 deletions website_external_javascripts/security/ir.model.access.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_javascript_public,website.extern.javascript,website_external_javascripts.model_website_extern_javascript,,1,0,0,0
access_javascript,website.extern.javascript,website_external_javascripts.model_website_extern_javascript,base.group_website_designer,1,1,1,1
26 changes: 26 additions & 0 deletions website_external_javascripts/views/assets_website.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>

<template id="assets_frontend" inherit_id="website.assets_frontend" name="website_contract">
<xpath expr="." position="inside">
<t t-if="javascripts">
<t t-foreach="javascripts" t-as="js">
kuh
<t t-if="js.type == 'url'">
<script type="text/javascript" t-att-src="js.url"/>
</t>
<t t-if="js.type == 'code'">
<script type="text/javascript">
muh
<t t-raw="js.code" />
</script>
</t>
</t>
</t>
</xpath>
</template>

</data>

</openerp>
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>

<record model="ir.ui.view" id="view_website_extern_javascript_tree">
<field name="name">website.extern.javascript.tree</field>
<field name="model">website.extern.javascript</field>
<field name="arch" type="xml">
<tree string="Extern JavaScript">
<field name="activated"/>
<field name="sequence"/>
<field name="description"/>
<field name="type"/>
</tree>
</field>
</record>

<record model="ir.ui.view" id="view_website_extern_javascript_form">
<field name="name">website.extern.javascript.from</field>
<field name="model">website.extern.javascript</field>
<field name="mode">primary</field>
<field name="arch" type="xml">
<form string="Extern JavaScript">
<sheet>
<group>
<field name="activated"/>
<field name="description"/>
</group>
<group>
<field name="sequence"/>
<field name="type"/>
</group>
<group>
<field name="url" attrs="{'invisible': [('type', '!=', 'url')]}"/>
<field name="code" attrs="{'invisible': [('type', '!=', 'code')]}"/>
</group>
</sheet>
</form>
</field>
</record>

<record model="ir.actions.act_window" id="action_website_extern_javascript">
<field name="name">Extern JavaScript</field>
<field name="res_model">website.extern.javascript</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
</record>

<menuitem name="Extern JavaScript"
id="menu_website_extern_javascript"
action="action_website_extern_javascript"
parent="base.menu_config"/>

</data>
</openerp>