Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

How to inherit javascript (class, widget) odoo v9

By
Adnier Rosello
on 9/9/16, 12:37 PM 300 views

I tried this code:

odoo.define('oepetstore.payment_widget', function (require) {

"use strict";

var payment_widget = require('account.account_payment_widget');

}); 


but I got this error: 

Missing dependencies: ["account.account_payment_widget"]

Non loaded modules: ["oepetstore.payment_widget"] 

I'm replaced var payment_widget = require('account.account_payment_widget'); by var payment_widget = require('account.payment'); and show this message in console: undefined

Adnier Rosello
on 9/12/16, 1:41 PM

Can I know, even after replacing require('account.account_payment_widget') with require('account.payment') , are you getting the same error in browser console?

Asmita Chavan
on 9/13/16, 7:40 AM

If you want to inherit the existing widget, then you should do it using

var PaymentWidget = core.form_widget_registry.get('payment');

var PaymentWidgetExtended = PaymentWidget.extend({

.

.

functions you want to inherit

.

.

.

});

Asmita Chavan
on 9/13/16, 7:56 AM

Hi Asmita, thanks for answer the question, specifically I'm trying to inherit the ShowPaymentLineWidget defined in account.payment class in account_payment_widget.js (account module) when i try to call this class (with var payment_widget = require('account.payment');) I got this message "undefined" at console, I tried your example and this is good for me, but making a little change this way PaymentWidget.include({...})

Adnier Rosello
on 9/13/16, 10:57 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

2 follower(s)

Stats

Asked: 9/9/16, 12:37 PM
Seen: 300 times
Last updated: 9/29/16, 6:18 PM