Skip to Content
Menu
This question has been flagged
3250 Views

we create custom module to enable pos to work offline by checking connection every one minute 

but after first three orders, pos can not send orders to database , and the led show red color 

this snapshot from my code to check internet connection to server

function hostReachable() {

  // Handle IE and more capable browsers
  var xhr = new ( window.ActiveXObject || XMLHttpRequest )( "Microsoft.XMLHTTP" );
  var status;
  var server = window.location.hostname;
  if (window.location.port != '') {
    server += ':'+window.location.port;
  }

  // Open new request as a HEAD to the root hostname with a random param to bust the cache
  xhr.open( "HEAD", "//" + server + "/?rand=" + Math.floor((1 + Math.random()) * 0x10000),false );

  // Open new request as a HEAD to the root hostname with a random param to bust the cache
//  xhr.open( "HEAD", "//" + window.location.host + "/?rand=" + Math.floor((1 + Math.random()) * 0x10000), true );
  // Issue request and handle response
  try {
    xhr.send();

    if (xhr.status >= 200 && xhr.status < 304) {
//        alert("connected");
        return true;
    } else {
            return false;
    }
  } catch (error) {
    return false;
  }

}

any help please ?

edit:snapshot from log file

2014-10-02 11:31:12,628 2089 ERROR Tor-9-24 openerp.sql_db: bad query: insert into "account_bank_statement" (id,"user_id","name","company_id","journal_id","state","period_id","date",create_uid,create_date,write_uid,write_date) values (290,1,'/','1',NULL,'draft',11,'2014-10-02 11:31:12',1,(now() at time zone 'UTC'),1,(now() at time zone 'UTC'))
Traceback (most recent call last):
  File "/home/belalsalah/ERP/server/openerp/sql_db.py", line 226, in execute
    res = self._obj.execute(query, params)
IntegrityError: null value in column "journal_id" violates not-null constraint

2014-10-02 11:31:12,630 2089 ERROR Tor-9-24 openerp.netsvc: Integrity Error
The operation cannot be completed, probably due to the following:
- deletion: you may be trying to delete a record while other records still reference it
- creation/update: a mandatory field is not correctly set

[object with reference: journal_id - journal.id]
Traceback (most recent call last):
  File "/home/belalsalah/ERP/server/openerp/netsvc.py", line 296, in dispatch_rpc
    result = ExportService.getService(service_name).dispatch(method, params)
  File "/home/belalsalah/ERP/server/openerp/service/web_services.py", line 626, in dispatch
    res = fn(db, uid, *params)
  File "/home/belalsalah/ERP/server/openerp/osv/osv.py", line 190, in execute_kw
    return self.execute(db, uid, obj, method, *args, **kw or {})
  File "/home/belalsalah/ERP/server/openerp/osv/osv.py", line 174, in wrapper
    netsvc.abort_response(1, _('Integrity Error'), 'warning', msg)
  File "/home/belalsalah/ERP/server/openerp/netsvc.py", line 71, in abort_response
    raise openerp.osv.osv.except_osv(description, details)
except_osv: ('Integrity Error', 'The operation cannot be completed, probably due to the following:\n- deletion: you may be trying to delete a record while other records still reference it\n- creation/update: a mandatory field is not correctly set\n\n[object with reference: journal_id - journal.id]')
> /home/belalsalah/ERP/server/openerp/netsvc.py(71)abort_response()
-> raise openerp.osv.osv.except_osv(description, details)
(Pdb) 2014-10-02 11:31:20,068 2089 INFO Tor-9-24 werkzeug: 127.0.0.1 - - [02/Oct/2014 11:31:20] "POST /web/dataset/call_kw HTTP/1.1" 200 -
2014-10-02 11:31:21,444 2089 ERROR Tor-9-24 openerp.addons.pos_multi_currency.pos_multi_currency: Dataaaa ############### : {'journal': 118, 'payment_date': '2014-10-02 10:59:09', 'amount': 10.47, 'payment_name': False, 'statement_id': 284}
2014-10-02 11:31:21,775 2089 ERROR Tor-9-24 openerp.sql_db: bad query: insert into "account_bank_statement" (id,"user_id","name","company_id","journal_id","state","period_id","date",create_uid,create_date,write_uid,write_date) values (291,1,'/','1',NULL,'draft',11,'2014-10-02 11:31:21',1,(now() at time zone 'UTC'),1,(now() at time zone 'UTC'))
Traceback (most recent call last):
  File "/home/belalsalah/ERP/server/openerp/sql_db.py", line 226, in execute
    res = self._obj.execute(query, params)
IntegrityError: null value in column "journal_id" violates not-null constraint

2014-10-02 11:31:21,776 2089 ERROR Tor-9-24 openerp.netsvc: Integrity Error
The operation cannot be completed, probably due to the following:
- deletion: you may be trying to delete a record while other records still reference it
- creation/update: a mandatory field is not correctly set

[object with reference: journal_id - journal.id]
Traceback (most recent call last):
  File "/home/belalsalah/ERP/server/openerp/netsvc.py", line 296, in dispatch_rpc
    result = ExportService.getService(service_name).dispatch(method, params)
  File "/home/belalsalah/ERP/server/openerp/service/web_services.py", line 626, in dispatch
    res = fn(db, uid, *params)
  File "/home/belalsalah/ERP/server/openerp/osv/osv.py", line 190, in execute_kw
    return self.execute(db, uid, obj, method, *args, **kw or {})
  File "/home/belalsalah/ERP/server/openerp/osv/osv.py", line 174, in wrapper
    netsvc.abort_response(1, _('Integrity Error'), 'warning', msg)
  File "/home/belalsalah/ERP/server/openerp/netsvc.py", line 71, in abort_response
    raise openerp.osv.osv.except_osv(description, details)
except_osv: ('Integrity Error', 'The operation cannot be completed, probably due to the following:\n- deletion: you may be trying to delete a record while other records still reference it\n- creation/update: a mandatory field is not correctly set\n\n[object with reference: journal_id - journal.id]')
> /home/belalsalah/ERP/server/openerp/netsvc.py(71)abort_response()
-> raise openerp.osv.osv.except_osv(description, details)
(Pdb) 2014-10-02 11:31:29,153 2089 INFO Tor-9-24 werkzeug: 127.0.0.1 - - [02/Oct/2014 11:31:29] "POST /web/dataset/call_kw HTTP/1.1" 200 -
2014-10-02 11:31:30,346 2089 ERROR Tor-9-24 openerp.addons.pos_multi_currency.pos_multi_currency: Dataaaa ############### : {'journal': 118, 'payment_date': '2014-10-02 10:59:09', 'amount': 10.47, 'payment_name': False, 'statement_id': 284}
2014-10-02 11:31:30,685 2089 ERROR Tor-9-24 openerp.sql_db: bad query: insert into "account_bank_statement" (id,"user_id","name","company_id","journal_id","state","period_id","date",create_uid,create_date,write_uid,write_date) values (292,1,'/','1',NULL,'draft',11,'2014-10-02 11:31:30',1,(now() at time zone 'UTC'),1,(now() at time zone 'UTC'))
Traceback (most recent call last):
  File "/home/belalsalah/ERP/server/openerp/sql_db.py", line 226, in execute
    res = self._obj.execute(query, params)
IntegrityError: null value in column "journal_id" violates not-null constraint

2014-10-02 11:31:30,686 2089 ERROR Tor-9-24 openerp.netsvc: Integrity Error
The operation cannot be completed, probably due to the following:
- deletion: you may be trying to delete a record while other records still reference it
- creation/update: a mandatory field is not correctly set

[object with reference: journal_id - journal.id]
Traceback (most recent call last):
  File "/home/belalsalah/ERP/server/openerp/netsvc.py", line 296, in dispatch_rpc
    result = ExportService.getService(service_name).dispatch(method, params)
  File "/home/belalsalah/ERP/server/openerp/service/web_services.py", line 626, in dispatch
    res = fn(db, uid, *params)
  File "/home/belalsalah/ERP/server/openerp/osv/osv.py", line 190, in execute_kw
    return self.execute(db, uid, obj, method, *args, **kw or {})
  File "/home/belalsalah/ERP/server/openerp/osv/osv.py", line 174, in wrapper
    netsvc.abort_response(1, _('Integrity Error'), 'warning', msg)
  File "/home/belalsalah/ERP/server/openerp/netsvc.py", line 71, in abort_response
    raise openerp.osv.osv.except_osv(description, details)
except_osv: ('Integrity Error', 'The operation cannot be completed, probably due to the following:\n- deletion: you may be trying to delete a record while other records still reference it\n- creation/update: a mandatory field is not correctly set\n\n[object with reference: journal_id - journal.id]')
> /home/belalsalah/ERP/server/openerp/netsvc.py(71)abort_response()
-> raise openerp.osv.osv.except_osv(description, details)
(Pdb) 2014-10-02 11:31:50,372 2089 INFO ? werkzeug: 127.0.0.1 - - [02/Oct/2014 11:31:50] "HEAD /?rand=114483 HTTP/1.1" 200 -
2014-10-02 11:31:50,389 2089 INFO Tor-9-24 werkzeug: 127.0.0.1 - - [02/Oct/2014 11:31:50] "POST /web/dataset/call_kw HTTP/1.1" 200 -
2014-10-02 11:32:20,368 2089 INFO ? werkzeug: 127.0.0.1 - - [02/Oct/2014 11:32:20] "HEAD /?rand=108520 HTTP/1.1" 200 -
2014-10-02 11:32:20,385 2089 INFO Tor-9-24 werkzeug: 127.0.0.1 - - [02/Oct/2014 11:32:20] "POST /web/dataset/call_kw HTTP/1.1" 200 -

Avatar
Discard

You do know the POS in version 8 works offline by itself, right? And for your errors, post the logfile please.

Author

i'm working on pos v7 and i try to handle multicurrency payment but after 2 or 3 orders , the red light appear while using hostReachable function show there is connection to server