Skip to content

Commit

Permalink
[ADD] New module: pos_save_client_error_fix
Browse files Browse the repository at this point in the history
The PoS displays a generic error message when an error occurs while
creating users.

This module improves the error handling providing a useful message
to the end user.
  • Loading branch information
Zambu committed Oct 25, 2016
1 parent 1364c9f commit 3a446bc
Show file tree
Hide file tree
Showing 6 changed files with 139 additions and 0 deletions.
58 changes: 58 additions & 0 deletions 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
<https://github.com/OCA/{project_repo}/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 <https://github.com/OCA/maintainer-tools/blob/master/template/module/static/description/icon.svg>`_.

Contributors
------------

* Jose Zambudio Bernabeu <jose.zambudio@diagram.es>

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.
3 changes: 3 additions & 0 deletions 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
21 changes: 21 additions & 0 deletions 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",
],
}
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -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);
11 changes: 11 additions & 0 deletions pos_save_client_error_fix/views/assets.xml
@@ -0,0 +1,11 @@
<openerp>
<data>

<template id="pos_save_client_error_fix_assets" name="pos_save_client_error_fix assets" inherit_id="web.assets_backend">
<xpath expr="." position="inside">
<script type="text/javascript" src="/pos_save_client_error_fix/static/src/js/pos_save_client_error_fix.js"></script>
</xpath>
</template>

</data>
</openerp>

0 comments on commit 3a446bc

Please sign in to comment.