Overslaan naar inhoud
Menu
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Deze vraag is gerapporteerd
1 Beantwoorden
3206 Weergaven

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.

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

I need model in above url.

here is the sample function


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: {}
},
Avatar
Annuleer
Beste antwoord

I know this already 2 yrs. But since nobody answer and this is in top search result on google (atleast that's what happen in my browser)

This is for odoo 16

if you inherit from AbstractController, you can use this.modelName

if you are unsure, you can try add following to any executable js

$.exposed = {
    this:this
}


This will expose that variable so you can access it with console in the browser by typing $.exposed

DON'T FORGET TO REMOVE THAT CODE WHEN YOU PUSH TO PRODUCTION

Avatar
Annuleer
Gerelateerde posts Antwoorden Weergaven Activiteit
0
mei 23
2791
1
jan. 23
7585
1
dec. 20
7125
1
mei 20
3730
2
feb. 20
5548