Skip to Content
Odoo मेन्यू
  • Sign in
  • मुफ़्त में आज़माएं
  • ऐप्लिकेशन
    फ़ाइनेंस
    • अकाउंटिंग
    • इनवॉइसिंग
    • एक्सपेंस
    • स्प्रेडशीट (बीआई)
    • डॉक्यूमेंट्स
    • साइन
    सेल्स
    • सीआरएम
    • सेल्स
    • पीओएस शॉप
    • पीओएस रेस्टोरेंट
    • सब्सक्रिप्शन
    • रेंटल
    वेबसाइट
    • वेबसाइट बिल्डर
    • ई-कॉमर्स
    • ब्लॉग
    • फ़ोरम
    • लाइव चैट
    • ई-लर्निंग
    सप्लाई चेन
    • इन्वेंट्री
    • मैन्युफ़ैक्चरिंग
    • पीएलएम
    • परचेज़
    • मेंटेनेंस
    • क्वालिटी
    मानव संसाधन
    • कर्मचारी
    • रिक्रूटमेंट
    • टाइम ऑफ़
    • अप्रेज़ल
    • रेफ़रल
    • फ़्लीट
    मार्केटिंग
    • सोशल मार्केटिंग
    • ईमेल मार्केटिंग
    • एसएमएस मार्केटिंग
    • इवेंट
    • मार्केटिंग ऑटोमेशन
    • सर्वे
    सेवाएं
    • प्रोजेक्ट
    • टाइमशीट
    • फ़ील्ड सर्विस
    • हेल्पडेस्क
    • प्लानिंग
    • अपॉइंटमेंट
    प्रॉडक्टिविटी
    • डिस्कस
    • अप्रूवल
    • आईओटी
    • वीओआईपी
    • नॉलेज
    • WhatsApp
    तीसरे पक्ष के ऐप्लिकेशन Odoo स्टूडियो Odoo क्लाउड प्लेटफ़ॉर्म
  • इंडस्ट्री
    रीटेल
    • बुक स्टोर
    • क्लोदिंग स्टोर
    • फ़र्नीचर स्टोर
    • ग्रॉसरी स्टोर
    • हार्डवेयर स्टोर
    • टॉय स्टोर
    Food & Hospitality
    • बार और पब
    • रेस्टोरेंट
    • फ़ास्ट फ़ूड
    • Guest House
    • बेवरिज डिस्ट्रीब्यूटर
    • होटल
    रियल एस्टेट
    • Real Estate Agency
    • आर्किटेक्चर फ़र्म
    • कंसट्रक्शन
    • एस्टेट मैनेजमेंट
    • गार्ड्निंग
    • प्रॉपर्टी ओनर असोसिएशन
    कंसल्टिंग
    • अकाउंटिंग फ़र्म
    • Odoo पार्टनर
    • मार्केटिंग एजेंसी
    • लॉ फ़र्म
    • टैलेंट ऐक्विज़िशन
    • ऑडिट & सर्टिफ़िकेशन
    मैन्युफ़ैक्चरिंग
    • टेक्सटाइल
    • Metal
    • फ़र्नीचर
    • फ़ूड
    • Brewery
    • कॉर्पोरेट गिफ़्ट
    हेल्थ & फिटनेस
    • स्पोर्ट्स क्लब
    • आईवियर स्टोर
    • फिटनेस सेंटर
    • वेलनेस प्रैक्टिशनर
    • फॉर्मेसी
    • हेयर सैलून
    Trades
    • Handyman
    • आईटी हॉर्डवेयर और सपोर्ट
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    अन्य
    • Nonprofit Organization
    • एन्वायरमेंटल एजेंसी
    • बिलबोर्ड रेंटल
    • फ़ोटोग्राफी
    • बाइक लीजिंग
    • सॉफ़्टवेयर रीसेलर
    Browse all Industries
  • कम्यूनिटी
    सीखें
    • ट्यूटोरियल्स
    • दस्तावेज़
    • सर्टिफ़िकेशन
    • ट्रेनिंग
    • ब्लॉग
    • पॉडकास्ट
    शिक्षा को बढ़ावा दें
    • एजुकेशन प्रोग्राम
    • स्केल अप! बिजनेस गेम
    • 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:

  • सीआरएम
  • e-Commerce
  • लेखांकन
  • इन्वेंटरी
  • PoS
  • प्रोजेक्ट
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
टैग (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
टैग (View all)
odoo accounting v14 pos v15
About this forum
Help

POS - Add invoice number Odoo V17

Subscribe

Get notified when there's activity on this post

This question has been flagged
invoicepospoint_of_sale1717.4
1 Reply
2401 Views
Avatar
Edgar Vasquez Vergara

Hello community, I have been trying for several days to update the ticket generated from the POS at the end of the purchase so that it is printed on the thermal ticket machine, I need to add the invoice number, the code that I am implementing so far is the following:


# models/custom_pos.py #
from odoo import models, fields
class PosOrder(models.Model):    _inherit = 'pos.order'
     invoice_id = fields.Many2one('account.move', string='Factura')


/* static/src/js/receipt_order.js */
odoo.define('custom_receipts_for_pos.receipt_order', function (require) 
"use strict";
var models = require('point_of_sale.models');   
var OrderSuper = models.Order.prototype;
models.Order = models.Order.extend({
        initialize: function (attributes, options) {
            OrderSuper.initialize.apply(this, arguments);
            this.invoice_id = this.invoice_id || false;
        },
        export_for_printing: function () {
            var result = OrderSuper.export_for_printing.apply(this, arguments);
            result.invoice_id = this.invoice_id;
            return result;
        },
    });
});


Since I have not been able to load the invoice_id in the JavaScript, I am not doing the xml view, but it should be something similar to this:


< !-- views/post_custom.xml-- >
< odoo>
    < template id="pos_ticket_custom" inherit_id="point_of_sale.receipt">
        < xpath expr="//div[@class='pos-receipt']" position="inside">
            < t t-if="order.invoice_id">
                < div>
                    < strong>Número de Factura:< /strong> < span t-esc="order.invoice_id.name"/>
                < /div>
            < /t>
        < /xpath>
    < /template>
< /odoo>


In case you didn't read the subject, the version is Odoo 17 and I'm testing in the Community and Enterprise version and it doesn't work


HELP!

0
Avatar
Discard
Avatar
Jainesh Shah(Aktiv Software)
Best Answer

Hello Edgar Vasquez Vergara,


To print the invoice number on a POS receipt in Odoo v17, you can simply try this approach.


Js file :


//Code 1 in Comment//


Python file:-


//Code 2 in Comment//


xml file:-


//Code 3 in comment//



Hope this Helps,

If you need any help in customization feel free to contact us.


Thanks & Regards,

Email:  odoo@aktivsoftware.com           

Skype: kalpeshmaheshwari

0
Avatar
Discard
Jainesh Shah(Aktiv Software)

Code 1 :
/ @odoo-module /

import { useState } from "@odoo/owl";
import { ReceiptHeader } from "@point_of_sale/app/screens/receipt_screen/receipt/receipt_header/receipt_header";
import { usePos } from "@point_of_sale/app/store/pos_hook";
import { useService } from "@web/core/utils/hooks";
import { patch } from "@web/core/utils/patch";

patch(ReceiptHeader.prototype, {
/**
* Extends the setup method of the ReceiptHeader component to include invoice number handling.
*
* This patched setup method initializes the component state with an `invoiceNumber` field set to `0`,
* retrieves the POS orders from the `pos` service, and if an order is eligible for invoicing (i.e.,
* `to_invoice` is true and `server_id` is present), it calls the `generate_invoice_number` method
* on the `orm` service to fetch the invoice number for the order. The retrieved invoice number is then
* stored in the component state.
*
* This process ensures that the invoice number is available in the component's state and can be used
* for rendering on the receipt screen template.
*/
async setup(){
super.setup();
this.state = useState({
invoiceNumber: ""
});
this.pos = usePos();
this.orm = useService("orm");
console.log(this.pos.orders.length,'===', this.pos.orders[0].to_invoice, '====', this.pos.orders[0].server_id );
if (this.pos.orders.length && this.pos.orders[0].to_invoice && this.pos.orders[0].server_id){
const InvNumber = await this.orm.call('pos.order', 'generate_invoice_number', [this.context, this.pos.orders[0].server_id]);
this.state.invoiceNumber = InvNumber
}
},
});

Code 2 :

class PosOrder(models.Model):
"""Inherited: Pos Order"""

_inherit = "pos.order"

def generate_invoice_number(self, data):
"""
Generate the invoice number for a given POS order.

This method retrieves the invoice number for a POS order identified by the provided `data`.
It uses the `pos.order` model to browse the specific order and fetch its associated account move name,
which is used as the invoice number. If the order or account move is not found, an empty string is returned.

Returns:
str: The invoice number associated with the POS order. Returns an empty string if the invoice number
cannot be found.

"""
return self.env["pos.order"].sudo().browse(int(data)).account_move.name or ""

Code 3:

<?xml version="1.0" encoding="UTF-8"?>
<templates id="template" xml:space="preserve">
<!--
This template extension modifies the ReceiptHeader view in the Point of Sale module.
It adds a new element to display the invoice number if it is present in the component's state.
-->
<t t-inherit="point_of_sale.ReceiptHeader" t-inherit-mode="extension">
<xpath expr="//div[hasclass('cashier')]" position="after">
<div class="fw-bolder" t-if="this.state.invoiceNumber">
<span class="fs-3" t-esc="state.invoiceNumber"/>
</div>
</xpath>
</t>
</templates>

Enjoying the discussion? Don't just read, join in!

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

Sign up
Related Posts Replies Views Activity
How can we post accounting entries for POS orders that remain in a 'Paid' state instead of being posted, even after the session has been closed?
invoice pos point_of_sale journal_entry
Avatar
0
दिस॰ 24
1681
Invoice number in Odoo POS voucher
invoice pos invoicing point_of_sale
Avatar
Avatar
1
अग॰ 15
4297
How to add customer previous balance and new balance lines on POS invoice
invoice pos customer point_of_sale odoo12
Avatar
0
दिस॰ 22
5273
How to update point of sale order state?
pos point_of_sale
Avatar
Avatar
1
नव॰ 25
356
restrict user acces to the transfert button in pos odoo17 CE
pos 17
Avatar
0
सित॰ 25
641
कम्यूनिटी
  • ट्यूटोरियल्स
  • दस्तावेज़
  • फ़ोरम
ओपन सोर्स
  • डाउनलोड
  • Github
  • रनबॉट
  • अनुवाद
सेवाएं
  • Odoo.sh Hosting
  • सहायता
  • अपग्रेड
  • कस्टम डेवलपमेंट्स
  • शिक्षा
  • अकाउंटेंट खोजें
  • पार्टनर ढूंढें
  • पार्टनर बनें
हमारे बारे में
  • हमारी कंपनी
  • ब्रांड ऐसेट
  • संपर्क करें
  • नौकरियां
  • इवेंट
  • पॉडकास्ट
  • ब्लॉग
  • ग्राहक
  • लीगल • गोपनीयता
  • सुरक्षा
الْعَرَبيّة 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, बिज़नेस से जुड़े ऐप्लिकेशन का एक कलेक्शन है जो ओपन सोर्स पर आधारित है. इसमें आपकी कंपनी की हर ज़रूरत के लिए ऐप्लिकेशन हैं. जैसे, सीआरएम, ई-कॉमर्स, अकाउंटिंग, इन्वेंट्री, पॉइंट ऑफ़ सेल, प्रोजेक्ट मैनेजमेंट वगैरह.

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