4
votes

I need to make some customizations in the PoS module in Odoo 8.

For this i have created a module call "cus_pos". With this code i extended the interface:

<?xml version="1.0" encoding="UTF-8"?>
    <templates xml:space="preserve">
        <t t-extend="PosWidget">
            <t t-jquery="div.pos-leftpane > div.window > div:last" t-operation="after">
            <div class="payment-lines">
                <div class="paymentline selected">
                    <!-- trigger an error <t t-esc="widget.get_list_salespersons()" /> -->
                    <div class="paymentline-name"> Salesperson: </div>
                    <select id="salesperson-select" class="paymentline-input">
                    </select> 
                </div>
            </div>
        </t>
    </t>
</templates> 

But when i try to extend the widget "PosWidget", to add a method to populate the select "salesperson-select", i get this error "Error: QWeb2 - template['PosWidget']: Runtime Error: TypeError: dict.widget.get_list_salespersons is not a function".

To extend the "PosWidget" i had tried this strategies:

One:

openerp.cus_pos = function(instance) {
    template: 'PosWidget',
    var module = instance.point_of_sale;

    module.PosWidget = module.PosWidget.extend({
        get_list_salespersons: function() {
            console.log("Hurray!!!");
        }
    }); 
}

Two:

function openerp_pos_salesperson(instance, module) { //module is instance.point_of_sale
    var module = instance.point_of_sale;
    var QWeb = instance.web.qweb;
    _t = instance.web._t;

    module.SalePersonWidget = module.PosWidget.include({
        template: 'PosWidget',

        get_list_salespersons: function() {
            console.log("Hurray!!!");
        }        
    });
}

Three:

function openerp_pos_saleperson(instance, module) { //module is instance.point_of_sale
    var module = instance.point_of_sale;
    var QWeb = instance.web.qweb;
    _t = instance.web._t;

    module.SalePersonWidget = module.PosWidget.include({
        template: 'PosWidget',

        get_list_salespersons: function() {
            console.log("Hurray!!!");
        }        
    });
}

(function() {
    var _super = window.openerp.point_of_sale;
    window.openerp.point_of_sale = function(instance) {
        _super(instance);
        var module = instance.point_of_sale;
        openerp_pos_vendedor(instance,module);
    }
})();

Four:

openerp.cus_pos = function(instance) {
    var module = instance.point_of_sale; 
    var _super_ = module.PosWidget.prototype.get_list_salespersons;

    module.PosWidget.prototype.get_list_salespersons = function() {
        console.log("Hurray!!!");
        _super_.call(this);
    };
};

Searching for some documentation i found http://thierry-godin.developpez.com/openerp/tutorial-module-creation-pos-modification-english-version/#LI but is outdated.

Any help on my question would be a great help. Many Thanks

1

1 Answers

4
votes

Yes Thierry Godin wrote things about V7, but a lot of things are obsolete now in V8. you should check new V8 modules in OCA on gitHub / OCA / POS

You can too take a look on the Odoo Forum.

After that, if you're still blocked I can check your problem.

There is 2 ways to overload existing Odoo POS :

(It depends of the kind of objects.)

BTW, what is the objective of your module ?

Kind regards.