Skip to Content
Odoo Menu
  • Sign in
  • 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
  • Accounting
  • Inventory
  • PoS
  • Project
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
Help

how do i show the custom inherited field in pos.order to the receipt order on the Point of Sale client?

Subscribe

Get notified when there's activity on this post

This question has been flagged
2 Replies
1306 Views
Avatar
Mangandaralam Sakti

this is my code:

# pos_order_inherit.py

from odoo import models, fields, api

from odoo.exceptions import ValidationError

class PosOrderInherit(models.Model):

​ _inherit = 'pos.order' 

​_description = 'POS Order Inherit'

pos_number = fields.Char(string="Pos Number", readonly=True)

@api.model

​def create(self, vals): 

​ ​if not vals.get('pos_number'): 

​ ​ ​vals['pos_number'] = self.env['ir.sequence'].next_by_code('pos.number.sequence') or '/' 

​ ​return super(PosOrderInherit, self).create(vals)


# pos_order_inherit_view.xml
<?xml version="1.0" encoding="utf-8"?>

<odoo>

​<record id="seq_pos_number" model="ir.sequence">

​ ​<field name="name">POS Number</field>

​ ​<field name="code">pos.number.sequence</field>

​ ​<field name="prefix">POS_NUMBER/</field>

​ ​<field name="padding">5</field>

​ ​<field name="company_id" eval="False"/>

​</record>


​<record id="pos_order_inherit_view_tree" model="ir.ui.view">

​ ​ <field name="name">pos.order.tree.inherit</field>

​ ​<field name="model">pos.order</field>

​ ​<field name="inherit_id" ref="point_of_sale.view_pos_order_tree"/>

​ ​<field name="arch" type="xml">

​ ​ ​<xpath expr="//field[@name='config_id']" position="after"> ​ ​ ​ ​<field name="pos_number" readonly="1"/>

​ ​ ​</xpath>

​ ​</field>

​</record>


​<record id="pos_order_inherit_view_form" model="ir.ui.view">

​ ​<field name="name">pos.order.form.inherit</field>

​ ​<field name="model">pos.order</field>

​ ​ <field name="inherit_id" ref="point_of_sale.view_pos_pos_form"/> <field name="arch" type="xml">

​ ​<xpath expr="//field[@name='name']" position="after">

​ ​ ​<field name="pos_number" readonly="1"/>

​ ​ </xpath>

​ ​</field>

​</record>

​</odoo>


I want to show this inherited field to the receipt order on the PoS client

0
Avatar
Discard
Avatar
lauralordelaure
Best Answer

To display the custom pos_number field on the Point of Sale (PoS) receipt in Odoo, you need to extend the PoS client-side JavaScript and modify the receipt template. Odoo’s PoS uses a combination of Python (server-side) and JavaScript (client-side) to handle the receipt rendering. Since your field is already added to the pos.order model, you’ll need to:

  1. Extend the PoS data model to include the pos_number field in the client-side order data.
  2. Modify the receipt template to display the pos_number field.

0
Avatar
Discard
lauralordelaure

https://geometrydashlitepc.io

Avatar
Jainesh Shah(Aktiv Software)
Best Answer

Hello, Alam


    To show the custom field inherited in pos.order to the receipt order on the Point of Sale, please follow below steps.

   

        1) Create a Module, then create a folder structure of staic folder as shown in below image.

       

           

        2) Register the pos assets in __manifest__.py file.

   

         

        3) Print ' pos_order.py ' file add below code snippet.


               //Code 1 in comment//


        4) Print 'payment_screen.js' file add below code snippet.


                //Code 2 in comment//


        5) Print 'order_receipt.xml' file add below code snippet.


               //Code 3 in comment//


       6) Print 'models.js' file add below code snippet.


               //Code 4 in comment//


       7) Do not forget to replace 'your_module_name' to Actual module name in 'order_receipt.xml' file.

       


    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 :

# -*- coding: utf-8 -*-

from odoo import api, models, fields

class PosOrder(models.Model):
_inherit = 'pos.order'

pos_number = fields.Char(string="Pos Number", readonly=True)

@api.model
def create(self,vals):
if not vals.get('pos_number'):
vals['pos_number'] = self.env['ir.sequence'].next_by_code('pos.number.sequence') or '/'
return super(PosOrder,self).create(vals)

def get_pos_number(self):
order = self.search([], limit=1, order='id desc')
pos_number = order.pos_number
return pos_number

Code 2 :

/* @odoo-module */

import { _t } from "@web/core/l10n/translation";
import { PaymentScreen } from "@point_of_sale/app/screens/payment_screen/payment_screen";
import { patch } from "@web/core/utils/patch";
import { OnlinePaymentPopup } from "@pos_online_payment/app/utils/online_payment_popup/online_payment_popup";
import { ErrorPopup } from "@point_of_sale/app/errors/popups/error_popup";
import { floatIsZero } from "@web/core/utils/numbers";
import { qrCodeSrc } from "@point_of_sale/utils";
import { useService } from "@web/core/utils/hooks";
import { useRef, onPatched, onMounted, useState } from "@odoo/owl";
import { usePos } from "@point_of_sale/app/store/pos_hook";

patch(PaymentScreen.prototype, {
setup() {
super.setup();
this.rpc = useService("rpc");
this.state = useState({ inputValue: this.props.startingValue });
this.pos = usePos();
this.popup = useService("popup");
this.userService = useService("user");
this.action = useService("action");
},

async afterOrderValidation(suggestToSync = false) {
const pos_number = this.pos.orders[0].server_id
const pos_number = await this.orm.call('payment.transaction', 'get_number_of_installment', [pos_number]);
this.pos.get_order().created_pos_number = pos_number
await super.afterOrderValidation(...arguments);
},

});

Code 3 :

<?xml version="1.0" encoding="UTF-8"?>
<templates id="template" xml:space="preserve">
<t t-name="your_module_name.OrderReceipt" t-inherit="point_of_sale.OrderReceipt" t-inherit-mode="extension">
<xpath expr="//div[hasclass('paymentlines')]" position="inside">
<t t-if="props.data.new_pos_number">
<h4>Session Name : <t t-esc="props.data.new_pos_number"/></h4>
</t>
</xpath>
</t>
</templates>

Code 4 :

/* @odoo-module */

import { Order } from "@point_of_sale/app/store/models";
import { usePos } from "@point_of_sale/app/store/pos_hook";
import { patch } from "@web/core/utils/patch";
import { useService } from "@web/core/utils/hooks";

patch(Order.prototype, {
export_for_printing() {
const result = super.export_for_printing(...arguments);
result.new_pos_number = this.pos.get_order().created_pos_number;
return result;
},

});

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
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