Skip to Content
Odoo Menu
  • Prijavi
  • Try it free
  • Apps
    Finance
    • Accounting
    • Invoicing
    • Expenses
    • Spreadsheet (BI)
    • Documents
    • Sign
    Sales
    • CRM
    • Sales
    • POS Shop
    • POS Restaurant
    • Subscriptions
    • Rental
    Websites
    • Website Builder
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Supply Chain
    • Inventory
    • Manufacturing
    • PLM
    • Purchase
    • Maintenance
    • Quality
    Human Resources
    • Employees
    • Recruitment
    • Time Off
    • Appraisals
    • Referrals
    • Fleet
    Marketing
    • Social Marketing
    • Email Marketing
    • SMS Marketing
    • Events
    • Marketing Automation
    • Surveys
    Services
    • Project
    • Timesheets
    • Field Service
    • Helpdesk
    • Planning
    • Appointments
    Productivity
    • Discuss
    • Approvals
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Industries
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Beverage Distributor
    • Hotel
    Real Estate
    • Real Estate Agency
    • Architecture Firm
    • Construction
    • Estate Management
    • Gardening
    • Property Owner Association
    Consulting
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Manufacturing
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware & Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Others
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Community
    Learn
    • Tutorials
    • Documentation
    • Certifications
    • Training
    • Blog
    • Podcast
    Empower Education
    • Education Program
    • Scale Up! Business Game
    • Visit Odoo
    Get the Software
    • Download
    • Compare Editions
    • Releases
    Collaborate
    • Github
    • Forum
    • Events
    • Translations
    • Become a Partner
    • Services for Partners
    • Register your Accounting Firm
    Get Services
    • Find a Partner
    • Find an Accountant
    • Meet an advisor
    • Implementation Services
    • Customer References
    • Support
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Get a demo
  • Pricing
  • Help

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

  • CRM
  • e-Commerce
  • Knjigovodstvo
  • Zaloga
  • PoS
  • Projekt
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Ključne besede (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Ključne besede (View all)
odoo accounting v14 pos v15
About this forum
Pomoč

POS - Add invoice number Odoo V17

Naroči se

Get notified when there's activity on this post

This question has been flagged
invoicepospoint_of_sale1717.4
1 Odgovori
2344 Prikazi
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
Opusti
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
Opusti
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!

Prijavi
Related Posts Odgovori Prikazi Aktivnost
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
dec. 24
1650
Invoice number in Odoo POS voucher
invoice pos invoicing point_of_sale
Avatar
Avatar
1
avg. 15
4261
How to add customer previous balance and new balance lines on POS invoice
invoice pos customer point_of_sale odoo12
Avatar
0
dec. 22
5234
How to update point of sale order state?
pos point_of_sale
Avatar
Avatar
1
nov. 25
296
restrict user acces to the transfert button in pos odoo17 CE
pos 17
Avatar
0
sep. 25
592
Community
  • Tutorials
  • Documentation
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Translations
Services
  • Odoo.sh Hosting
  • Support
  • Upgrade
  • Custom Developments
  • Education
  • Find an Accountant
  • Find a Partner
  • Become a Partner
About us
  • Our company
  • Brand Assets
  • Contact us
  • Jobs
  • Events
  • Podcast
  • Blog
  • Customers
  • Legal • Privacy
  • Security
الْعَرَبيّة 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 is a suite of open source business apps that cover all your company needs: CRM, eCommerce, accounting, inventory, point of sale, project management, etc.

Odoo's unique value proposition is to be at the same time very easy to use and fully integrated.

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