Siirry sisältöön
Odoo Menu
  • Kirjaudu sisään
  • Kokeile ilmaiseksi
  • Sovellukset
    Talous
    • Kirjanpito
    • Laskutus
    • Kulut
    • Datataulukot (BI)
    • Asiakirjat
    • Allekirjoita
    Myynti
    • CRM
    • Myynti
    • Kassajärjestelmä myymälään
    • Kassajärjestelmä ravintolaan
    • Tilaukset
    • Vuokraus
    Verkkosivut
    • Verkkosivun Rakennustyökalu
    • Verkkokauppa
    • Blogi
    • Foorumi
    • Livechat
    • Verkko-oppiminen
    Toimitusketju
    • Varastointi
    • Tuotanto
    • Tuotteen elinkaaren hallinta (PLM)
    • Ostot
    • Huolto
    • Laatu
    Henkilöstöhallinto
    • Työntekijät
    • Rekrytointi
    • Vapaat
    • Arvioinnit
    • Suositukset
    • Kuljetuskalusto
    Markkinointi
    • Somemarkkinointi
    • Sähköpostimarkkinointi
    • Tekstiviestimarkkinointi
    • Tapahtumat
    • Markkinoinnin automaatio
    • Kyselyt
    Palvelut
    • Projekti
    • Työaikakirjaukset
    • Kenttähuolto
    • Asiakaspalvelu
    • Suunnittelu
    • Ajanvaraukset
    Tuottavuus
    • Viestintä
    • Hyväksynnät
    • IoT
    • IP-puhe
    • Tietokirjasto
    • WhatsApp
    Kolmannen osapuolen sovellukset Odoo-Studio Odoo-Pilvialusta
  • Toimialat
    Vähittäiskauppa
    • Kirjakauppa
    • Vaatekauppa
    • Huonekaluliike
    • Ruokakauppa
    • Laitteistokauppa
    • Lelukauppa
    Ruoka & Majoitus
    • Baari ja Pubi
    • Ravintola
    • Pikaruoka
    • Majatalo
    • Juomien jakelija
    • Hotelli
    Kiinteistöt
    • Kiinteistönvälitystoimisto
    • Arkkitehtitoimisto
    • Rakentaminen
    • Kiinteistönhallinta
    • Puutarhanhoito
    • Kiinteistön omistajien yhdistys
    Konsultointi
    • Tilitoimisto
    • Odoo-kumppani
    • Markkinointitoimisto
    • Lakitoimisto
    • Osaajahankinta
    • Tilintarkastus & sertifiointi
    Tuotanto
    • Tekstiili
    • Metalli
    • Huonekalut
    • Ruoka
    • Panimo
    • Yrityslahjat
    Terveys & Liikunta
    • Urheiluseura
    • Silmälasiliike
    • Kuntokeskus
    • Hyvinvointialan ammattilaiset
    • Apteekki
    • Kampaamo
    Kaupat
    • Yleismies
    • IT-laitteisto & Tuki
    • Aurinkoenergiajärjestelmät
    • Suutari
    • Siivouspalvelut
    • LVI-palvelut
    Muut
    • Voittoa tavoittelematon järjestö
    • Ympäristötoimisto
    • Mainostaulujen vuokraus  
    • Valokuvaus
    • Leasing-pyörät
    • Ohjelmistojen jälleenmyyjä
    Selaa kaikkia toimialoja
  • Yhteisö
    Opi
    • Kurssit
    • Dokumentaatio
    • Todistukset
    • Koulutus
    • Blogi
    • Podcast
    Kannusta kouluttautumaan
    • Koulutusohjelmat
    • Scale Up! Liiketoimintapeli
    • Vieraile Odoolla
    Hanki ohjelmisto
    • Lataa
    • Vertaile versioita
    • Julkaisut
    Tee yhteistyötä
    • Github
    • Foorumi
    • Tapahtumat
    • Käännökset
    • Ryhdy kumppaniksi
    • Kumppanipalvelut
    • Rekisteröi tilitoimistosi
    Hanki palveluja
    • Löydä kumppani
    • Löydä kirjanpitäjä
    • Varaa asiantuntijatapaaminen
    • Implementaatiopalvelut
    • Asiakasreferenssit
    • Tuki
    • Versionkorotukset
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Varaa demo
  • Hinnoittelu
  • Asiakaspalvelu

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

  • CRM
  • e-Commerce
  • Kirjanpito
  • Varastointi
  • PoS
  • Projekti
  • MRP
All apps
Sinun on rekisteröidyttävä, jotta voit olla vuorovaikutuksessa yhteisön kanssa.
Kaikki kirjoitukset Ihmiset Merkit
Tunnisteet (Näytä kaikki)
odoo accounting v14 pos v15
Tietoa tästä foorumista
Sinun on rekisteröidyttävä, jotta voit olla vuorovaikutuksessa yhteisön kanssa.
Kaikki kirjoitukset Ihmiset Merkit
Tunnisteet (Näytä kaikki)
odoo accounting v14 pos v15
Tietoa tästä foorumista
Apua

Custom JavaScript Not Working in POS Module in Odoo 17

Tilaa

Saat ilmoituksen, kun tähän viestiin ilmaantuu aktiviteettia

Tämä kysymys on merkitty
developmentdevelopementpospoint_of_sale
2 Vastaukset
7907 Näkymät
Avatar
Technology Pill Business Solution

I am currently working on a custom module for Odoo 17 and facing an issue with JavaScript customization in the Point of Sale (POS) module. I am trying to override the add_product method in the POS, but my changes don't seem to take effect. I've ensured that my JavaScript file is included in the point_of_sale.assets bundle, but I'm not seeing the expected behavior or any console logs that I've added for debugging.


I included the JavaScript file in the point_of_sale.assets bundle in my module's __manifest__.py. Here's a snippet of the code for reference:


odoo.define('give_and_get_order_module.CustomOrder', function(require) {
    'use strict';

    var models = require('point_of_sale.models');
    var OrderSuper = models.Order.prototype;

    models.Order.include({
        add_product: function(product, options) {
            console.log("Custom add_product method called");
            if (!options || !options.quantity) {
                options = options || {};
                options.quantity = -1;
            }
            return OrderSuper.add_product.apply(this, [product, options]);
        },
    });
});

And the relevant part of my __manifest__.py:

'assets': {
    'point_of_sale.assets': [
        'give_and_get_order_module/static/src/js/custom_order.js',
    ],
},

I would appreciate any insights or suggestions on what I might be missing or doing wrong. Is there a specific aspect of POS module customization in Odoo 17 that I need to be aware of?

Thank you in advance for your help!

0
Avatar
Hylkää
Avatar
Jainesh Shah(Aktiv Software)
Paras vastaus

Hey Technology Pill Business Solution,


I hope you are doing well.


For inheriting add_product function, we need to follow the steps defined below:

1. Create models.js file under static > src > overrides > models directory.

2. Use the below code for inheriting Order from base models.js using Patch.


/* @odoo-module /


import { Order, Orderline, Payment } from "@point_of_sale/app/store/models";

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


patch(Order.prototype, {

    async add_product(product, options) {

// Your custom code

        return super.add_product(...arguments);

    },

});


3. Insert custom JS path in manifest.

Note:- Add ‘point_of_sale’ in your customer module’s depends.

- Odoo.define is deprecated in Odoo V17.


Hope this will help you.

Thanks & Regards,
Email:   odoo@aktivsoftware.com      

Skype: kalpeshmaheshwari

0
Avatar
Hylkää
Avatar
Maciej Burzymowski
Paras vastaus

From your code, it seems like you’re correctly including your JavaScript file in the 'point_of_sale.assets' bundle and your method override also looks correct. However, there are a few things you might want to check:

  1. Order of JS files: Ensure that your JavaScript file is loaded after the original file you’re trying to override. The order of JavaScript files in the assets bundle can affect the behavior of your customization.
  2. Module Dependency: Make sure that your custom module depends on the 'point_of_sale' module. You can specify this in the 'depends' section of your '__manifest__.py' file.
  3. Browser Cache: Clear your browser cache or try in incognito mode. Sometimes, the browser might be loading a cached version of your JavaScript file.
  4. Server Restart: After making changes to the '__manifest__.py' file, you need to restart your Odoo server and upgrade your module.

If you’ve checked all of these and your method override is still not working, it might be due to some changes in Odoo 17’s POS module. In Odoo 17, there are new ways to load custom models and fields. You might need to inherit the 'pos.session' model and overwrite the '_pos_ui_models_to_load()' method. Also, creating a custom screen involves patching the 'PosStore' and overriding the '_processData' function.

I hope this helps! If you’re still facing issues, please provide more details about the behavior you’re observing and any error messages you’re seeing. I’ll do my best to assist you further. 

Best regards,
Maciej Burzymowski


0
Avatar
Hylkää
Nautitko keskustelusta? Älä vain lue, vaan osallistu!

Luo tili jo tänään nauttiaksesi yksinoikeusominaisuuksista ja osallistuaksesi mahtavaan yhteisöömme!

Rekisteröidy
Aiheeseen liittyviä artikkeleita Vastaukset Näkymät Toimenpide
How to update point of sale order state?
pos point_of_sale
Avatar
Avatar
1
marrask. 25
378
Pos product shows 0.0 units sold
pos point_of_sale
Avatar
Avatar
Avatar
3
huhtik. 25
1895
How to have checkboxes for the variables of each product
pos point_of_sale
Avatar
Avatar
1
elok. 24
2976
How to delete POS Sessions! Odoo 16 Ratkaistu
pos point_of_sale
Avatar
Avatar
Avatar
Avatar
3
toukok. 24
13109
POS Session wont close Ratkaistu
pos point_of_sale
Avatar
Avatar
1
syysk. 23
4733
Yhteisö
  • Kurssit
  • Dokumentaatio
  • Foorumi
Avoin lähdekoodi
  • Lataa
  • Github
  • Runbot
  • Käännökset
Palvelut
  • Odoo.sh hosting
  • Tuki
  • Versionkorotus
  • Räätälöidyt kehitykset
  • Koulutus
  • Löydä kirjanpitäjä
  • Löydä kumppani
  • Ryhdy kumppaniksi
Meistä
  • Yrityksemme
  • Tavaramerkki
  • Ota yhteyttä
  • Työpaikat
  • Tapahtumat
  • Podcast
  • Blogi
  • Asiakkaat
  • Oikeudellinen ilmoitus • Yksityisyys
  • Tietoturva
الْعَرَبيّة 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 on kokoelma avoimen lähdekoodin yrityssovelluksia, jotka kattavat kaikki yrityksesi tarpeet: asiakkuudenhallinta eli CRM, verkkokauppa, kirjanpito, varastointi, kassajärjestelmä, projektinhallinta, jne.

Odoon uniikki arvolupaus on olla samanaikaisesti erittäin helppokäyttöinen ja täysin integroitu.

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