This question has been flagged
8 Replies
34867 Views

Hi everybody

I'd like to know how to modify the POS ticket. I know its in the point_of_sale module and that I have to edit the file under /static/src/xml/ and then edit the file pos.xml.
So far I've managed to add some details that I'd like etc but now my question is how do I get the logo from the company?
I've managed to hardcode it like this:

<img width="100"  hspace="20" src="/point_of_sale/static/src/img/logo.png" />

But I'd like to get the image from the database, being the logo from the company. 
By default the email etc is fetched by

<t t-esc="widget.pos.company.phone || ''"/>

But when I do this for the logo (<t t-esc="widget.pos.company.logo || ''"/>) nothing is printed. Can anybody tell me how to fix this?
As a second part I would also like to print out the details of the customer in the ticket (customer name, phone, address,..). How can I get those values on the ticket?

Thanks
Yenthe

Avatar
Discard

What about company street, city, country?

Author

Pascal the answer down here from Emipro explains how to get the street, city, .. First load in the model, add it to eh JS and then print it :)

Best Answer

@Yenthe

For printing the company logo

If you check the models.js, it has got an array called 'models' where it tries to load different models defined into the system, in that it includes the model 'res.company', where you can see it tries to fetch different fields of model 'res.company', but in that list it doesn't include the field 'logo'. So by inheritance or by changing the core code try to add the field 'logo' along with other fields of 'res.company' in it and under the pos-ticket template add the following line which will display the company logo on the receipt.

<div id="company_logo" style="text-align:center;"><img t-att-src="'data:image/png;base64,'+ widget.pos.company.logo" height="150px" width="150px"/></div>

Edited

For adding the customer details

go to the screen.js and go to the ReceiptScreenWidget, In there try to find the function "Refresh", below the line

var order = this.pos.get('selectedOrder');

Over there try to add the following code

            customer = order.get_client();
            var street = '';
            var city ='';
            var customer_name='';
            if (customer != undefined)
                {
                customer_name = customer.name;
                street = customer.street;
                city=customer.city;                
                }

            $('.pos-receipt-container', this.$el).html(QWeb.render('PosTicket',{
                    widget:this,
                    order: order,
                    orderlines: order.get('orderLines').models,
                    paymentlines: order.get('paymentLines').models,
                    customer_name:customer_name,
                    customer_street:street,
                    city:city,
                }));

 

Now go to the template file and go to the "PosTicket" template, add the following lines below the value of shop

            customer name:<t t-esc="customer_name"/><br />
            customer street:<t t-esc="street"/><br />
            customer city:<t t-esc="city"/><br />

Hope this helps!!

Avatar
Discard
Author

@Emipro thanks for your reply! Sadly the solution does not seem to work as the image is not showing up.. I've added the field 'logo' in the models as you can see here: http://i.imgur.com/CDp6XFP.png and then I've added your block of code to the file pos.xml as you can see here: http://i.imgur.com/mUSvKkn.png and then I get this: http://i.imgur.com/bSfpG1j.png Am i missing something? And any idea how to get the customers data in the ticket too?

@Yenthe Actually at my side this thing works totally fine !!. What was your image format, can you try some other format the way you can see in the code "data:image/png;base64", try "gif,jpg". I tried again and it worked.

Author

@Empiro, you're right it does work! I set the company logo once again and then it was fixed.. Something probably glitched! Thank you very much for this. Could you also tell me how to add the customer his details? If you do I can accept this answer too, for now I've upvoted it. Thanks for the help!

@yenthe.. I think you mean that whatever customer is been selected for an order, you need the information of that customer to be printed in the receipt. If yes, then let me check it out. I will let you know.

Author

@Empiro, thats correct! You can select a customer for a session and set this person as the customer (see http://i.imgur.com/EyIaFu3.png). I want to print the customer his name, address, ... etc out on the ticket too! So far I found out there should be logic added to models.js as there isn't anything sending it to the XML, but I'm not sure how.

Author

@Empiro, have you found any solution for this? I haven't had any succes for now..

@Yenthe.... Sorry I didn't got chance to look into this. If you can wait till this Saturday then I can try something.

Author

@Emipro did you manage to find a solution? I'm still looking for this but I haven't found myself any solution yet :(

@Yenthe I have added the code for showing the customer details in pos receipt, please have a look at it and let me know if that works or not.

Author

This works like a charm! Thank you very much Emipro, I've both upvoted and accepted the answer! Wish I could upvote this 10 times.

Best Answer

Hello, how to change pos screen on "odoo" logo change company logo with odoo14?

Avatar
Discard

You will have to customize the pos module for that. Please share your code if you have already tried so that we can help you.

Best Answer

i need   customer name  (client name)  in   kitchen receipt,

someone know how to I can do?
Avatar
Discard
Best Answer

Hi , 

may i check how do i extend the function in the screen.js and models.js in the point_of_sales addon ?

i am able to extend the view using <t t-extend="PosTicket"...> and <t t-extend="XmlReceipt"...> but i have added the javascripts in my foder static/src/js and added the asset using xml as follow ,

<odoo>
<data>
<template id="assets_backend" name="pos_ticket_assets" inherit_id="point_of_sale.assets">
<xpath expr="//link[last()]" position="after">
<script type="text/javascript" src="/pos_ticket/static/src/js/pos_ticket.js"></script>
<!-- link rel="stylesheet" href="/pos_multi_session/static/src/css/pos_multi_session.css"/-->
</xpath>
</template>
</data>
</odoo>

and my javascripts , i code as follow .



odoo.define('pos_ticket.pos_ticket', function(require){
"use strict";

var session = require('web.session');
var Backbone = window.Backbone;
var core = require('web.core');
var screens = require('point_of_sale.screens');
var models = require('point_of_sale.models');
//var bus = require('bus.bus');
//var chrome = require('point_of_sale.chrome');
//var longpolling = require('pos_longpolling');
var QWeb = core.qweb;
var Model = require('web.Model');

var _t = core._t;

screens.ReceiptScreenWidget.extend({

print_xml: function() {
//.....i used the above code that was mentioned in this thread but it was not working
// and i have to go to the ODOO STANDARD addons to modify the screen.js and pos_ticket.js
// to modify the print_xml() and render_receipt() , so any advice ????
 }
}),
});


how can we extend the function in the ReceiptScreenWidget ? 

Thanks,

kalmen

Avatar
Discard
Best Answer

Hi!

I tryed the solution from emipro:

<div id="company_logo" style="text-align:center;"><img t-att-src="'data:image/png;base64,'+ widget.pos.company.logo" height="150px" width="150px"/></div>

Now the Printer (Metapace T-3) prints continuous errors "invalid literal for float(): 150 px"

It does not stop, also not after restart printer or restart pos/ odoo Server.

How can I solve this? Help!

Avatar
Discard
Best Answer

I am using version 8. I attempted the solution in this thread, but I see absolutely no change to the POS ticket.

I edited: openerp/addons /point_of_sale/static/src/js/models.js

openerp/addons /point_of_sale/static/src/xml/pos.xml

openerp/addons /point_of_sale/static/src/js/screen.js

..as instructed above.

My POS ticket still looks like this:



Is there a step that I missed?

Avatar
Discard
Best Answer

Can you help me with  ticket number correlative? how can i do that?

Avatar
Discard

Sadly Odoo doesnt allow you to edti the Order number, You have to create a module that extends correlative. I ve developped one. My contact info@odoohonduras.com +504 97719246

Best Answer

As a new field is added, for example I created a field in module sales in the part of customers, that field is called x_cedula, is a custom field, I want it then appears in the POS terminal next to the information telephone, while it can print on the ticket of the tpv

Avatar
Discard