This question has been flagged

I'm trying to simply remove the 'Set as Draft' button from the interface since we're not using a draft state for slides.

I've added an xml file with:

<?xml version="1.0" encoding="UTF-8"?>
<templates id="template" xml:space="preserve">
    <t t-name="website.slide.upload.publishonly" t-extend="website.slide.upload">
        <t t-jquery=".modal-footer button:first-child" t-operation="replace">
        </t>
    </t>
</templates>

And an entry in __manifest__.py which properly registers the xml,

'qweb': ['/my_module/static/src/xml/slides_upload.xml'],

But I'm getting an error "Uncaught Error: QWeb2: Can't clone undefined template website.slide.upload"

I see that the original template is used in the website in /website_slides/static/src/js/slides_upload.js:

/*global $, _, PDFJS */
odoo.define('website_slides.upload', function (require) {
"use strict";
var ajax = require('web.ajax');
var core = require('web.core');
var Widget = require('web.Widget');
var base = require('web_editor.base');
var slides = require('website_slides.slides');
var website = require('website.website');
var qweb = core.qweb;
var _t = core._t;
if(!$('.oe_slide_js_upload').length) {
    return $.Deferred().reject("DOM doesn't contain '.oe_slide_js_upload'");
}
ajax.loadXML('/website_slides/static/src/xml/website_slides.xml', qweb);
var SlideDialog = Widget.extend({
    template: 'website.slide.upload',
    events: {

TRUNCATED

I've tried to inherit the SlideDialog widget using a properly registered js module:

odoo.define('website_slides.upload_publishonly', function (require) {
  "use strict";
  var ajax = require('web.ajax');
  var Widget = require('web.Widget');
  var slides_upload = require('website_slides.upload');
  if(!$('.oe_slide_js_upload').length) {
    return $.Deferred().reject("DOM doesn't contain '.oe_slide_js_upload'");
  }

  ajax.loadXML('/website_slides/static/src/xml/website_slides.xml', qweb);
  ajax.loadXML('/my_module/static/src/xml/slides_upload.xml', qweb);

  var SlideDialog = slides_upload.SlideDialog.include({
    template: 'website.slide.upload.publishonly',
  });
  return SlideDialog;
});

but the same error is raised in the JS console and it doesn't seem like I would need to patch the js at all; just inherit the the xml template. Any help would be appreciated.

Avatar
Discard