summaryrefslogtreecommitdiff
path: root/addons
diff options
context:
space:
mode:
authorAntoine Prieels <anp@odoo.com>2020-09-23 11:58:12 +0000
committerAntoine Prieels <anp@odoo.com>2020-09-23 14:02:54 +0000
commitcb16eccbf18ed80fe0d6284fc272148e89c9d0f0 (patch)
tree0093c61a0e31bc4511ab7b960da24b5ad5c1a8de /addons
parent32f8e15466e3911ae9083d0c9c07a42283a12d13 (diff)
[FIX] pos_six: Prepare for the certification
- The balance operation is performed automatically at the end of the day but it doesn't print any receipt. We add the possibility to perform the balance manually to get a receipt showing all the transactions of the day. - By default, DCC is set to true, but it requires a different implementation. As we don't support it, Six asked us to changed the variable to False, to make it clearer in case of debugging. closes odoo/odoo#58355 X-original-commit: bc5ea7e3d3b694bbe88b14c10cd5cc80ca617e48 Signed-off-by: pimodoo <pimodoo@users.noreply.github.com> Signed-off-by: Antoine Prieƫls <aprieels@users.noreply.github.com>
Diffstat (limited to 'addons')
-rw-r--r--addons/pos_six/__manifest__.py4
-rw-r--r--addons/pos_six/static/src/js/BalanceButton.js21
-rw-r--r--addons/pos_six/static/src/js/Chrome.js17
-rw-r--r--addons/pos_six/static/src/js/payment_six.js17
-rw-r--r--addons/pos_six/static/src/xml/BalanceButton.xml12
-rw-r--r--addons/pos_six/static/src/xml/Chrome.xml10
-rw-r--r--addons/pos_six/views/point_of_sale_assets.xml2
7 files changed, 83 insertions, 0 deletions
diff --git a/addons/pos_six/__manifest__.py b/addons/pos_six/__manifest__.py
index d59c415b353..580f37fc1d9 100644
--- a/addons/pos_six/__manifest__.py
+++ b/addons/pos_six/__manifest__.py
@@ -11,6 +11,10 @@
'views/pos_payment_method_views.xml',
'views/point_of_sale_assets.xml',
],
+ 'qweb': [
+ 'static/src/xml/BalanceButton.xml',
+ 'static/src/xml/Chrome.xml',
+ ],
'depends': ['point_of_sale'],
'installable': True,
'license': 'OEEL-1',
diff --git a/addons/pos_six/static/src/js/BalanceButton.js b/addons/pos_six/static/src/js/BalanceButton.js
new file mode 100644
index 00000000000..a792aa3333d
--- /dev/null
+++ b/addons/pos_six/static/src/js/BalanceButton.js
@@ -0,0 +1,21 @@
+odoo.define('pos_six.BalanceButton', function(require) {
+ 'use strict';
+
+ const PosComponent = require('point_of_sale.PosComponent');
+ const Registries = require('point_of_sale.Registries');
+
+ class BalanceButton extends PosComponent {
+ sendBalance() {
+ this.env.pos.payment_methods.map(pm => {
+ if (pm.use_payment_terminal === 'six') {
+ pm.payment_terminal.send_balance();
+ }
+ });
+ }
+ }
+ BalanceButton.template = 'BalanceButton';
+
+ Registries.Component.add(BalanceButton);
+
+ return BalanceButton;
+});
diff --git a/addons/pos_six/static/src/js/Chrome.js b/addons/pos_six/static/src/js/Chrome.js
new file mode 100644
index 00000000000..0df6c4e1dc7
--- /dev/null
+++ b/addons/pos_six/static/src/js/Chrome.js
@@ -0,0 +1,17 @@
+odoo.define('pos_six.chrome', function (require) {
+ 'use strict';
+
+ const Chrome = require('point_of_sale.Chrome');
+ const Registries = require('point_of_sale.Registries');
+
+ const PosSixChrome = (Chrome) =>
+ class extends Chrome {
+ get balanceButtonIsShown() {
+ return this.env.pos.payment_methods.some(pm => pm.use_payment_terminal === 'six');
+ }
+ };
+
+ Registries.Component.extend(Chrome, PosSixChrome);
+
+ return Chrome;
+});
diff --git a/addons/pos_six/static/src/js/payment_six.js b/addons/pos_six/static/src/js/payment_six.js
index bc4633d1fd1..2eeb9b7dbe5 100644
--- a/addons/pos_six/static/src/js/payment_six.js
+++ b/addons/pos_six/static/src/js/payment_six.js
@@ -33,6 +33,7 @@ var PaymentSix = PaymentInterface.extend({
settings.connectionIPString = this.payment_method.six_terminal_ip;
settings.connectionIPPort = "80";
settings.integratorId = "175d97a0-2a88-4413-b920-e90037b582ac";
+ settings.dcc = false;
this.terminal = new timapi.Terminal(settings);
this.terminal.setPosId(this.pos.pos_session.name);
@@ -40,6 +41,7 @@ var PaymentSix = PaymentInterface.extend({
this.terminalListener = new timapi.DefaultTerminalListener();
this.terminalListener.transactionCompleted = this._onTransactionComplete.bind(this);
+ this.terminalListener.balanceCompleted = this._onBalanceComplete.bind(this);
this.terminal.addListener(this.terminalListener);
var recipients = [timapi.constants.Recipient.merchant, timapi.constants.Recipient.cardholder];
@@ -83,6 +85,10 @@ var PaymentSix = PaymentInterface.extend({
return this._sendTransaction(timapi.constants.TransactionType.reversal);
},
+ send_balance: function () {
+ this.terminal.balanceAsync();
+ },
+
//--------------------------------------------------------------------------
// Private
//--------------------------------------------------------------------------
@@ -113,6 +119,17 @@ var PaymentSix = PaymentInterface.extend({
}
},
+ _onBalanceComplete: function (event, data) {
+ if (event.exception) {
+ Gui.showPopup('ErrorPopup',{
+ 'title': _t('Balance Failed'),
+ 'body': _t('The balance operation failed.'),
+ });
+ } else {
+ this._printReceipts(data.printData.receipts);
+ }
+ },
+
_printReceipts: function (receipts) {
_.forEach(receipts, (receipt) => {
var value = receipt.value.replace(/\n/g, "<br />");
diff --git a/addons/pos_six/static/src/xml/BalanceButton.xml b/addons/pos_six/static/src/xml/BalanceButton.xml
new file mode 100644
index 00000000000..e68d7ae397a
--- /dev/null
+++ b/addons/pos_six/static/src/xml/BalanceButton.xml
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<templates id="template" xml:space="preserve">
+
+ <t t-name="BalanceButton" owl="1">
+ <div class="header-button balance-button" t-on-click="sendBalance">
+ <span class="lock-button">
+ Send Balance
+ </span>
+ </div>
+ </t>
+
+</templates>
diff --git a/addons/pos_six/static/src/xml/Chrome.xml b/addons/pos_six/static/src/xml/Chrome.xml
new file mode 100644
index 00000000000..1187e4f5a44
--- /dev/null
+++ b/addons/pos_six/static/src/xml/Chrome.xml
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<templates id="template" xml:space="preserve">
+
+ <t t-name="Chrome" t-inherit="point_of_sale.Chrome" t-inherit-mode="extension" owl="1">
+ <xpath expr="//SyncNotification" position="after">
+ <BalanceButton t-if="balanceButtonIsShown" />
+ </xpath>
+ </t>
+
+</templates>
diff --git a/addons/pos_six/views/point_of_sale_assets.xml b/addons/pos_six/views/point_of_sale_assets.xml
index 7bb3693a356..dbca83d95d5 100644
--- a/addons/pos_six/views/point_of_sale_assets.xml
+++ b/addons/pos_six/views/point_of_sale_assets.xml
@@ -3,6 +3,8 @@
<template id="assets" inherit_id="point_of_sale.assets">
<xpath expr="." position="inside">
<script type="text/javascript" src="/pos_six/static/lib/six_timapi/timapi.js"></script>
+ <script type="text/javascript" src="/pos_six/static/src/js/BalanceButton.js"></script> -->
+ <script type="text/javascript" src="/pos_six/static/src/js/Chrome.js"></script>
<script type="text/javascript" src="/pos_six/static/src/js/models.js"></script>
<script type="text/javascript" src="/pos_six/static/src/js/payment_six.js"></script>
</xpath>