Przejdź do zawartości
Odoo Menu
  • Zaloguj się
  • Wypróbuj za darmo
  • Aplikacje
    Finanse
    • Księgowość
    • Fakturowanie
    • Wydatki
    • Arkusz kalkulacyjny (BI)
    • Dokumenty
    • Podpisy
    Sprzedaż
    • CRM
    • Sprzedaż
    • PoS Sklep
    • PoS Restauracja
    • Subskrypcje
    • Wypożyczalnia
    Strony Internetowe
    • Kreator Stron Internetowych
    • eCommerce
    • Blog
    • Forum
    • Czat na Żywo
    • eLearning
    Łańcuch dostaw
    • Magazyn
    • Produkcja
    • PLM
    • Zakupy
    • Konserwacja
    • Jakość
    Zasoby Ludzkie
    • Pracownicy
    • Rekrutacja
    • Urlopy
    • Ocena pracy
    • Polecenia Pracownicze
    • Flota
    Marketing
    • Marketing Społecznościowy
    • E-mail Marketing
    • SMS Marketing
    • Wydarzenia
    • Automatyzacja Marketingu
    • Ankiety
    Usługi
    • Projekt
    • Ewidencja czasu pracy
    • Usługi Terenowe
    • Helpdesk
    • Planowanie
    • Spotkania
    Produktywność
    • Dyskusje
    • Zatwierdzenia
    • IoT
    • VoIP
    • Wiedza
    • WhatsApp
    Aplikacje trzecich stron Studio Odoo Odoo Cloud Platform
  • Branże
    Sprzedaż detaliczna
    • Księgarnia
    • Sklep odzieżowy
    • Sklep meblowy
    • Sklep spożywczy
    • Sklep z narzędziami
    • Sklep z zabawkami
    Żywienie i hotelarstwo
    • Bar i Pub
    • Restauracja
    • Fast Food
    • Pensjonat
    • Dystrybutor napojów
    • Hotel
    Agencja nieruchomości
    • Agencja nieruchomości
    • Biuro architektoniczne
    • Budowa
    • Zarządzanie nieruchomościami
    • Ogrodnictwo
    • Stowarzyszenie właścicieli nieruchomości
    Doradztwo
    • Biuro księgowe
    • Partner Odoo
    • Agencja marketingowa
    • Kancelaria prawna
    • Agencja rekrutacyjna
    • Audyt i certyfikacja
    Produkcja
    • Tekstylia
    • Metal
    • Meble
    • Jedzenie
    • Browar
    • Prezenty firmowe
    Zdrowie & Fitness
    • Klub sportowy
    • Salon optyczny
    • Centrum fitness
    • Praktycy Wellness
    • Apteka
    • Salon fryzjerski
    Transakcje
    • Złota rączka
    • Wsparcie Sprzętu IT
    • Systemy energii słonecznej
    • Szewc
    • Firma sprzątająca
    • Usługi HVAC
    Inne
    • Organizacja non-profit
    • Agencja Środowiskowa
    • Wynajem billboardów
    • Fotografia
    • Leasing rowerów
    • Sprzedawca oprogramowania
    Przeglądaj wszystkie branże
  • Community
    Ucz się
    • Samouczki
    • Dokumentacja
    • Certyfikacje
    • Szkolenie
    • Blog
    • Podcast
    Pomóż w nauce innym
    • Program Edukacyjny
    • Scale Up! Gra biznesowa
    • Odwiedź Odoo
    Skorzystaj z oprogramowania
    • Pobierz
    • Porównaj edycje
    • Wydania
    Współpracuj
    • Github
    • Forum
    • Wydarzenia
    • Tłumaczenia
    • Zostań partnerem
    • Usługi dla partnerów
    • Zarejestruj swoją firmę rachunkową
    Skorzystaj z usług
    • Znajdź partnera
    • Znajdź księgowego
    • Spotkaj się z doradcą
    • Usługi wdrożenia
    • Opinie klientów
    • Wsparcie
    • Aktualizacje
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Zaplanuj demo
  • Cennik
  • Pomoc
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
Wszystkie posty Osoby Odznaki
Tagi (Zobacz wszystko)
odoo accounting v14 pos v15
O tym forum
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
Wszystkie posty Osoby Odznaki
Tagi (Zobacz wszystko)
odoo accounting v14 pos v15
O tym forum
Pomoc

Odoo Fill field values using JavaScript

Zaprenumeruj

Otrzymaj powiadomienie o aktywności w tym poście

To pytanie dostało ostrzeżenie
javascript
2 Odpowiedzi
4701 Widoki
Awatar
Yusuf Qisthi

so I want to fill field values of latitude and longitude using JavaScript. I tried document.getElementbyId method and find the input field id manually but when i cllick save it only fills the UI not the actual database. Is there any way to do this?

code:

model.py
latitude = fields.Float(string='Latitude',)
longitude = ​fields.Float(string='Longitude',)

 script

  navigator.geolocation.getCurrentPosition(    successCallback,    errorCallback,    options  );
  functionsuccessCallback(position) {    const { accuracy, latitude, longitude, altitude, heading, speed } =      position.coords;

document.getElementById("o_field_input_13").value = latitude;    document.getElementById("o_field_input_14").value = longitude;

0
Awatar
Odrzuć
Awatar
shubham shiroya
Najlepsza odpowiedź

you need to assign the values to the corresponding fields using the Odoo JavaScript API. Here's an example of how you can modify your script to achieve this:

navigator.geolocation.getCurrentPosition(successCallback, errorCallback, options);

function successCallback(position) {
const { accuracy, latitude, longitude, altitude, heading, speed } = position.coords;

// Use Odoo JavaScript API to set field values
odoo.define('your_module_name.your_script_name', function (require) {
"use strict";

var FormController = require('web.FormController');
var formController = new FormController();
var model = 'your.model'; // Replace with your actual model name

formController.widget = {};
formController.widget.fields = {};

// Set field values
formController.widget.fields['latitude'] = latitude;
formController.widget.fields['longitude'] = longitude;

// Save the record
formController.widget.saveRecord(model, null);
});
}

function errorCallback(error) {
console.error('Error getting geolocation:', error);
}

In the above code, we use the Odoo JavaScript API to set the field values latitude and longitude using the FormController. Replace 'your_module_name' with the actual name of your module and 'your.model' with the name of the model you are working with.

By using the Odoo JavaScript API, the field values will be properly assigned to the underlying record and saved in the database when you call saveRecord().

Make sure to include this JavaScript code in a JavaScript file within your Odoo module and load it properly in the corresponding view.

0
Awatar
Odrzuć
Awatar
Cybrosys Techno Solutions Pvt.Ltd
Najlepsza odpowiedź

Hi,
If you want to add new functionality to a field in Odoo, creating a new field widget can be a solution. By creating a custom field widget, you can customize the behavior and appearance of the field to meet your specific requirements.
To create a new field widget in Odoo, you can follow a step-by-step guide provided in this blog. "https://www.cybrosys.com/blog/how-to-create-a-field-widget-in-the-odoo-16"

Hope it helps

0
Awatar
Odrzuć
Podoba Ci się ta dyskusja? Dołącz do niej!

Stwórz konto dzisiaj, aby cieszyć się ekskluzywnymi funkcjami i wchodzić w interakcje z naszą wspaniałą społecznością!

Zarejestruj się
Powiązane posty Odpowiedzi Widoki Czynność
Odoo Chatter Edit/Create Permissions With Only Model Read?
javascript
Awatar
0
kwi 26
7
Display outstanding invoices
javascript
Awatar
0
mar 26
5
Error While Installing Accounting Module in Odoo 19 Enterprise (Works on Another PC)
javascript
Awatar
0
lis 25
195
Cannot import @website_sale/js/utils
javascript
Awatar
Awatar
2
lis 25
1771
Cómo cerrar una transferencia interna al recibirla desde la vista de código de barras stock.picking
javascript
Awatar
0
lip 25
1951
Społeczność
  • Samouczki
  • Dokumentacja
  • Forum
Open Source
  • Pobierz
  • Github
  • Runbot
  • Tłumaczenia
Usługi
  • Hosting Odoo.sh
  • Wsparcie
  • Aktualizacja
  • Indywidualne rozwiązania
  • Edukacja
  • Znajdź księgowego
  • Znajdź partnera
  • Zostań partnerem
O nas
  • Nasza firma
  • Zasoby marki
  • Skontaktuj się z nami
  • Oferty pracy
  • Wydarzenia
  • Podcast
  • Blog
  • Klienci
  • Informacje prawne • Prywatność
  • Bezpieczeństwo Odoo
الْعَرَبيّة 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 Svenska ภาษาไทย Türkçe українська Tiếng Việt

Odoo to pakiet aplikacji biznesowych typu open source, które zaspokoją wszystkie potrzeby Twojej firmy: CRM, eCommerce, księgowość, inwentaryzacja, punkt sprzedaży, zarządzanie projektami itp.

Unikalną wartością Odoo jest to, że jest jednocześnie bardzo łatwe w użyciu i w pełni zintegrowane.

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