Odoo Help

2

How to show company logo and customer details in POS ticket?

By
Yenthe
on 12/5/14, 10:49 AM 13,638 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

What about company street, city, country?

Pascal Tremblay
on 3/17/15, 6:41 PM

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

Yenthe
on 3/18/15, 3:04 AM
5

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

@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
on 12/9/14, 3:27 AM

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

Emipro Technologies Pvt. Ltd.
on 12/10/14, 12:02 AM

@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
on 12/10/14, 2:15 AM

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

Emipro Technologies Pvt. Ltd.
on 12/10/14, 3:09 AM

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

Yenthe
on 12/10/14, 3:31 AM

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

Yenthe
on 12/18/14, 6:25 AM

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

Emipro Technologies Pvt. Ltd.
on 12/18/14, 6:35 AM

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

Yenthe
on 12/22/14, 10:28 AM

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

Emipro Technologies Pvt. Ltd.
on 12/23/14, 3:16 PM

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.

Yenthe
on 12/24/14, 2:14 AM
0

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

0
Christian Schneider
On 1/4/17, 3:01 AM

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!

0
Daniel Holden
On 12/1/16, 12:01 PM

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?

0
Mario Vargas
On 12/7/15, 2:06 PM

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

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

Odoo Honduras
on 2/28/16, 6:55 PM
0
Ronal Gamarra
On 8/10/15, 2:17 PM

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

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Register

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

8 follower(s)

Stats

Asked: 12/5/14, 10:49 AM
Seen: 13638 times
Last updated: 12/12/17, 4:25 PM