How to extend/inherit form_view.js in odoo 15

Viewed 247

Am using Odoo15 customized in file web\static\src\js\views\form_view.js as below method:

form_view.js

      odoo.define('web.FormRenderingEngine', function (require) {

       "use strict";

       process_group: function($group) {

              // custom Code

      }

   });

Am extending this file like as mention below:

var FormRenderingEngine = require('web.FormRenderingEngine');

return FormRenderingEngine.extend({

  process_group: function($group) {   // custom Code

}

}};

.extend or include doesn't work.

please anyone help me to resolve this.

1 Answers

If you look in the console log you will see the following error message:

Uncaught SyntaxError: functions cannot be labelled

It is related to form_view.js script. To create a new form renderer, you can extend the basic renderer or the form renderer like they did with the product configurator

Example:(extending the basic renderer)

odoo.define('web.FormRenderingEngine', function (require) {

"use strict";
var BasicRenderer = require('web.BasicRenderer');

var FormRenderingEngine = BasicRenderer.extend({
    process_group: function($group) {
        // custom Code
    },
});

return FormRenderingEngine;
});

In the FormRenderingEngine, you have a syntax error:

Uncaught SyntaxError: missing ) after argument list

It should end with });

Related