diff options
| author | Kishan Gajjar <kig@odoo.com> | 2017-03-21 11:48:02 +0530 |
|---|---|---|
| committer | qsm-odoo <qsm@odoo.com> | 2017-07-04 10:54:20 +0200 |
| commit | aaeef14903d4a3f359fcd6dd61a4f8ee41c947a4 (patch) | |
| tree | 60f858c1ee67be6cdcc0918f1f59a48f8d956c48 /addons/web_editor/models/ir_qweb.py | |
| parent | 79c9f0a7a52b0d88339efcb69296ab3b66f44442 (diff) | |
[IMP] web_editor, website(_*): show all snippets even if module is not installed
* mail_channel, mass_mailing, twitter, event
- t-install attribute holds the technical name of the module that
needs to be install to use a particular snippet.
- Disable the drag & drop feature for these dummy snippets.
- Move some images to website module.
- Installed snippets display at the top of the list.
- Hide not-installed module snippets if user don't have rights to install module.
Diffstat (limited to 'addons/web_editor/models/ir_qweb.py')
| -rw-r--r-- | addons/web_editor/models/ir_qweb.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/addons/web_editor/models/ir_qweb.py b/addons/web_editor/models/ir_qweb.py index 71445d4919e..fcab2902a3b 100644 --- a/addons/web_editor/models/ir_qweb.py +++ b/addons/web_editor/models/ir_qweb.py @@ -50,6 +50,18 @@ class QWeb(models.AbstractModel): div = u'<div name="%s" data-oe-type="snippet" data-oe-thumbnail="%s">' % (escape(ir_qweb.unicodifier(name)), escape(ir_qweb.unicodifier(thumbnail))) return [self._append(ast.Str(div))] + self._compile_node(el, options) + [self._append(ast.Str(u'</div>'))] + def _compile_directive_install(self, el, options): + if self.user_has_groups('base.group_system'): + module = self.env['ir.module.module'].search([('name', '=', el.attrib.get('t-install'))]) + if not module or module.state == 'installed': + return [] + name = el.attrib.get('string') or 'Snippet' + thumbnail = el.attrib.pop('t-thumbnail', 'oe-thumbnail') + div = u'<div name="%s" data-oe-type="snippet" data-module-id="%s" data-oe-thumbnail="%s"><section/></div>' % (escape(ir_qweb.unicodifier(name)), module.id, escape(ir_qweb.unicodifier(thumbnail))) + return [self._append(ast.Str(div))] + else: + return [] + def _compile_directive_tag(self, el, options): if el.get('t-placeholder'): el.set('t-att-placeholder', el.attrib.pop('t-placeholder')) @@ -60,6 +72,7 @@ class QWeb(models.AbstractModel): def _directives_eval_order(self): directives = super(QWeb, self)._directives_eval_order() directives.insert(directives.index('call'), 'snippet') + directives.insert(directives.index('call'), 'install') return directives |
