This question has been flagged
2 Replies
9475 Views

Hi, I'm new to python and odoo. I made a custom dashboard view. But when I drag one of the views inside, this error comes out:

Odoo Server Error
Traceback (most recent call last):
  File "C:\Users\Administrator\odoo-13.0\odoo\http.py", line 624, in _handle_exception
    return super(JsonRequest, self)._handle_exception(exception)
  File "C:\Users\Administrator\odoo-13.0\odoo\http.py", line 310, in _handle_exception
    raise pycompat.reraise(type(exception), exception, sys.exc_info()[2])
  File "C:\Users\Administrator\odoo-13.0\odoo\tools\pycompat.py", line 14, in reraise
    raise value
  File "C:\Users\Administrator\odoo-13.0\odoo\http.py", line 669, in dispatch
    result = self._call_function(**self.params)
  File "C:\Users\Administrator\odoo-13.0\odoo\http.py", line 350, in _call_function
    return checked_call(self.db, *args, **kwargs)
  File "C:\Users\Administrator\odoo-13.0\odoo\service\model.py", line 93, in wrapper
    return f(dbname, *args, **kwargs)
  File "C:\Users\Administrator\odoo-13.0\odoo\http.py", line 339, in checked_call
    result = self.endpoint(*a, **kw)
  File "C:\Users\Administrator\odoo-13.0\odoo\http.py", line 915, in __call__
    return self.method(*args, **kw)
  File "C:\Users\Administrator\odoo-13.0\odoo\http.py", line 515, in response_wrap
    response = f(*args, **kw)
TypeError: edit_custom() missing 1 required positional argument: 'custom_id'

The process of making a custom dashboard is from a youtube tutorial. The tutorial experienced the same issue and provided a solution, which is to change the js code in the dashboard module in odoo.

//before
_saveDashboard: function () {
        var board = this.renderer.getBoard();
        var arch = QWeb.render('DashBoard.xml'_.extend({}, board));
        return this._rpc({
                route: '/web/view/edit_custom',
                params: {
                    custom_id: this.customViewID,
                    arch: arch,
                }
            }).then(dataManager.invalidate.bind(dataManager));
    },

//after
_saveDashboard: function () {
var board = this.renderer.getBoard();
var arch = QWeb.render('DashBoard.xml', _.extend({}, board));
return this._rpc({
route: '/web/view/edit_custom',
params: {
custom_id: this.customViewID !=null? this.customViewID: '',
arch: arch,
}
}).then(dataManager.invalidate.bind(dataManager));
},

In the tutorial, it works. But what I desperately need is to write a js file to override this _saveDashboard method inside "/addons/board/static/src/js/board_view.js". I tried to google relevant issues on forums but still cannot find a solution or explanation of this. I tried to learn js to understand the issue but still not helpful.


Can anyone show me how to override this method in my custom module?

Avatar
Discard

The solution for this issue is shown in this video, which illustrate the steps of creating dashboard in odoo: https://youtu.be/kfffu4Uzo10?t=924

Best Answer

_saveDashboard: function () {
        var board = this.renderer.getBoard();
        var arch = QWeb.render('DashBoard.xml', _.extend({}, board));
        return this._rpc({
                route: '/web/view/edit_custom',
                params: {
                    custom_id: this.customViewID ? this.customViewID : "",
                    arch: arch,
                }
            }).then(dataManager.invalidate.bind(dataManager));
    },

Replace this propertie in dashboard module static js code, can help anyone who have same issue !


Avatar
Discard

How can we do it in our own custom module?
It works if we edit it in the source code.

Best Answer

For a temporary solution, write the below code in your controller

@http.route('/web/view/edit_custom', type='json', auth="user")

def edit_custom(self, arch):

        return {'result': True}

Cheers!


Avatar
Discard