This question has been flagged
2489 Views

On Odoo 9.

I'm trying to extend the Mass Mailing module to add product blocks. The idea being that in the same way that you can select an image for an image tag, you can select a product if you've selected a product block in the editor.

I've created a "template" block that I can drop into the editor that gives me the markup with product image, name, price, etc. What I now want to do is have an extra button available within the web_editor.snippet_overlay. Eventually I will have an event attached to this button that will allow me to select the product, and then have the script update the markup with the selected product details, much like the updating of markup when you replace an image in the editor.

I've created an XML file in /static/src/xml/snippets.xml that looks like this;

<?xml version="1.0" encoding="utf-8"?>
<templates id="template" xml:space="preserve">

<t t-extend="web_editor.snippet_overlay">
<t t-jquery=".oe_snippet_parent" t-operation="prepend">
<a href="#" class="btn btn-default btn-sm oe_snippet_product" title="Change Product"><i class="fa fa-barcode"></i></a>
</t>
</t>

</templates>

I've added to __openerp__.py;

'qweb' : [
'static/src/xml/snippets.xml',
],

This is however not working. I did try adding some JS as per some advice given in posts here;

odoo.define('mail_extensions.snippets', function (require) {
'use strict';
var Class = require('web.Class');
var ajax = require('web.ajax');
var core = require('web.core');
var Widget = require('web.Widget');
var base = require('web_editor.base');
var editor = require('web_editor.editor');
var snippets = require('web_editor.snippet.editor');
var qweb = core.qweb;
ajax.loadXML('/mail_extensions/static/src/xml/snippets.xml', qweb);
});

When I include the JS, I can see the snippets.xml file being requested by the browser, but still don't see my extra markup (ie; by button).

This should be one of the easier bits..! What am I missing?





Avatar
Discard