This question has been flagged
1 Reply
4257 Views

Hello,

I successfully set up a kitchen printer via posbox. I however find the kitchen ticket to be too scanty in terms of the order details. I would therefore like to add the following details:

1. The Point of sale Name

2. The name of the User/Cashier who made the order.

I figured I can get the user id by editing the return object of the computeChanges function in /point_of_sale/static/src/js/multiprint.js to be

return {
'user':json.user_id,
'date': json.creation_date,
'new': add,
'cancelled': rem,
'table': json.table || false,
'floor': json.floor || false,
'name': json.name || 'unknown order',
'time': {
        'hours': hours,
        'minutes': minutes,
    },
};

I then add these details to the qweb template. This however gives me the user id instead of the name. Anyone with an idea on how I can add these details to the ticket?



Avatar
Discard
Best Answer

Hi Cyrus,

You can console.log() the content of "json" data, or simply "json.user_id" and see it's content.

Since you get the user ID instead of name that means json.user_id hold the user id, and it's the one that will be rendered by Qweb.

Look in Json if the name exists in the dictionary, if exists you can change json.user_id by it. but if not you will need to get it and then return it.


Good luck,

Avatar
Discard
Author

Hello Youness,

Thats exactly what I had done and was able to push the user_id to Qweb. Initially, it just pushes the ordername, the changes and the time as seen on line 280 here https://github.com/odoo/odoo/blob/9.0/addons/pos_restaurant/static/src/js/multiprint.js

Since the username does not exist in the json data, any idea how I can get it and return it?

Hi Cyrus,

Here is it is :

if (self.pos.cashier) {

console.log(self.pos.cashier.name)

} else {

console.log(self.pos.user.name)

}

If Cashier is not selected then the "self.pos.cashier" will be null, and then you will need to return the default logged in user which is "self.pos.user.name".

Good luck,