Odoo Help

Welcome!

This community 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.

0

How are orders saved to the database point_of_sale touchscreen?

By
splucena
on 6/10/14, 2:53 AM 1,045 views

I am trying to trace how orders from touchscreen interface of the point of sale module are saved to database but to no avail. I have tracked the process but don't understand how these scripts saves order/s to the database.

file: addons/point_of_sale/static/src/js/db.js

* save: function(store,data){
            //alert(store);
            //alert(this.look_deep(data));
            var str_data = JSON.stringify(data);
            localStorage[this.name + '_' + store] = JSON.stringify(data);
            this.cache[store] = data;
        },

*In a series of function calls this was the last called. But I don't understand how this script would save data to the database. Is this the function that saves or is there anything else involved in the process.

0

Thierry Godin

--Thierry Godin--
1516
| 8 7 8
Collegien, France
--Thierry Godin--

..

Thierry Godin
On 6/10/14, 6:02 AM

Hi ,

 

In V7, this is the _flush() function  in static/js/model.js around line 275 :

        _flush: function(index){
            var self = this;
            var orders = this.db.get_orders();
            self.set('nbr_pending_operations',orders.length);

            var order  = orders[index];
            if(!order){
                return;
            }
            //try to push an order to the server
            // shadow : true is to prevent a spinner to appear in case of timeout
            (new instance.web.Model('pos.order')).call('create_from_ui',[[order]],undefined,{ shadow:true })
                .fail(function(unused, event){
                    //don't show error popup if it fails
                    event.preventDefault();
                    console.error('Failed to send order:',order);
                    self._flush(index+1);
                })
                .done(function(){
                    //remove from db if success
                    self.db.remove_order(order.id);
                    self._flush(index);
                });
        },

Hope this helps.

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 6/10/14, 2:53 AM
Seen: 1045 times
Last updated: 3/16/15, 8:10 AM