Skip to Content
Odoo Menu
  • Log ind
  • Prøv gratis
  • apps
    Økonomi
    • Bogføring
    • Fakturering
    • Udgifter
    • Regneark (BI)
    • Dokumenter
    • e-Signatur
    Salg
    • CRM
    • Salg
    • POS Butik
    • POS Restaurant
    • Abonnementer
    • Udlejning
    Hjemmeside
    • Hjemmesidebygger
    • e-Handel
    • Blog
    • Forum
    • LiveChat
    • e-Læring
    Forsyningskæde
    • Lagerbeholdning
    • Produktion
    • PLM
    • Indkøb
    • Vedligeholdelse
    • Kvalitet
    HR
    • Medarbejdere
    • Rekruttering
    • Fravær
    • Medarbejdersamtaler
    • Anbefalinger
    • Flåde
    Marketing
    • Markedsføring på sociale medier
    • E-mailmarketing
    • SMS-marketing
    • Arrangementer
    • Automatiseret marketing
    • Spørgeundersøgelser
    Tjenester
    • Projekt
    • Timesedler
    • Udkørende Service
    • Kundeservice
    • Planlægning
    • Aftaler
    Produktivitet
    • Dialog
    • Godkendelser
    • IoT
    • VoIP
    • Vidensdeling
    • WhatsApp
    Tredjepartsapps Odoo Studio Odoo Cloud-platform
  • Brancher
    Detailhandel
    • Boghandel
    • Tøjforretning
    • Møbelforretning
    • Dagligvarebutik
    • Byggemarked
    • Legetøjsforretning
    Mad og værtsskab
    • Bar og pub
    • Restaurant
    • Fastfood
    • Gæstehus
    • Drikkevareforhandler
    • Hotel
    Ejendom
    • Ejendomsmægler
    • Arkitektfirma
    • Byggeri
    • Ejendomsadministration
    • Havearbejde
    • Boligejerforening
    Rådgivning
    • Regnskabsfirma
    • Odoo-partner
    • Marketingbureau
    • Advokatfirma
    • Rekruttering
    • Audit & certificering
    Produktion
    • Tekstil
    • Metal
    • Møbler
    • Fødevareproduktion
    • Bryggeri
    • Firmagave
    Heldbred & Fitness
    • Sportsklub
    • Optiker
    • Fitnesscenter
    • Kosmetolog
    • Apotek
    • Frisør
    Håndværk
    • Handyman
    • IT-hardware og support
    • Solenergisystemer
    • Skomager
    • Rengøringsservicer
    • VVS- og ventilationsservice
    Andet
    • Nonprofitorganisation
    • Miljøagentur
    • Udlejning af billboards
    • Fotografi
    • Cykeludlejning
    • Softwareforhandler
    Gennemse alle brancher
  • Community
    Få mere at vide
    • Tutorials
    • Dokumentation
    • Certificeringer
    • Oplæring
    • Blog
    • Podcast
    Bliv klogere
    • Udannelselsesprogram
    • Scale Up!-virksomhedsspillet
    • Besøg Odoo
    Få softwaren
    • Download
    • Sammenlign versioner
    • Udgaver
    Samarbejde
    • Github
    • Forum
    • Arrangementer
    • Oversættelser
    • Bliv partner
    • Tjenester til partnere
    • Registrér dit regnskabsfirma
    Modtag tjenester
    • Find en partner
    • Find en bogholder
    • Kontakt en rådgiver
    • Implementeringstjenester
    • Kundereferencer
    • Support
    • Opgraderinger
    Github Youtube Twitter LinkedIn Instagram Facebook Spotify
    +1 (650) 691-3277
    Få en demo
  • Prissætning
  • Hjælp

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

  • CRM
  • e-Commerce
  • Bogføring
  • Lager
  • PoS
  • Projekt
  • MRP
All apps
Du skal være registreret for at interagere med fællesskabet.
All Posts People Emblemer
Tags (View all)
odoo accounting v14 pos v15
Om dette forum
Du skal være registreret for at interagere med fællesskabet.
All Posts People Emblemer
Tags (View all)
odoo accounting v14 pos v15
Om dette forum
Hjælp

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

Tilmeld

Få besked, når der er aktivitet på dette indlæg

Dette spørgsmål er blevet anmeldt
4 Besvarelser
9540 Visninger
Avatar
amine ah

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


0
Avatar
Kassér
Avatar
Cybrosys Techno Solutions Pvt.Ltd
Bedste svar

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
Avatar
Kassér
Avatar
Iwan Prasetya
Bedste svar

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
Avatar
Kassér
Avatar
amine ah
Forfatter Bedste svar

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

0
Avatar
Kassér
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.

Avatar
MUHAMMAD Imran
Bedste svar

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
Avatar
Kassér
Enjoying the discussion? Don't just read, join in!

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

Tilmeld dig
Community
  • Tutorials
  • Dokumentation
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Oversættelser
Tjenester
  • Odoo.sh-hosting
  • Support
  • Opgradere
  • Individuelt tilpasset udvikling
  • Uddannelse
  • Find en bogholder
  • Find en partner
  • Bliv partner
Om os
  • Vores virksomhed
  • Brandaktiver
  • Kontakt os
  • Stillinger
  • Arrangementer
  • Podcast
  • Blog
  • Kunder
  • Juridiske dokumenter • Privatlivspolitik
  • Sikkerhedspolitik
الْعَرَبيّة 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 er en samling open source-forretningsapps, der dækker alle dine virksomhedsbehov – lige fra CRM, e-handel og bogføring til lagerstyring, POS, projektledelse og meget mere.

Det unikke ved Odoo er, at systemet både er brugervenligt og fuldt integreret.

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