From 93a93f0d5aa12fc00ef34c429ebfd3e85d1682ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20BEAU?= Date: Tue, 16 May 2017 18:30:00 +0200 Subject: [PATCH] [ADD] start module pos_order_no_offline, the aim is to have a blocking synchronisation in order to be sure to synchronise the order without any posibility to destroy it --- pos_order_no_offline/README.rst | 38 ++++++++++++++ pos_order_no_offline/__init__.py | 1 + pos_order_no_offline/__openerp__.py | 30 ++++++++++++ .../static/src/js/pos_order_no_offline.js | 49 +++++++++++++++++++ .../view/pos_order_no_offline.xml | 13 +++++ 5 files changed, 131 insertions(+) create mode 100644 pos_order_no_offline/README.rst create mode 100644 pos_order_no_offline/__init__.py create mode 100644 pos_order_no_offline/__openerp__.py create mode 100644 pos_order_no_offline/static/src/js/pos_order_no_offline.js create mode 100644 pos_order_no_offline/view/pos_order_no_offline.xml diff --git a/pos_order_no_offline/README.rst b/pos_order_no_offline/README.rst new file mode 100644 index 00000000..5c6da361 --- /dev/null +++ b/pos_order_no_offline/README.rst @@ -0,0 +1,38 @@ +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :alt: License: AGPL-3 + +POS Order No offline mode +=========================== + +This module remove the possibility to generate a pos ticket without connexion. +This mean that no pos order can be drop + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed feedback +`here `_. + +Credits +======= + +Contributors +------------ + +* Sébastien Beau + +Maintainer +---------- + +.. image:: http://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: http://odoo-community.org + +This module is maintained by the OCA. + +OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use. + +To contribute to this module, please visit http://odoo-community.org. + diff --git a/pos_order_no_offline/__init__.py b/pos_order_no_offline/__init__.py new file mode 100644 index 00000000..40a96afc --- /dev/null +++ b/pos_order_no_offline/__init__.py @@ -0,0 +1 @@ +# -*- coding: utf-8 -*- diff --git a/pos_order_no_offline/__openerp__.py b/pos_order_no_offline/__openerp__.py new file mode 100644 index 00000000..3ab446c3 --- /dev/null +++ b/pos_order_no_offline/__openerp__.py @@ -0,0 +1,30 @@ +# -*- coding: utf-8 -*- +# Copyright 2017 Akretion (http://www.akretion.com). +# @author Sébastien BEAU +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + "name": "POS Order no offline mode", + "summary": "Remove offine mode on pos order", + "version": "8.1.0.0", + "category": "Point Of Sale", + "website": "www.akretion.com", + 'author': 'Akretion,Odoo Community Association (OCA)', + "license": "AGPL-3", + "application": False, + "installable": True, + "external_dependencies": { + "python": [], + "bin": [], + }, + "depends": [ + "base", + ], + "data": [ + 'view/pos_order_no_offline.xml', + ], + "demo": [ + ], + "qweb": [ + ] +} diff --git a/pos_order_no_offline/static/src/js/pos_order_no_offline.js b/pos_order_no_offline/static/src/js/pos_order_no_offline.js new file mode 100644 index 00000000..945846a3 --- /dev/null +++ b/pos_order_no_offline/static/src/js/pos_order_no_offline.js @@ -0,0 +1,49 @@ +openerp.pos_order_no_offline = function(instance, local) { + module = instance.point_of_sale; + var QWeb = instance.web.qweb; + var _t = instance.web._t; + var round_pr = instance.web.round_precision; + + /************************************************************************* + Extend Model PaymentScreenWidget: + */ + + module.PaymentScreenWidget = module.PaymentScreenWidget.extend({ + next_screen: 'products', // forbid to edit ticket with pdf + }) + + /************************************************************************* + Extend Model Pos: + */ + module.PosModel = module.PosModel.extend({ + + push_order: function(order) { + //this._super(); + if(order){ + var posOrderModel = new instance.web.Model('pos.order'); + return posOrderModel.call( + 'create_from_ui', + [[{'data': order.export_as_JSON(), 'to_invoice': false}]], + undefined, + { + shadow: false, //!options.to_invoice, + timeout: 30000, //timeout + }).then(function (response) { + console.log(response) + return response; + }).fail(function (error, event){ + if(error.code === 200 ){ // Business Logic Error, not a connection problem + /*self.pos_widget.screen_selector.show_popup('error-traceback',{ + message: error.data.message, + comment: error.data.debug + });*/ + } + // prevent an error popup creation by the rpc failure + // we want the failure to be silent as we send the orders in the background + event.preventDefault(); + console.error('Failed to send orders:', order); + }); + } + }, + }); +}; diff --git a/pos_order_no_offline/view/pos_order_no_offline.xml b/pos_order_no_offline/view/pos_order_no_offline.xml new file mode 100644 index 00000000..7fe53fe1 --- /dev/null +++ b/pos_order_no_offline/view/pos_order_no_offline.xml @@ -0,0 +1,13 @@ + + + + + + + +