Odoo Help


Electronic scale pos interface

on 2/21/13, 11:17 AM 4,141 views

Hello, I'm creating a proxy server to manage the interface between the pos module and the electronic scale. I receive well the http get request on my server, but I don't understand in wich format I have to answer with the actual weight... Can somebody tell me the correct answer format for this json request?

Here is the request I receive:


Url = {htp://localhost:6655/pos/weighting_start?jsonp=jQuery18302055237984620708_1361460794237&id=r360&r={"jsonrpc":"2.0","method":"call","params":{"context":{}},"id":"r360"}&_=1361460812032}

For the javascript code, it's the original device.js (..\server\openerp\addons\point_of_sale\static\src\js):

//returns the weight on the scale. 
        // is called at regular interval (up to 10x/sec) between a weighting_start()
        // and a weighting_end()
        weighting_read_kg: function(){
            var self = this;
                return this.weight;
                        if(self.weighting && !self.bypass_proxy){
                            self.weight = weight;
                return this.weight;

I'm making the server in C#.

I have every data I need but don't know how to format them... Here is the reponse code:

private void HttpWebServer_SendData()
            if (context == null) return;

            string responseString = RxString;
            byte[] buffer = Encoding.UTF8.GetBytes(responseString);
            context.Response.ContentLength64 = buffer.Length;

            context.Response.Headers.Set(HttpResponseHeader.Server, "Serial to http Server");

            System.IO.Stream output = context.Response.OutputStream;
            output.Write(buffer, 0, buffer.Length);

where RxString is the actual weight, ex: "120.5"

Thank you

Can you post your json structure? That way you will get more opportunities to have some answer. Maybe you just have a minor error on the json structure or alike and it will be easier to detect it.

on 2/21/13, 11:19 AM

Edit your question and add there the code. Use the Edit option, it's the small pencil under the question, aligned to the right.

on 2/21/13, 11:49 AM

Sorry, I'll do this

Swiss-Ecotechnologies Sarl, Erbeia
on 2/21/13, 11:49 AM

Nobody can give me an example of proxy answer that the POS 7.0 is waiting in the weighting_read_kg loop?

Swiss-Ecotechnologies Sarl, Erbeia
on 2/28/13, 3:33 AM

Here is the JQuery - JSON Exchange I get: Request: {http://localhost:6655/pos/weighting_start?jsonp=jQuery183021106903867513827_1362069234058&id=r360&r={"jsonrpc":"2.0","method":"call","params":{"context":{}},"id":"r360"}&_=1362069249742}

Response: "{\"jsonrpc\": \"2.0\", \"result\": 12.5, \"id\": \"r360\"}"

I still get a script error in the POS frontend.

Swiss-Ecotechnologies Sarl, Erbeia
on 2/28/13, 12:41 PM

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.


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

2 follower(s)


Asked: 2/21/13, 11:17 AM
Seen: 4141 times
Last updated: 12/19/15, 8:27 AM