This question has been flagged
1 Reply
5706 Views

Hi

i have above 50K products in Point of sale which didn't load fast. For fast product loading i have installed pos_cache module.

But when i update any product or change price of the product pos cache does not automatically synchronised with opened sessions.

For this reason i have modified pos longpolling module . I am comparing current time stamp with cache write date if write date less than 6 minutes i changed the message. On browser side i will reload the browser on message base.

But i am getting this error:

Server application error {"message":"Odoo Server Error","code":200,"data":{"debug":"Traceback (most recent call last):\n  File \"/opt/bitnami/apps/odoo/lib/odoo-10.0.post20171015-py2.7.egg/odoo/http.py\", line 640, in _handle_exception\n    return super(JsonRequest, self)._handle_exception(exception)\n  File \"/opt/bitnami/apps/odoo/lib/odoo-10.0.post20171015-py2.7.egg/odoo/addons/base/ir/ir_http.py\", line 177, in _dispatch\n    rule, arguments = cls._find_handler(return_rule=True)\n  File \"/opt/bitnami/apps/odoo/lib/odoo-10.0.post20171015-py2.7.egg/odoo/addons/base/ir/ir_http.py\", line 79, in _find_handler\n    return cls.routing_map().bind_to_environ(request.httprequest.environ).match(return_rule=return_rule)\n  File \"/opt/bitnami/python/lib/python2.7/site-packages/Werkzeug-0.11.11-py2.7.egg/werkzeug/routing.py\", line 1563, in match\n    raise NotFound()\nNotFound: 404: Not Found\n","exception_type":"internal_error","message":"404: Not Found","name":"werkzeug.exceptions.NotFound","arguments":[]}}  web.assets_common.js:2801:556
    genericJsonRpc/result< http://192.168.8.103/web/content/252-56c0a0e/web.assets_common.js:2801:556
    then/</</< http://192.168.8.103/web/content/252-56c0a0e/web.assets_common.js:510:678
    fire http://192.168.8.103/web/content/252-56c0a0e/web.assets_common.js:504:281
    fireWith http://192.168.8.103/web/content/252-56c0a0e/web.assets_common.js:509:198
    done http://192.168.8.103/web/content/252-56c0a0e/web.assets_common.js:899:86
    callback http://192.168.8.103/web/content/252-56c0a0e/web.assets_common.js:919:15


This is my code:

if channel_name == "pos.longpolling":
            channel = self._get_full_channel_name(channel_name)
            try:
                self.env.cr.execute("SELECT * FROM pos_cache WHERE write_date > current_timestamp - interval '6 minute")
                if len(self.env.fetchall() > 0:
                    notifications.append([channel, "POSCACHE"])
                else:
                    notifications.append([channel, "PONG"])
            except:
                notifications.append([channel, "PONGERROR"])

Avatar
Discard
Best Answer

Am also working to implement the same thing.

It seems you need to create a custom module to override the write and create a function for product.template.

@api.model
def send_field_updates(self, partner_ids, action=""):
channel_name = "pos_partner_sync"
data = {
"message": "update_partner_fields",
"action": action,
"partner_ids": partner_ids,
}
self.env["pos.config"].send_to_all_poses(channel_name, data)

call the above function in the write and create a function as it is in this module https://apps.odoo.com/apps/modules/13.0/pos_partner_sync/ 

Note :  make sure your lonpolling is setuped correctly

Avatar
Discard