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

Odoo 17 - Show new field in POS receipt

Langganan

Dapatkan notifikasi saat terdapat aktivitas pada post ini

Pertanyaan ini telah diberikan tanda
recieptpoint_of_salePoint Of Sale17.0
1 Balas
4008 Tampilan
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
Buang
Avatar
S.A. Methsiri Madusanka Sooriyaarachchi
Jawaban Terbai

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
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
Pos Self Order customization
Point Of Sale 17.0
Avatar
0
Mar 25
1301
How to inherit point_of_sale action_pad.xml?
point_of_sale Point Of Sale
Avatar
Avatar
1
Des 24
2354
Custom filter odoo 17
point_of_sale Point Of Sale
Avatar
0
Des 24
1627
Looking for a solution to "MODULE ERROR Adjusting the price is not allowed".
point_of_sale Point Of Sale
Avatar
Avatar
1
Jan 21
3070
How to inherit POS javascript for customization? Diselesaikan
point_of_sale Point Of Sale
Avatar
Avatar
Avatar
Avatar
6
Nov 19
15784
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