diff --git a/pos_save_client_error_fix/README.rst b/pos_save_client_error_fix/README.rst new file mode 100644 index 0000000000..7e322adf7b --- /dev/null +++ b/pos_save_client_error_fix/README.rst @@ -0,0 +1,58 @@ +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 + +============== +POS Save Client Error Message FIX +============== + +This module extends the functionality of POS and displays the error message returned by the server rather than "Your Internet connection is probably down.". + + +Installation +============ + +This module depends on the point_of_sale Odoo official module. + + +Configuration +============= + +No configuration is needed. + + +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. + +Credits +======= + +Images +------ + +* Odoo Community Association: `Icon `_. + +Contributors +------------ + +* Jose Zambudio Bernabeu + +Maintainer +---------- + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://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 https://odoo-community.org. diff --git a/pos_save_client_error_fix/__init__.py b/pos_save_client_error_fix/__init__.py new file mode 100644 index 0000000000..4c885b481e --- /dev/null +++ b/pos_save_client_error_fix/__init__.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- +# © 2016 Diagram Software S.L. +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html diff --git a/pos_save_client_error_fix/__openerp__.py b/pos_save_client_error_fix/__openerp__.py new file mode 100644 index 0000000000..faf337b0b9 --- /dev/null +++ b/pos_save_client_error_fix/__openerp__.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +# © 2016 Diagram Software S.L. +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html + +{ + "name": "POS save client error FIX", + "summary": "Displays the error message returned by the server.", + "version": "8.0.1.0.0", + "category": "Point Of Sale", + "author": "Diagram Software S.L., " + "Odoo Community Association (OCA)", + "license": "AGPL-3", + "application": False, + "installable": True, + "depends": [ + "point_of_sale", + ], + "data": [ + "views/assets.xml", + ], +} diff --git a/pos_save_client_error_fix/static/description/icon.png b/pos_save_client_error_fix/static/description/icon.png new file mode 100644 index 0000000000..3a0328b516 Binary files /dev/null and b/pos_save_client_error_fix/static/description/icon.png differ diff --git a/pos_save_client_error_fix/static/src/js/pos_save_client_error_fix.js b/pos_save_client_error_fix/static/src/js/pos_save_client_error_fix.js new file mode 100644 index 0000000000..496d17187b --- /dev/null +++ b/pos_save_client_error_fix/static/src/js/pos_save_client_error_fix.js @@ -0,0 +1,46 @@ +/* © 2016 Diagram Software S.L. + * License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). */ + +(function ($) { + "use strict"; + openerp.pos_save_client_error_fix = function (instance, module) { + var _t = instance.web._t; + var pos = instance.point_of_sale; + + pos.ClientListScreenWidget = pos.ClientListScreenWidget.extend({ + save_client_details: function(partner) { + var self = this; + + var fields = {}; + this.$('.client-details-contents .detail').each(function(idx,el){ + fields[el.name] = el.value; + }); + + if (!fields.name) { + this.pos_widget.screen_selector.show_popup('error',{ + message: _t('A Customer Name Is Required'), + }); + return; + } + + if (this.uploaded_picture) { + fields.image = this.uploaded_picture; + } + + fields.id = partner.id || false; + fields.country_id = fields.country_id || false; + fields.ean13 = fields.ean13 ? this.pos.barcode_reader.sanitize_ean(fields.ean13) : false; + + new instance.web.Model('res.partner').call('create_from_ui',[fields]).then(function(partner_id){ + self.saved_client_details(partner_id); + },function(err,event){ + event.preventDefault(); + self.pos_widget.screen_selector.show_popup('error',{ + 'message': _t('Error: Could not Save Changes'), + 'comment': err.data["arguments"][1], + }); + }); + }, + }); + }; +})(jQuery); diff --git a/pos_save_client_error_fix/views/assets.xml b/pos_save_client_error_fix/views/assets.xml new file mode 100644 index 0000000000..b2a7eac685 --- /dev/null +++ b/pos_save_client_error_fix/views/assets.xml @@ -0,0 +1,11 @@ + + + + + + +