Skip ke Konten
Odoo Menu
  • Login
  • Uji coba gratis
  • Aplikasi
    Keuangan
    • Akuntansi
    • Faktur
    • Pengeluaran
    • Spreadsheet (BI)
    • Dokumen
    • Tanda Tangan
    Sales
    • CRM
    • Sales
    • POS Toko
    • POS Restoran
    • Langganan
    • Rental
    Website
    • Website Builder
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Rantai Pasokan
    • Inventaris
    • Manufaktur
    • PLM
    • Purchase
    • Maintenance
    • Kualitas
    Sumber Daya Manusia
    • Karyawan
    • Rekrutmen
    • Cuti
    • Appraisal
    • Referensi
    • Armada
    Marketing
    • Social Marketing
    • Email Marketing
    • SMS Marketing
    • Acara
    • Otomatisasi Marketing
    • Survei
    Layanan
    • Project
    • Timesheet
    • Layanan Lapangan
    • Meja Bantuan
    • Planning
    • Appointment
    Produktivitas
    • Diskusi
    • Approval
    • IoT
    • VoIP
    • Pengetahuan
    • WhatsApp
    Aplikasi pihak ketiga Odoo Studio Platform Odoo Cloud
  • Industri-Industri
    Retail
    • Toko Buku
    • Toko Baju
    • Toko Furnitur
    • Toko Kelontong
    • Toko Hardware
    • Toko Mainan
    Makanan & Hospitality
    • Bar dan Pub
    • Restoran
    • Fast Food
    • Rumah Tamu
    • Distributor Minuman
    • Hotel
    Real Estate
    • Agensi Real Estate
    • Firma Arsitektur
    • Konstruksi
    • Estate Management
    • Perkebunan
    • Asosiasi Pemilik Properti
    Konsultansi
    • Firma Akuntansi
    • Mitra Odoo
    • Agensi Marketing
    • Firma huku
    • Talent Acquisition
    • Audit & Sertifikasi
    Manufaktur
    • Tekstil
    • Logam
    • Perabotan
    • Makanan
    • Brewery
    • Corporate Gift
    Kesehatan & Fitness
    • Sports Club
    • Toko Kacamata
    • Fitness Center
    • Wellness Practitioners
    • Farmasi
    • Salon Rambut
    Perdagangan
    • Handyman
    • IT Hardware & Support
    • Sistem-Sistem Energi Surya
    • Pembuat Sepatu
    • Cleaning Service
    • Layanan HVAC
    Lainnya
    • Organisasi Nirlaba
    • Agen Lingkungan
    • Rental Billboard
    • Fotografi
    • Penyewaan Sepeda
    • Reseller Software
    Browse semua Industri
  • Komunitas
    Belajar
    • Tutorial-tutorial
    • Dokumentasi
    • Sertifikasi
    • Pelatihan
    • Blog
    • Podcast
    Empower Education
    • Program Edukasi
    • Game Bisnis 'Scale Up!'
    • Kunjungi Odoo
    Dapatkan Softwarenya
    • Download
    • Bandingkan Edisi
    • Daftar Rilis
    Kolaborasi
    • Github
    • Forum
    • Acara
    • Terjemahan
    • Menjadi Partner
    • Layanan untuk Partner
    • Daftarkan perusahaan Akuntansi Anda.
    Dapatkan Layanan
    • Temukan Mitra
    • Temukan Akuntan
    • Temui penasihat
    • Layanan Implementasi
    • Referensi Pelanggan
    • Bantuan
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Dapatkan demo
  • Harga
  • Bantuan

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

  • CRM
  • e-Commerce
  • Akuntansi
  • Inventaris
  • PoS
  • Project
  • MRP
All apps
Anda harus terdaftar untuk dapat berinteraksi di komunitas.
Semua Post Orang Lencana-Lencana
Label (Lihat semua)
odoo accounting v14 pos v15
Mengenai forum ini
Anda harus terdaftar untuk dapat berinteraksi di komunitas.
Semua Post Orang Lencana-Lencana
Label (Lihat semua)
odoo accounting v14 pos v15
Mengenai forum ini
Help

How to add an existing field validation with OWL?

Langganan

Dapatkan notifikasi saat terdapat aktivitas pada post ini

Pertanyaan ini telah diberikan tanda
javascriptodooOWL
2 Replies
1036 Tampilan
Avatar
Khaled

I want to add validation for the email field in the Contacts app, however, I don't know what libraries should I import in my JS file. Also, how to edit the field validation using OWL.

0
Avatar
Buang
Avatar
Marvin Accuweb.Cloud
Jawaban Terbai


Hello Khaled,

Here’s an example of how you can add a simple validation for the email field in the Contacts app using OWL. You don’t need any extra libraries; OWL and the web client utilities are already available in Odoo.


/** @odoo-module **/

import { CharField } from "@web/views/fields/char/char_field";

import { patch } from "@web/core/utils/patch";

patch(CharField.prototype, "email_validation_patch", {

    async onInput(ev) {

        await super.onInput(ev);

        if (this.props.name === "email") {

            const value = ev.target.value || "";

            const emailPattern = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;

            const isValid = emailPattern.test(value);

            if (!isValid && value) {

                this.notification.add("Please enter a valid email address.", { type: "warning" });

                ev.target.classList.add("o_invalid_field");

            } else {

                ev.target.classList.remove("o_invalid_field");

            }

        }

    },

});


Add this file under your custom module path:

/static/src/js/email_validation.js

Then include it in your manifest file:

'assets': {

    'web.assets_backend': [

        '/your_module/static/src/js/email_validation.js',

    ],

},


After updating and reloading, the email field will show a warning message when the format is invalid.



0
Avatar
Buang
Avatar
Cybrosys Techno Solutions Pvt.Ltd
Jawaban Terbai

Hi,


The error occurs because your pos_data_loader.js is importing @point_of_sale/app/store/pos_global_state, which exists only in Odoo 19, not Odoo 18. In Odoo 18, the equivalent is point_of_sale.models or PosModel, and your code should patch its prototype instead. Additionally, your custom JS must be included in the point_of_sale.assets bundle in your module manifest. Using Odoo 19 import paths in Odoo 18 causes unmet dependency errors, so adapting the imports and ensuring proper asset inclusion will resolve the issue.


Try the following code,


/** @odoo-module **/

import { patch } from "web.utils";

import PosModel from "point_of_sale.models";  // <-- Correct path for v18


console.log("PSMS: Extending POS data models for Odoo 18");


patch(PosModel.prototype, "psms_pos_data_loader", {

    async _load_data() {

        console.log("PSMS: _load_data running...");


        await super._load_data();


        const orm = this.env.services.orm;

        if (!orm) return;


        const configs = await orm.searchRead("pos.config", [], [

            "id", "name", "display_stock", "nozzle_ids", "pump_ids", "tanks_ids"

        ]);


        const currentConfigId = this.config_id;

        const currentConfig = configs.find(c => c.id === currentConfigId);


        if (!currentConfig) return;


        this.display_stock = currentConfig.display_stock;

        this.nozzle_ids = currentConfig.nozzle_ids || [];

        this.pump_ids = currentConfig.pump_ids || [];

        this.tanks_ids = currentConfig.tanks_ids || [];


        console.log(" POS CONFIG", this);


        // Load nozzle data if any

        if (this.nozzle_ids.length) {

            const nozzles = await orm.searchRead("petrol.nozzle", [["id", "in", this.nozzle_ids]], [

                "id", "name", "pump_id", "tank_id", "product_id"

            ]);

            this.db.nozzle_by_id = {};

            for (const nozzle of nozzles) this.db.nozzle_by_id[nozzle.id] = nozzle;

            console.log(` PSMS: Loaded ${nozzles.length} nozzles for this POS`);

        }

    }

});


Hope it helps

0
Avatar
Buang
Menikmati diskusi? Jangan hanya membaca, ikuti!

Buat akun sekarang untuk menikmati fitur eksklufi dan agar terlibat dengan komunitas kami!

Daftar
Post Terkait Replies Tampilan Aktivitas
py.eval in Javascript
javascript OWL
Avatar
0
Jan 25
1846
Uncaught Javascript Error > Invalid handler (expected a function, received: 'undefined")
javascript OWL
Avatar
0
Sep 23
3800
Odoo 16 : How to use message_post() to send message in the chatter? Diselesaikan
odoo OWL
Avatar
Avatar
Avatar
2
Agu 23
12710
Save and get the value of variable from backend
javascript odoo
Avatar
0
Agu 23
194
is there onload hook in v13 JS FormViewDialog ? Diselesaikan
javascript OWL
Avatar
Avatar
1
Mei 23
2933
Komunitas
  • Tutorial-tutorial
  • Dokumentasi
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Terjemahan
Layanan
  • Odoo.sh Hosting
  • Bantuan
  • Peningkatan
  • Custom Development
  • Pendidikan
  • Temukan Akuntan
  • Temukan Mitra
  • Menjadi Partner
Tentang Kami
  • Perusahaan kami
  • Aset Merek
  • Hubungi kami
  • Tugas
  • Acara
  • Podcast
  • Blog
  • Pelanggan
  • Hukum • Privasi
  • Keamanan
الْعَرَبيّة 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 adalah rangkaian aplikasi bisnis open source yang mencakup semua kebutuhan perusahaan Anda: CRM, eCommerce, akuntansi, inventaris, point of sale, manajemen project, dan seterusnya.

Mudah digunakan dan terintegrasi penuh pada saat yang sama adalah value proposition unik Odoo.

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