Skip to Content
Menu
This question has been flagged
2 Replies
5328 Views

Can some guide me on how to solve this  TypeError: self._super is not a function in odoo v12.
The error occurs on the bolded self._super() line in the code below
Thank you.


odoo.define('pos_allow_credit.pos', function (require) {
"use strict";

	var screens = require('point_of_sale.screens');
	var models = require('point_of_sale.models');
	var core = require('web.core');
	var rpc = require('web.rpc');
	var Session = require('web.Session');
	var PosBaseWidget = require('point_of_sale.BaseWidget');

	var QWeb = core.qweb;
	var _t = core._t;

	
	models.load_fields("res.partner", ['allow_credit']);
	screens.PaymentScreenWidget.include({
		finalize_validation: function() {
			var self = this;
	    	if(self.pos.partner.allow_credit){
	    		self._super();
    		} else {

    			rpc.query({
                        model: 'res.partner',
                        method: 'get_status',
                    })

    				.then(function(result){
    					self._super();
    				})
    				.fail(function (error, event){
    					event.preventDefault();
    					self.pos.gui.show_popup('error',{
    						'title': _t('Not Allowed'),
    						'body': _t("You are not Qualified"),
    					});
    					return;
    				});
    			}
    		}
    	});

});
Avatar
Discard
Best Answer

instead of var self = this;
use var _super = this._super.bind(this);
and call
_super() like

.then(function(result){ 
   _super();
})

Avatar
Discard
Author

Thanks for the answer.

Your answer works on Odoo v12

But failed to work in Odoo v13.

On v13 I got this error: TypeError: rpc.query is not a function

Strange! 'web.rpc' API doesn't change between V12 to V13

can you double-check

Author Best Answer

Could any experienced JS assist please

Avatar
Discard

Hello
have you found a solution?

Author

@ Ali,
I have not found a solution yet. Any help?

Related Posts Replies Views Activity
3
Oct 23
5975
1
Sep 23
1965
1
May 23
1001
2
Apr 23
1375
1
Mar 23
996