Skip to Content
Menu
This question has been flagged

Hello, I have a certain module that displays a popup in the POS. As it's a licensed module I'm not legally allowed to apply direct modifications, so I'm developing another module that extends its functionality.

POS extensions usually are defined like this:

odoo.define('some.module', function(require) {
"use strict";
    var gui = require('point_of_sale.gui');
    var PopupWidget = require('point_of_sale.popups');

    SomePopup = PopupWidget.extend({
    template: 'SomeTemplate',
        show: function(options){...},
        click_confirm: function(options){...},
        renderElement: function(){...}
});
    //this line loads the popup in the POS GUI
    gui.define_popup({name:'some_popup', widget: SomePopup});
   
    //this line isn't always present, and it's absent from the module I want to extend
     return({SomePopup:SomePopup});
});

Worth mentioning that the popup is loaded somewhere in the GUI objects, so the return statement isn't mandatory to load the module. When the return statement is present, I can reference and extend the corresponding popup as easily as this:

odoo.define('my.module', function(require) {
    var gui = require('point_of_sale.gui');
    var some_module = require('some.module');
    var ModifiedPopup = some_module.SomePopup.extend({// here go my own modifications})
    gui.define_popup({name:'some_popup', widget: ModifiedPopup});
});

However when the return statement is absent, I have no easy way to call or extend it. SomePopup *must be* loaded somewhere, otherwise "some module" wouldn't work, but I can't find a way to reference it. Eventually I found a list of defined popups in a variable named Gui.prototype.popup_classes, and called SomePopup with this line:

gui.Gui.prototype.popup_classes.find(o=>o.name='some_popup');

However when I reference and extend it, the popup comes empty as if I was referencing the generic Popup object instead of the one I want to extend.

So my question is, has anyone figured out how to call a loaded popups without needing that return statement from the module that created it?

Thanks beforehand.

Avatar
Discard
Related Posts Replies Views Activity
0
Aug 23
1262
0
Apr 16
24788
13
May 19
21542
1
Apr 24
1023
0
Jul 21
312