forked from OCA/website
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
343 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
Backend views for website | ||
========================= | ||
|
||
This module was written to extend the functionality of ... to support ... and allow you to ... | ||
|
||
Installation | ||
============ | ||
|
||
To install this module, you need to: | ||
|
||
* do this ... | ||
|
||
Configuration | ||
============= | ||
|
||
To configure this module, you need to: | ||
|
||
* go to ... | ||
|
||
Usage | ||
===== | ||
|
||
To use this module, you need to: | ||
|
||
* go to ... | ||
|
||
For further information, please visit: | ||
|
||
* https://www.odoo.com/forum/help-1 | ||
|
||
Known issues / Roadmap | ||
====================== | ||
|
||
* ... | ||
|
||
Credits | ||
======= | ||
|
||
Contributors | ||
------------ | ||
|
||
* Firsname Lastname <[email protected]> | ||
|
||
Maintainer | ||
---------- | ||
|
||
.. image:: http://odoo-community.org/logo.png | ||
:alt: Odoo Community Association | ||
:target: http://odoo-community.org | ||
|
||
This module is maintained by the OCA. | ||
|
||
OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use. | ||
|
||
To contribute to this module, please visit http://odoo-community.org. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# -*- coding: utf-8 -*- | ||
############################################################################## | ||
# | ||
# OpenERP, Open Source Management Solution | ||
# This module copyright (C) 2015 Therp BV <http://therp.nl>. | ||
# | ||
# 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 model | ||
from . import controllers |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# -*- coding: utf-8 -*- | ||
############################################################################## | ||
# | ||
# OpenERP, Open Source Management Solution | ||
# This module copyright (C) 2015 Therp BV <http://therp.nl>. | ||
# | ||
# 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": "Backend views for website", | ||
"version": "1.0", | ||
"author": "Therp BV", | ||
"license": "AGPL-3", | ||
"category": "Website", | ||
"summary": "Hook backend views into your website frontend", | ||
"depends": [ | ||
], | ||
"data": [ | ||
'view/templates.xml', | ||
], | ||
"demo": [ | ||
"view/demo.xml", | ||
], | ||
"test": [ | ||
], | ||
"auto_install": False, | ||
"installable": True, | ||
"application": False, | ||
"external_dependencies": { | ||
'python': [], | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# -*- coding: utf-8 -*- | ||
############################################################################## | ||
# | ||
# OpenERP, Open Source Management Solution | ||
# This module copyright (C) 2015 Therp BV <http://therp.nl>. | ||
# | ||
# 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 demo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# -*- coding: utf-8 -*- | ||
############################################################################## | ||
# | ||
# OpenERP, Open Source Management Solution | ||
# This module copyright (C) 2015 Therp BV <http://therp.nl>. | ||
# | ||
# 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 http, _ | ||
|
||
class Demo(http.Controller): | ||
@http.route('/website_backend_views/demo/', auth='user', website=True) | ||
def index(self, debug=False): | ||
if not http.request.env.ref( | ||
'website_backend_views.demo_index', raise_if_not_found=False): | ||
return _('You need to install this module in demo mode for this ' | ||
'url to work!') | ||
return http.request.render('website_backend_views.demo_index') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# -*- coding: utf-8 -*- | ||
############################################################################## | ||
# | ||
# OpenERP, Open Source Management Solution | ||
# This module copyright (C) 2015 Therp BV <http://therp.nl>. | ||
# | ||
# 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_qweb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# -*- coding: utf-8 -*- | ||
############################################################################## | ||
# | ||
# OpenERP, Open Source Management Solution | ||
# This module copyright (C) 2015 Therp BV (<http://therp.nl>). | ||
# | ||
# 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/>. | ||
# | ||
############################################################################## | ||
import simplejson | ||
from lxml import etree | ||
from openerp import models, fields, api, exceptions | ||
|
||
|
||
class IrQweb(models.Model): | ||
_inherit = 'ir.qweb' | ||
|
||
def render_tag_website_backend_view( | ||
self, element, template_attributes, generated_attributes, | ||
qwebcontext): | ||
options = simplejson.loads( | ||
template_attributes.get('website-backend-view', '{}')) | ||
model = self.pool.get(options.get('res_model')) | ||
if not model: | ||
raise NameError( | ||
'Unknown model "%s" or no model defined' % | ||
options.get('res_model')) | ||
etree.SubElement( | ||
element, | ||
'div', | ||
attrib={ | ||
'data-website-backend-view-model': model._name, | ||
'data-website-backend-view-type': options.get( | ||
'view_type', 'form'), | ||
'data-website-backend-view-id': options.get('view_id', ''), | ||
'data-website-backend-view-res-id': str( | ||
options.get('res_id', '')), | ||
'data-website-backend-view-domain': simplejson.dumps( | ||
options.get('domain', '{}')), | ||
}) | ||
etree.SubElement( | ||
element, | ||
't', | ||
attrib={ | ||
't-set': 'website_backend_views_active', | ||
't-value': 'True', | ||
}) | ||
return self.render_element( | ||
element, template_attributes, generated_attributes, | ||
qwebcontext) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file.
58 changes: 58 additions & 0 deletions
58
website_backend_views/static/src/js/website_backend_views.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
//-*- coding: utf-8 -*- | ||
//############################################################################ | ||
// | ||
// OpenERP, Open Source Management Solution | ||
// This module copyright (C) 2015 Therp BV <http://therp.nl>. | ||
// | ||
// 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/>. | ||
// | ||
//############################################################################ | ||
(function() | ||
{ | ||
openerp.website.dom_ready.then(function() | ||
{ | ||
var views = jQuery('[data-website-backend-view-model]'); | ||
if(!views.length) | ||
{ | ||
return; | ||
} | ||
var backend = openerp.init(); | ||
backend.client = new backend.web.WebClient(); | ||
backend.client.start().then(function() | ||
{ | ||
views.each(function(i, view) | ||
{ | ||
view = jQuery(view); | ||
var action = { | ||
'type': 'ir.actions.act_window', | ||
'res_model': view.data('website-backend-view-model'), | ||
'res_id': view.data('website-backend-view-res-id'), | ||
'views': [ | ||
[ | ||
view.data('website-backend-view-id'), | ||
view.data('website-backend-view-type') | ||
] | ||
], | ||
'domain': view.data('website-backend-view-domain') || [], | ||
}; | ||
var action_manager = new backend.web.ActionManager(backend.client); | ||
var view_manager = new backend.web.ViewManagerAction( | ||
action_manager, action); | ||
view_manager.setElement(view); | ||
view_manager.renderElement(); | ||
view_manager.start(); | ||
}); | ||
}); | ||
}); | ||
})() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<openerp> | ||
<data> | ||
<template id="demo_index"> | ||
<t t-call="website.layout"> | ||
<h1>Beneath you'll see an edit form for your main partner. Should work</h1> | ||
<!-- this wil end up in a window action with the appropriate fields set /--> | ||
<t t-website-backend-view='{"res_model": "res.partner", "view_type": "form", "res_id": %(base.main_partner)s, "domain": [["id", "=", %(base.main_partner)s]]}' /> | ||
<div>And of course, you can do whatever you want with the rest of the page. Maybe hide the manager's buttons and provide a nicer UI for saving?</div> | ||
</t> | ||
</template> | ||
</data> | ||
</openerp> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<openerp> | ||
<data> | ||
<template id="assets_frontend" name="website_backend_views assets" inherit_id="website.assets_frontend"> | ||
<xpath expr="." position="inside"> | ||
<script type="text/javascript" src="/website_backend_views/static/src/js/website_backend_views.js"></script> | ||
<link rel="stylesheet" href="/website_backend_views/static/src/css/website_backend_views.css"/> | ||
</xpath> | ||
</template> | ||
<template id="layout" inherit_id="website.layout"> | ||
<xpath expr="//t[@t-call-assets='web.assets_common' and @t-css='false']" position="after"> | ||
<t t-if="website_backend_views_active"> | ||
<t t-call-assets="web.assets_backend" t-css="false" /> | ||
</t> | ||
</xpath> | ||
</template> | ||
</data> | ||
</openerp> |