Skip to Content
Odoo Меню
  • Увійти
  • Спробуйте це безкоштовно
  • Додатки
    Фінанси
    • Бухоблік
    • Виставлення рахунку
    • Витрати
    • Електронні таблиці (BI)
    • Документи
    • Підпис
    Продажі
    • CRM
    • Продажі
    • POS Магазин
    • POS Ресторан
    • Підписки
    • Оренда
    Веб-сайти
    • Конструктор веб-сайту
    • Електронна комерція
    • Блог
    • Форум
    • Живий чат
    • Електронне навчання
    Ланцюг поставок
    • Склад
    • Виробництво
    • PLM
    • Купівлі
    • Технічне обслуговування
    • Якість
    Кадри
    • Співробітники
    • Рекрутинг
    • Відпустки
    • Оцінювання
    • Рекомендації
    • Автотранспорт
    Маркетинг
    • Маркетинг соцмереж
    • Email-маркетинг
    • SMS-маркетинг
    • Події
    • Автом. маркетингу
    • Опитування
    Послуги
    • Проект
    • Табелі
    • Виїзне обслуговування
    • Служба підтримки
    • Планування
    • Призначення
    Продуктивність
    • Обговорення
    • Схвалення
    • IoT
    • IP-телефонія
    • База знань
    • WhatsApp
    Сторонні модулі Odoo Studio Платформа Odoo Cloud
  • Сфери
    Роздрібна торгівля
    • Книжковий магазин
    • Магазин одягу
    • Магазин меблів
    • Продуктовий магазин
    • Магазин будівельних матеріалів
    • Магазин іграшок
    Food & Hospitality
    • Бар та паб
    • Ресторан
    • Фастфуд
    • Guest House
    • Дистриб'ютор напоїв
    • Hotel
    Нерухомість
    • Real Estate Agency
    • Архітектурна фірма
    • Будівництво
    • Управління нерухомістю
    • Садівництво
    • Асоціація власників нерухомості
    Консалтинг
    • Бухгалтерська компанія
    • Партнер Odoo
    • Агенція маркетингу
    • Юридична фірма
    • Придбання Талантів
    • Аудит та сертифікація
    Виробництво
    • Textile
    • Metal
    • Меблі
    • Їжа
    • Brewery
    • Корпоративні подарунки
    Здоров'я & Фітнес
    • Спортивний клуб
    • Оптика
    • Фітнес-центр
    • Практики здоров'я
    • Аптека
    • Салон краси
    Trades
    • Ремонтник
    • IT-обладнання та Підтримка
    • Системи сонячної енергії
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Інші
    • Nonprofit Organization
    • Екологічна агенція
    • Оренда білбордів
    • Фотографія
    • Лізинг велосипедів
    • Реселлер програмного забезпечення
    Browse all Industries
  • Спільнота
    Навчання
    • Навчальний посібник
    • Документація
    • Сертифікації
    • Тренування
    • Блог
    • Подкаст
    Сприяйте Освіті
    • Програма навчання
    • Бізнес гра Scale Up!
    • Відвідайте Odoo
    Отримайте програмне забезпечення
    • Завантаження
    • Порівняйте версії
    • Релізи
    Співпрацюйте
    • Github
    • Форум
    • Події
    • Переклади
    • Стати партнером
    • Services for Partners
    • Зареєструйте вашу бухгалтерську фірму
    Отримайте послуги
    • Знайдіть партнера
    • Знайдіть бухгалтера
    • Зустріньтеся з консультантом
    • Послуги з впровадження
    • Референси клієнтів
    • Підтримка
    • Оновлення
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Отримати демо
  • Ціни
  • Допомога

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

  • CRM
  • e-Commerce
  • Бухоблік
  • Склад
  • PoS
  • Проект
  • MRP
All apps
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
All Posts Люди Значки
Мітки (View all)
odoo accounting v14 pos v15
Про цей форум
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
All Posts Люди Значки
Мітки (View all)
odoo accounting v14 pos v15
Про цей форум
Допомога

Custom JavaScript Not Working in POS Module in Odoo 17

Підписатися

Отримуйте сповіщення про активність щодо цієї публікації

Це запитання позначене
developmentdevelopementpospoint_of_sale
2 Відповіді
7903 Переглядів
Аватар
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
Аватар
Відмінити
Аватар
Jainesh Shah(Aktiv Software)
Найкраща відповідь

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
Аватар
Відмінити
Аватар
Maciej Burzymowski
Найкраща відповідь

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
Аватар
Відмінити
Enjoying the discussion? Don't just read, join in!

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

Реєстрація
Related Posts Відповіді Переглядів Дія
How to update point of sale order state?
pos point_of_sale
Аватар
Аватар
1
лист. 25
377
Pos product shows 0.0 units sold
pos point_of_sale
Аватар
Аватар
Аватар
3
квіт. 25
1893
How to have checkboxes for the variables of each product
pos point_of_sale
Аватар
Аватар
1
серп. 24
2975
How to delete POS Sessions! Odoo 16 Вирішено
pos point_of_sale
Аватар
Аватар
Аватар
Аватар
3
трав. 24
13105
POS Session wont close Вирішено
pos point_of_sale
Аватар
Аватар
1
вер. 23
4732
Спільнота
  • Навчальний посібник
  • Документація
  • Форум
Open Source
  • Завантаження
  • Github
  • Runbot
  • Переклади
Послуги
  • Хостинг Odoo.sh
  • Підтримка
  • Оновлення
  • Кастомні доробки
  • Навчання
  • Знайдіть бухгалтера
  • Знайдіть партнера
  • Стати партнером
Про нас
  • Наша компанія
  • Торгові активи
  • Зв'яжіться з нами
  • Вакансії
  • Події
  • Подкаст
  • Блог
  • Клієнти
  • Юридичні документи • Конфіденційність
  • Безпека
الْعَرَبيّة 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 - це набір програм для роботи з відкритим кодом, які охоплюють всі ваші потреби компанії: CRM, електронна комерція, бухгалтерський облік, склад, точка продажу, управління проектами тощо.

Унікальна пропозиція 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