Skip to Content
Odoo Menu
  • Prisijungti
  • Išbandykite nemokamai
  • Programėlės
    Finansai
    • Apskaita
    • Pateikimas apmokėjimui
    • Sąnaudos
    • Skaičiuoklė (BI)
    • Dokumentai
    • Pasirašymas
    Pardavimai
    • CRM
    • Pardavimai
    • Kasų sistema - Parduotuvė
    • Kasų sistema - Restoranas
    • Prenumeratos
    • Nuoma
    Svetainės
    • Svetainių kūrėjimo įrankis
    • El. Prekyba
    • Internetinis Tinklaraštis
    • Forumas
    • Tiesioginis pokalbis
    • eMokymasis
    Tiekimo grandinė
    • Atsarga
    • Gamyba
    • PLM
    • Įsigijimai
    • Priežiūra
    • Kokybė
    Žmogaus ištekliai
    • Darbuotojai
    • Įdarbinimas
    • Atostogos
    • Įvertinimai
    • Rekomendacijos
    • Transporto priemonės
    Rinkodara
    • Socialinė rinkodara
    • Rinkodara el. paštu
    • SMS rinkodara
    • Renginiai
    • Rinkodaros automatizavimas
    • Apklausos
    Paslaugos
    • Projektas
    • Darbo laiko žiniaraščiai
    • Priežiūros tarnyba
    • Pagalbos tarnyba
    • Planavimas
    • Rezervacijos
    Produktyvumas
    • Diskucija
    • Patvirtinimai
    • IoT
    • VoIP
    • Žinių biblioteka
    • WhatsApp
    Trečiųjų šalių programos Odoo Studija Odoo debesijos platforma
  • Pramonės šakos
    Mažmeninė prekyba
    • Knygynas
    • Drabužių parduotuvė
    • Baldų parduotuvė
    • Maisto prekių parduotuvė
    • Techninės įrangos parduotuvė
    • Žaislų parduotuvė
    Food & Hospitality
    • Barai ir pub'ai
    • Restoranas
    • Greitasis maistas
    • Guest House
    • Gėrimų platintojas
    • Hotel
    Nekilnojamasis turtas
    • Real Estate Agency
    • Architektūros įmonė
    • Konstrukcija
    • Estate Managament
    • Sodininkauti
    • Turto savininkų asociacija
    Konsultavimas
    • Accounting Firm
    • Odoo Partneris
    • Marketing Agency
    • Teisinė firma
    • Talentų paieška
    • Auditai & sertifikavimas
    Gamyba
    • Textile
    • Metal
    • Furnitures
    • Maistas
    • Brewery
    • Įmonių dovanos
    Sveikata & Fitnesas
    • Sporto klubas
    • Akinių parduotuvė
    • Fitneso Centras
    • Sveikatos praktikai
    • Vaistinė
    • Kirpėjas
    Trades
    • Handyman
    • IT įranga ir palaikymas
    • Saulės energijos sistemos
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Kiti
    • Nonprofit Organization
    • Aplinkos agentūra
    • Reklaminių stendų nuoma
    • Fotografavimas
    • Dviračių nuoma
    • Programinės įrangos perpardavėjas
    Browse all Industries
  • Bendrija
    Mokykitės
    • Mokomosios medžiagos
    • Dokumentacija
    • Sertifikatai
    • Mokymai
    • Internetinis Tinklaraštis
    • Tinklalaidės
    Skatinkite švietinimą
    • Švietimo programa
    • Scale Up! Verslo žaidimas
    • Aplankykite Odoo
    Gaukite programinę įrangą
    • Atsisiųsti
    • Palyginkite versijas
    • Leidimai
    Bendradarbiauti
    • Github
    • Forumas
    • Renginiai
    • Vertimai
    • Tapkite partneriu
    • Services for Partners
    • Registruokite jūsų apskaitos įmonę
    Gaukite paslaugas
    • Susiraskite partnerį
    • Susirask buhalterį
    • Susitikti su konsultantu
    • Diegimo paslaugos
    • Klientų rekomendavimas
    • Palaikymas
    • Atnaujinimai
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Gaukite demo
  • Kainodara
  • Pagalba

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Apskaita
  • Atsarga
  • PoS
  • Projektas
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Žymos (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Žymos (View all)
odoo accounting v14 pos v15
About this forum
Pagalba

hi how call a function python in file javascript in odoo 15 please help

Prenumeruoti

Get notified when there's activity on this post

This question has been flagged
4 Replies
9536 Rodiniai
Portretas
amine ah

hi how call a function python in file javascript in odoo 15 please help


0
Portretas
Atmesti
Portretas
Cybrosys Techno Solutions Pvt.Ltd
Best Answer

Hi,

It is not possible to call a Python function from JavaScript in Odoo 15 directly, as they are two separate programming languages and run on different environments (Python on the server side, JavaScript on the client side). However, you can achieve this by making an API call to the server, where the Python function is located, from your JavaScript code. In Odoo 15, this is typically done using the 'rpc' method provided by the odoo.define JavaScript method.

Here is an example of how you can call a Python function named 'my_python_function' that is defined in an Odoo model named 'my.model' from JavaScript in an Odoo 15:

odoo.define('my_module', function (require) {
var rpc = require('web.rpc');

// Call the Python function
rpc.query({
model: 'my.model',
method: 'my_python_function',
args: [arg1, arg2, ...],
}).then(function (result) {
console.log(result);
});
});

You can pass any arguments you want to the Python function by including them in the 'args' array.
The result of python function will be returned as a promise and you can use the then function to catch it.

Regards

1
Portretas
Atmesti
Portretas
Iwan Prasetya
Best Answer

Hello when i try to call function using this._rpc on the js file, i got error "TypeError: this._rpc is not a function", can someone help me ?

0
Portretas
Atmesti
Portretas
amine ah
Autorius Best Answer

My function python call a action view how and i need every 1h show this action

0
Portretas
Atmesti
MUHAMMAD Imran

You can use the Python built-in library schedule to schedule the execution of your function that calls the action view every hour. Here's an example:

Copy code
import schedule
import time

def call_action_view():
# Code to call the action view goes here

schedule.every(1).hour.do(call_action_view)

while True:
schedule.run_pending()
time.sleep(1)
This code will run the call_action_view function every hour indefinitely.

In Odoo, you can also schedule the execution of a function using the ir.cron model. You would need to create a new record in the ir.cron model with the following fields:

name: A name for the cron job
model_id: The model where the function is located
function: The name of the function you want to execute
interval_number: The frequency at which the function should be executed (e.g. 1 for every hour)
interval_type: The unit of time for the frequency (e.g. 'hours')
nextcall: The next time the cron job will be run
You can also use another odoo module that is odoo-automation it will help you to schedule the function you want to execute and also you can use it to execute any odoo functionality as well.

Portretas
MUHAMMAD Imran
Best Answer

If you need to call a Python function from JavaScript in Odoo 15, you can use the Odoo's RPC (Remote Procedure Call) mechanism to call the Python function on the server and get the result back to the browser.


You can use the odoo.jsonRpc() method provided by the Odoo JavaScript API to call a Python method. The first parameter of this method is the name of the method to call, the second parameter is an object containing the method's parameters, the third parameter is a callback function that will be called when the server returns a response.


For example, if you have a Python method named my_python_method that you want to call from JavaScript, you can use the following code:



odoo.jsonRpc("/your/controller/path", 'call', {

    'method': 'my_python_method',

    'params': {'param1': 'value1', 'param2': 'value2'}

}).then(function (result) {

    // do something with the result here

});

Please note that you need to specify the correct path to your controller, and also need to make sure that you have a corresponding method defined in your controller.

0
Portretas
Atmesti
Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Registracija
Bendrija
  • Mokomosios medžiagos
  • Dokumentacija
  • Forumas
Atvirasis kodas
  • Atsisiųsti
  • Github
  • Runbot
  • Vertimai
Paslaugos
  • Odoo.sh talpinimas
  • Palaikymas
  • Atnaujinti
  • Pritaikytas programavimo kūrimas
  • Švietimas
  • Susirask buhalterį
  • Susiraskite partnerį
  • Tapkite partneriu
Apie mus
  • Mūsų įmonė
  • Prekės ženklo turtas
  • Susisiekite su mumis
  • Darbo pasiūlymai
  • Renginiai
  • Tinklalaidės
  • Internetinis Tinklaraštis
  • Klientai
  • Teisinis • Privatumas
  • Saugumas
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo yra atvirojo kodo verslo programų rinkinys, kuris apima visas įmonės poreikius: CRM, El. Prekybą, Apskaitą, Atsargų, Kasų sistemą, Projektų valdymą ir kt.

Unikali Odoo vertės pasiūla – būti tuo pačiu metu labai lengvai naudojama ir visiškai integruota sistema.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now