Search code examples
javascriptodooodoo-14

In ODOO14 I want to get current model in javascript function


I have a js function that I am using in action buttons just like confirm="custom message" as attributes. Question is: I need to know that from which action It is called for example if it is called from a sale.order, then I need to know that it is called from sale.order. What I tried is as below.

Example URL: localhost:8069/web?#action=430&cids=1&id=24&menu_id=277&model=sale.order&view_type=form

I need model and id in above url.

here is the sample function I tried.

def = new Promise(function (resolve, reject) {
                var model = this.dataset.model; 
                var call_kw = '/web/dataset/call_kw/my.mudule/my_func';  
                session.rpc(call_kw, {
                    model: 'my.module',
                    method: 'my_func',
                    args: [model],
                    kwargs: {}
                },

Solution

  • It was very simple. I needed to pass model as self.modelName in args

                    .......
                    args: [self.modelName],
                    .......