Přejít na obsah
Odoo Menu
  • Přihlásit se
  • Vyzkoušejte zdarma
  • Aplikace
    Finance
    • Účetnictví
    • Fakturace
    • Výdaje
    • Spreadsheet (BI)
    • Dokumenty
    • Podpisy
    Prodej
    • CRM
    • Prodej
    • POS Obchod
    • POS Restaurace
    • Předplatné
    • Pronájem
    Webové stránky
    • Webové stránky
    • E-shop
    • Blog
    • Fórum
    • Živý chat
    • eLearning
    Dodavatelský řetězec
    • Sklad
    • Výroba
    • PLM
    • Nákup
    • Údržba
    • Kvalita
    Lidské zdroje
    • Zaměstnanci
    • Nábor
    • Volno
    • Hodnocení zaměstnanců
    • Doporučení
    • Vozový park
    Marketing
    • Marketing sociálních sítí
    • Emailový marketing
    • SMS Marketing
    • Události
    • Marketingová automatizace
    • Dotazníky
    Služby
    • Projekt
    • Časové výkazy
    • Práce v terénu
    • Helpdesk
    • Plánování
    • Schůzky
    Produktivita
    • Diskuze
    • Schvalování
    • IoT
    • VoIP
    • Znalosti
    • WhatsApp
    Aplikace třetích stran Odoo Studio Odoo cloudová platforma
  • Branže
    Maloobchod
    • Knihkupectví
    • Obchod s oblečením
    • Obchod s nábytkem
    • Potraviny
    • Obchod s hardwarem
    • Hračkářství
    Food & Hospitality
    • Bar a Pub
    • Restaurace
    • Fast Food
    • Guest House
    • Distributor nápojů
    • Hotel
    Real Estate
    • Real Estate Agency
    • Architektonická firma
    • Stavba
    • Správa nemovitostí
    • Zahradnictví
    • Asociace vlastníků nemovitosti
    Consulting
    • Accounting Firm
    • Odoo Partner
    • Marketingová agentura
    • Právník
    • Akvizice talentů
    • Audit a certifikace
    Výroba
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Korporátní dárky
    Zdraví a fitness
    • Sportovní klub
    • Prodejna brýli
    • Fitness Centrum
    • Wellness praktikové
    • Lékárna
    • Kadeřnictví
    Trades
    • Údržbář
    • IT hardware a podpora
    • Solar Energy Systems
    • Výrobce obuvi
    • Úklidové služby
    • HVAC Services
    Others
    • Nonprofit Organization
    • Agentura pro životní prostředí
    • Pronájem billboardů
    • Fotografování
    • Leasing jízdních kol
    • Prodejce softwaru
    Browse all Industries
  • Komunita
    Edukační program
    • Tutoriály
    • Dokumentace
    • Certifikace
    • Vzdělávání
    • Blog
    • Podcast
    Podpora vzdělávání
    • Vzdělávací program
    • Scale Up! Hra na firmu
    • Navštivte Odoo
    Získat software
    • Stáhnout
    • Porovnejte edice
    • Verze
    Spolupráce
    • Github
    • Fórum
    • Události
    • Překlady
    • Stát se partnerem
    • Services for Partners
    • Registrujte svou účetní firmu
    Získat služby
    • Najít partnera
    • Najít účetní
    • Setkejte se s poradcem
    • Implementační služby
    • Zákaznické reference
    • Podpora
    • Upgrady
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Dohodnout demo
  • Ceník
  • Pomoc

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

  • CRM
  • e-Commerce
  • Účetnictví
  • Sklad
  • PoS
  • Projekty
  • MRP
All apps
You need to be registered to interact with the community.
All Posts Lidé Odznaky
Štítky (View all)
odoo accounting v14 pos v15
O tomto fóru
You need to be registered to interact with the community.
All Posts Lidé Odznaky
Štítky (View all)
odoo accounting v14 pos v15
O tomto fóru
Pomoc

Odoo 17 - Show new field in POS receipt

Odebírat

Get notified when there's activity on this post

This question has been flagged
recieptpoint_of_salePoint Of Sale17.0
1 Odpovědět
4037 Zobrazení
Avatar
Kareem Magdy

I'm using Odoo 17 pos I've added new field called is_void, I want to access this field from the receipt, It comes with undefined (empty), but It sent to the DB Correctly here is my code below:

Python:

from odoo import models, fields


class PosOrderLine(models.Model):
    _inherit = "pos.order.line"

    is_void = fields.Boolean(
        string="Is Void",
        default=False,
        help="Indicates whether this line is voided or not.",
    )

    def _order_line_fields(self, line, session_id=None):
        result = super(PosOrderLine, self)._order_line_fields(line, session_id)
        result["is_void"] = line.get("is_void", False)
        return result

    def _export_for_ui(self, orderline):
        result = super()._export_for_ui(orderline)
        result.update(
            {
                "is_void": orderline.is_void,
            }
        )
        return result

Javascript:

patch(Orderline.prototype, {
  constructor() {
    this.is_void = this.is_void || false;
  },

  // // Toggle the is_void flag
  toggleVoid() {
    this.is_void = !this.is_void;
  },

  // Include is_void in export_as_JSON
  export_as_JSON() {
    const result = super.export_as_JSON(...arguments);
    result["is_void"] = this.is_void;
    return result;
  },

  init_from_JSON(json) {
    super.init_from_JSON(...arguments);
    this.is_void = json.is_void || false;
  },

  export_for_printing() {
    const json = this._super(...arguments);
    json.is_void = this.is_void;
    return json;
  },
});
Getting the below error

point_of_sale.assets_prod.min.js:9701 Failed to send orders: [{…}]
_save_to_server @ point_of_sale.assets_prod.min.js:9701
RPC_ERROR://localhost:8069/web/assets/7b7dc0e/point_of_sale.assets_prod.min.js:6586:163)
    at XMLHttpRequest. (http://localhost:8069/web/assets/7b7dc0e/point_of_sale.assets_prod.min.js:6590:13)

Also I tried to load_params but this solution works only if the custom field is predefined not defined or set its value during making the order itself.


0
Avatar
Zrušit
Avatar
S.A. Methsiri Madusanka Sooriyaarachchi
Nejlepší odpověď

The error you're encountering while attempting to include the is_void field in the Odoo POS receipt seems to be related to how the field data is being passed and processed between the client-side JavaScript code and the server-side Python code. Here's a breakdown of how to address this issue:

1. Ensure the Field is Properly Initialized

The is_void field needs to be correctly initialized in both the server-side and client-side code. You appear to be doing this in the export_as_JSON and init_from_JSON methods in JavaScript, and in the _order_line_fields and _export_for_ui methods in Python. These are the right places, but let’s ensure that everything is correctly linked.

2. Review the JavaScript Logic

You need to make sure that is_void is being handled correctly when the order is being exported and imported. Since the error happens during order saving, let’s focus on the methods dealing with data persistence:

javascriptCopy code// Extend Orderline with new logic for is_void field
patch(Orderline.prototype, {
  // Constructor logic to initialize is_void
  constructor() {
    this.is_void = this.is_void || false;
  },

  // Toggle is_void field
  toggleVoid() {
    this.is_void = !this.is_void;
  },

  // Export data as JSON for backend
  export_as_JSON() {
    const result = super.export_as_JSON(...arguments);
    result["is_void"] = this.is_void;
    return result;
  },

  // Initialize from JSON data received from the backend
  init_from_JSON(json) {
    super.init_from_JSON(...arguments);
    this.is_void = json.is_void || false;
  },

  // Export data for printing (receipt)
  export_for_printing() {
    const json = this._super(...arguments);
    json.is_void = this.is_void;
    return json;
  },
});

3. Review the Python Code for Compatibility

Make sure that the Python methods handling the order lines are correctly updating and retrieving the is_void field:

pythonCopy codefrom odoo import models, fields

class PosOrderLine(models.Model):
    _inherit = "pos.order.line"

    is_void = fields.Boolean(
        string="Is Void",
        default=False,
        help="Indicates whether this line is voided or not.",
    )

    def _order_line_fields(self, line, session_id=None):
        result = super(PosOrderLine, self)._order_line_fields(line, session_id)
        result["is_void"] = line.get("is_void", False)
        return result

    def _export_for_ui(self, orderline):
        result = super()._export_for_ui(orderline)
        result.update({
            "is_void": orderline.is_void,
        })
        return result

4. Check the Field Mapping in the POS Frontend

Ensure that your custom is_void field is correctly referenced in all parts of the code that manage the order data, particularly in the load_params and save_to_server processes.

5. Investigate the Error Message

The error Failed to send orders suggests that there might be an issue with how the order data, including your custom field, is being transmitted to the server. Here’s what to look for:

  • Check the Network Tab: In your browser's developer tools, check the network tab to see the payload of the request being sent to the server. Ensure that is_void is correctly included in the JSON data.
  • Check the Logs: Look at the Odoo server logs for any more detailed error messages that might give you clues.

6. Debug the Save Process

You might need to add some debug logging in the JavaScript and Python methods that handle order saving to identify where the process is failing. For example, log the content of export_as_JSON in the JavaScript to ensure the data is being exported correctly.

7. Odoo Field Initialization Timing

If the field is only set during the order process, make sure that any logic depending on is_void doesn't run before the field is initialized (e.g., during the first render or before the order is saved).

8. Possible Fix for load_params Issue

The load_params issue you mentioned typically arises if the field isn’t recognized during the order’s initial loading. Ensure that the field is part of the pos.order.line model and that any dependencies in load_params correctly refer to it.

Final Step: Testing

After applying these changes, test the functionality again by:

  • Adding a line with is_void set to True or False.
  • Saving the order and ensuring it is correctly stored in the database.
  • Checking the receipt to see if is_void is correctly reflected.

This process should help resolve the issue with your is_void field being undefined during the receipt printing process while ensuring it is correctly stored and retrieved in Odoo POS.

1
Avatar
Zrušit
Enjoying the discussion? Don't just read, join in!

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

Přihlásit se
Related Posts Odpovědi Zobrazení Aktivita
Pos Self Order customization
Point Of Sale 17.0
Avatar
0
bře 25
1316
How to inherit point_of_sale action_pad.xml?
point_of_sale Point Of Sale
Avatar
Avatar
1
pro 24
2374
Custom filter odoo 17
point_of_sale Point Of Sale
Avatar
0
pro 24
1630
Looking for a solution to "MODULE ERROR Adjusting the price is not allowed".
point_of_sale Point Of Sale
Avatar
Avatar
1
led 21
3078
How to inherit POS javascript for customization? Vyřešeno
point_of_sale Point Of Sale
Avatar
Avatar
Avatar
Avatar
6
lis 19
15798
Komunita
  • Tutoriály
  • Dokumentace
  • Fórum
Open Source
  • Stáhnout
  • Github
  • Runbot
  • Překlady
Služby
  • Odoo.sh hostování
  • Podpora
  • Upgrade
  • Nestandardní vývoj
  • Edukační program
  • Najít účetní
  • Najít partnera
  • Stát se partnerem
O nás
  • Naše společnost
  • Podklady značky
  • Kontakujte nás
  • Práce
  • Události
  • Podcast
  • Blog
  • Zákazníci
  • Právní dokumenty • Soukromí
  • Zabezpečení
الْعَرَبيّة 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 je balíček open-source aplikací, které pokrývají všechny potřeby vaší společnosti: CRM, e-shop, účetnictví, sklady, kasy, projektové řízení a další.

Unikátní nabídka od Odoo poskytuje velmi jednoduché uživatelské rozhraní a vše je integrované na jednom místě.

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