Js framework | SoloLearn: Learn to code for FREE!


Js framework

Learning js in Odoo. Please see the below link. https://github.com/odoo/odoo/blob/13.0/addons/web/static/src/js/widgets/date_picker.js I would to know in odoo framework which library is used in the above code? And the above code format follows: 1) var Widget = require('web.Widget') 2) Object defined many user-defined functions. Default init() and start() method have all object. 3) Functions defined as: Functionname : myfunct(){ } I would like to know the above format which lib is using? Using object properties name can i able to get require package properties list. But unable to get predefined function used in that object how to get user defined method? Is any tutorial available for the above the js library framework? And underscore js library used in odoo framework is any courses available for this library in sololearn. Please share.

2/11/2020 4:48:01 PM

Prakash Jain

2 Answers

New Answer


anime js


I know this is an old post, but I will let this to help. Sorry for my bad English... Odoo uses its own undocumented framework. As far as I know it doesn't have name. Odoo 14 will come with a whole new front end framework named OWL (Odoo Web Library). It will use Typescript. But Odoo <= 13 uses this other framework. This Javascript framework is built on backbone.js and underscore. But There is no good official documentation or tutorial to learn this... You have to look a lot of code and examples to learn... To answer you some question: Why require? Odoo uses an module based javascript framework, I mean, odoo separate its code using modules. It's like python modules... They compile all the javascript files in just one file. every odoo.define("some.module") is a new module that odoo will register. odoo.define("some.module", function (require)) { require("other.module") } Require is an argument. You will use it to handle dependencies. (Other module will have the same form, and require will return the value that these function return...) In javascript everything is an object, so you functions are object, variable are objects. and a object has properties. And yes, a property can be a funcition. Type this in your browser: var a = { myFunction: function (msg) {console.log(msg);} }; a.myFunction("A test!!!"); a.myFunction = function (msg) {console.error("Error: " + msg);}; a.myFunction("A test!!!"); a.myFunction = "Hola"; console.log(a.myFunction);