Zum Inhalt springen
Odoo Menü
  • Anmelden
  • Jetzt gratis testen
  • Apps
    Finanzen
    • Buchhaltung
    • Rechnungsstellung
    • Spesenabrechnung
    • Tabellenkalkulation (BI)
    • Dokumente
    • E-Signatur
    Vertrieb
    • CRM
    • Vertrieb
    • Kassensystem – Shop
    • Kassensystem – Restaurant
    • Abonnements
    • Vermietung
    Websites
    • Website-Builder
    • E-Commerce
    • Blog
    • Forum
    • Livechat
    • E-Learning
    Lieferkette
    • Lager
    • Fertigung
    • PLM
    • Einkauf
    • Wartung
    • Qualität
    Personalwesen
    • Mitarbeiter
    • Personalbeschaffung
    • Abwesenheiten
    • Mitarbeiterbeurteilung
    • Personalempfehlungen
    • Fuhrpark
    Marketing
    • Social Marketing
    • E-Mail-Marketing
    • SMS-Marketing
    • Veranstaltungen
    • Marketing-Automatisierung
    • Umfragen
    Dienstleistungen
    • Projekte
    • Zeiterfassung
    • Außendienst
    • Kundendienst
    • Planung
    • Termine
    Produktivität
    • Dialog
    • Genehmigungen
    • IoT
    • VoIP
    • Wissensdatenbank
    • WhatsApp
    Apps von Drittanbietern Odoo Studio Odoo Cloud-Plattform
  • Branchen
    Einzelhandel
    • Buchladen
    • Kleidergeschäft
    • Möbelhaus
    • Lebensmittelgeschäft
    • Baumarkt
    • Spielwarengeschäft
    Essen & Gastgewerbe
    • Bar und Kneipe
    • Restaurant
    • Fast Food
    • Gästehaus
    • Getränkehändler
    • Hotel
    Immobilien
    • Immobilienagentur
    • Architekturbüro
    • Baugewerbe
    • Immobilienverwaltung
    • Gartenarbeit
    • Eigentümervereinigung
    Beratung
    • Buchhaltungsfirma
    • Odoo-Partner
    • Marketingagentur
    • Anwaltskanzlei
    • Talentakquise
    • Prüfung & Zertifizierung
    Fertigung
    • Textil
    • Metall
    • Möbel
    • Speisen
    • Brauerei
    • Firmengeschenke
    Gesundheit & Fitness
    • Sportklub
    • Brillengeschäft
    • Fitnessstudio
    • Therapeut
    • Apotheke
    • Friseursalon
    Handel
    • Handyman
    • IT-Hardware & -Support
    • Solarenergiesysteme
    • Schuster
    • Reinigungsdienstleistungen
    • HLK-Dienstleistungen
    Sonstiges
    • Gemeinnützige Organisation
    • Umweltschutzagentur
    • Plakatwandvermietung
    • Fotostudio
    • Fahrrad-Leasing
    • Software-Händler
    Alle Branchen ansehen
  • Community
    Lernen
    • Tutorials
    • Dokumentation
    • Zertifizierungen
    • Schulung
    • Blog
    • Podcast
    Bildung fördern
    • Bildungsprogramm
    • Scale-Up! Planspiel
    • Odoo besuchen
    Software anfragen
    • Herunterladen
    • Editionen vergleichen
    • Releases
    Zusammenarbeiten
    • Github
    • Forum
    • Veranstaltungen
    • Übersetzungen
    • Partner werden
    • Dienstleistungen für Partner
    • Buchhaltungsfirma registrieren
    Services anfragen
    • Partner finden
    • Buchhalter finden
    • Einen Experten treffen
    • Implementierungsservices
    • Kundenreferenzen
    • Support
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Eine Demo erhalten
  • Preiskalkulation
  • Hilfe

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

  • CRM
  • e-Commerce
  • Buchhaltung
  • Lager
  • PoS
  • Projekte
  • MRP
All apps
Sie müssen registriert sein, um mit der Community zu interagieren.
Alle Beiträge Personen Abzeichen
Stichwörter (Alle anzeigen)
odoo accounting v14 pos v15
Über dieses Forum
Sie müssen registriert sein, um mit der Community zu interagieren.
Alle Beiträge Personen Abzeichen
Stichwörter (Alle anzeigen)
odoo accounting v14 pos v15
Über dieses Forum
Hilfe

How to add an existing field validation with OWL?

Abonnieren

Erhalten Sie eine Benachrichtigung, wenn es eine Aktivität zu diesem Beitrag gibt

Diese Frage wurde gekennzeichnet
javascriptodooOWL
2 Antworten
1044 Ansichten
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
Verwerfen
Avatar
Marvin Accuweb.Cloud
Beste Antwort


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
Verwerfen
Avatar
Cybrosys Techno Solutions Pvt.Ltd
Beste Antwort

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
Verwerfen
Diskutieren Sie gerne? Treten Sie bei, statt nur zu lesen!

Erstellen Sie heute ein Konto, um exklusive Funktionen zu nutzen und mit unserer tollen Community zu interagieren!

Registrieren
Verknüpfte Beiträge Antworten Ansichten Aktivität
py.eval in Javascript
javascript OWL
Avatar
0
Jan. 25
1848
Uncaught Javascript Error > Invalid handler (expected a function, received: 'undefined")
javascript OWL
Avatar
0
Sept. 23
3803
Odoo 16 : How to use message_post() to send message in the chatter? Gelöst
odoo OWL
Avatar
Avatar
Avatar
2
Aug. 23
12713
Save and get the value of variable from backend
javascript odoo
Avatar
0
Aug. 23
194
is there onload hook in v13 JS FormViewDialog ? Gelöst
javascript OWL
Avatar
Avatar
1
Mai 23
2937
Community
  • Tutorials
  • Dokumentation
  • Forum
Open Source
  • Herunterladen
  • Github
  • Runbot
  • Übersetzungen
Dienstleistungen
  • Odoo.sh-Hosting
  • Support
  • Upgrade
  • Individuelle Entwicklungen
  • Bildung
  • Buchhalter finden
  • Partner finden
  • Partner werden
Über uns
  • Unsere Firma
  • Markenwerte
  • Kontakt
  • Karriere
  • Veranstaltungen
  • Podcast
  • Blog
  • Kunden
  • Rechtliches • Datenschutz
  • Sicherheit
الْعَرَبيّة 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 ist eine Suite von Open-Source-Betriebsanwendungen, die alle Bedürfnisse Ihres Unternehmens abdecken: CRM, E-Commerce, Buchhaltung, Lager, Kassensystem, Projektmanagement etc.

Das einzigartige Wertversprechen von Odoo ist, dass es gleichzeitig sehr einfach zu bedienen und voll integriert ist.

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