Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Working on openerp in offline mode

I'm new to openerp and sorry for asking this basic question.

Can we save and retrieve data of customized module ,while openERP is not connected to server[offline mode]. if 'yes', what are the steps to be followed while creating customized module so as to work offline. How does data gets synchronized ? how to connect openerp in offline mode

[Not concerned about the offline data storage limit]

like image 472
user3276175 Avatar asked Feb 05 '14 17:02

user3276175


1 Answers

Your question is not so basic. Natively OpenERP doesn't have offline mode. But being open source and fully extensible OpenERP allows you to do it by yourself.

You can implement such functionality using the HTML5 Web Storage. It allows you to store data locally in the web browser. Your implementation will be responsible for data retrieval at startup and for data synchronisation. For sure you will face some constraints such as storage limit (depending on the browser - something like 5MB or 10MB) and performance issues.

The Point Of Sale module of OpenERP implements such local storage. I'm not sure if it's used any more but you can use it as example. You may want to take a look at the Javascript implementing the local storage functionality of this module here - db.js.

This module can serve as good example of offline implementation. Nevertheless, the offline mode is not used any more in the module. A good reasoning is given in the comment in the beginning of db.js file:

 /* The db module was intended to be used to store all the data needed to run the Point
 * of Sale in offline mode. (Products, Categories, Orders, ...) It would also use WebSQL
 * or IndexedDB to make the searching and sorting products faster. It turned out not to be
 * a so good idea after all.
  *
 * First it is difficult to make the Point of Sale truly independant of the server. A lot
 * of functionality cannot realistically run offline, like generating invoices.
 *
 * IndexedDB turned out to be complicated and slow as hell, and loading all the data at the
 * start made the point of sale take forever to load over small connections.
 *
 * LocalStorage has a hard 5.0MB on chrome. For those kind of sizes, it is just better
 * to put the data in memory and it's not too big to download each time you launch the PoS.
  *
 * So at this point we are dropping the support for offline mode, and this module doesn't really
 * make sense anymore. But if at some point you want to store millions of products and if at
 * that point indexedDB has improved to the point it is usable, you can just implement this API.
 *
 * You would also need to change the way the models are loaded at the start to not reload all your
 * product data.
 */
like image 54
Andrei Boyanov Avatar answered Nov 06 '22 03:11

Andrei Boyanov