summaryrefslogtreecommitdiff
path: root/addons/point_of_sale/static/src/js/utils.js
diff options
context:
space:
mode:
authorJoseph Caburnay <jcb@odoo.com>2020-06-15 09:59:37 +0000
committerJoseph Caburnay <jcb@odoo.com>2020-07-17 10:00:04 +0000
commitb2f8170d88239b5eaf04f1e3c0dcef613b78fedc (patch)
treeae1a178dab9afd382cd9e45e8db5b28d6a6424e5 /addons/point_of_sale/static/src/js/utils.js
parent39ff9d95c2c2b09e7d6ec47051ca0bb3c9f6165a (diff)
[IMP] point_of_sale,pos_*: allow users to manage orders in the pos frontend
We now allow invoicing of finalized orders in an open session in this first iteration of order management in the pos frontend. Additionally, receipt reprinting is also introduced. With this feature, we can now reprint the receipt of old orders. closes odoo/odoo#51141 Task-id: 1981354 Related: odoo/enterprise#11690 Related: odoo/upgrade#1472 Signed-off-by: pimodoo <pimodoo@users.noreply.github.com>
Diffstat (limited to 'addons/point_of_sale/static/src/js/utils.js')
-rw-r--r--addons/point_of_sale/static/src/js/utils.js32
1 files changed, 29 insertions, 3 deletions
diff --git a/addons/point_of_sale/static/src/js/utils.js b/addons/point_of_sale/static/src/js/utils.js
index ae698ab60d3..26442ef776b 100644
--- a/addons/point_of_sale/static/src/js/utils.js
+++ b/addons/point_of_sale/static/src/js/utils.js
@@ -1,4 +1,4 @@
-odoo.define('point_of_sale.utils', function(require) {
+odoo.define('point_of_sale.utils', function (require) {
'use strict';
function getFileAsText(file) {
@@ -7,7 +7,7 @@ odoo.define('point_of_sale.utils', function(require) {
reject();
} else {
const reader = new FileReader();
- reader.addEventListener('load', function() {
+ reader.addEventListener('load', function () {
resolve(reader.result);
});
reader.addEventListener('abort', reject);
@@ -17,5 +17,31 @@ odoo.define('point_of_sale.utils', function(require) {
});
}
- return { getFileAsText };
+ /**
+ * This global variable is used by nextFrame to store the timer and
+ * be able to cancel it before another request for animation frame.
+ */
+ let timer = null;
+
+ /**
+ * Wait for the next animation frame to finish.
+ */
+ const nextFrame = () => {
+ return new Promise((resolve) => {
+ cancelAnimationFrame(timer);
+ timer = requestAnimationFrame(() => {
+ resolve();
+ });
+ });
+ };
+
+ function isRpcError(error) {
+ return (
+ !(error instanceof Error) &&
+ error.message &&
+ [100, 200, 404, -32098].includes(error.message.code)
+ );
+ }
+
+ return { getFileAsText, nextFrame, isRpcError };
});