Skip to content

Commit 293c8ce

Browse files
Merge PR #2 into 16.0
Signed-off-by legalsylvain
2 parents e1c6bb9 + ce92705 commit 293c8ce

24 files changed

+399
-0
lines changed

pos_odoo_driver_payment/README.rst

Whitespace-only changes.

pos_odoo_driver_payment/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import models
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Copyright (C) 2024 - Today: GRAP (http://www.grap.coop)
2+
# @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
3+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
4+
5+
{
6+
"name": "Point of Sale - Telium Payment Terminal (odoo-pos-driver)",
7+
"version": "16.0.1.0.0",
8+
"category": "Point Of Sale",
9+
"summary": "Communicate with Telium Payment Terminal"
10+
" via odoo-pos-driver library",
11+
"author": (
12+
"Aurélien DUMAINE,"
13+
"GRAP,"
14+
"Akretion,"
15+
"ACSONE SA/NV,"
16+
"Odoo Community Association (OCA)"
17+
),
18+
"website": "https://github.com/grap/odoo-addons-pos",
19+
"license": "AGPL-3",
20+
"depends": ["point_of_sale"],
21+
"assets": {
22+
"point_of_sale.assets": [
23+
"pos_odoo_driver_payment/static/src/css/pos.css",
24+
"pos_odoo_driver_payment/static/src/js/devices.esm.js",
25+
"pos_odoo_driver_payment/static/src/js/ProxyStatus.esm.js",
26+
"pos_odoo_driver_payment/static/src/js/PaymentScreen.esm.js",
27+
"pos_odoo_driver_payment/static/src/xml/PaymentScreenPaymentLines.xml",
28+
],
29+
},
30+
"data": [
31+
"views/view_res_config_settings.xml",
32+
"views/view_pos_payment_method.xml",
33+
],
34+
"installable": True,
35+
}

pos_odoo_driver_payment/i18n/fr.po

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
# Translation of Odoo Server.
2+
# This file contains the translation of the following modules:
3+
# * pos_odoo_driver_payment
4+
#
5+
msgid ""
6+
msgstr ""
7+
"Project-Id-Version: Odoo Server 16.0\n"
8+
"Report-Msgid-Bugs-To: \n"
9+
"POT-Creation-Date: 2024-09-10 22:50+0000\n"
10+
"PO-Revision-Date: 2024-09-10 22:50+0000\n"
11+
"Last-Translator: \n"
12+
"Language-Team: \n"
13+
"MIME-Version: 1.0\n"
14+
"Content-Type: text/plain; charset=UTF-8\n"
15+
"Content-Transfer-Encoding: \n"
16+
"Plural-Forms: \n"
17+
18+
#. module: pos_odoo_driver_payment
19+
#: model:ir.model.fields,help:pos_odoo_driver_payment.field_pos_config__iface_payment_terminal
20+
#: model:ir.model.fields,help:pos_odoo_driver_payment.field_res_config_settings__pos_iface_payment_terminal
21+
msgid "A payment terminal is available on the Proxy"
22+
msgstr "Un terminal de paiement est disponible via le proxy"
23+
24+
#. module: pos_odoo_driver_payment
25+
#. odoo-javascript
26+
#: code:addons/pos_odoo_driver_payment/static/src/js/PaymentScreen.esm.js:0
27+
#, python-format
28+
msgid "Communication failed"
29+
msgstr "Echec de la communication"
30+
31+
#. module: pos_odoo_driver_payment
32+
#: model:ir.model,name:pos_odoo_driver_payment.model_res_config_settings
33+
msgid "Config Settings"
34+
msgstr "Paramètres de configuration"
35+
36+
#. module: pos_odoo_driver_payment
37+
#. odoo-javascript
38+
#: code:addons/pos_odoo_driver_payment/static/src/js/ProxyStatus.esm.js:0
39+
#, python-format
40+
msgid "EPT"
41+
msgstr "TPE"
42+
43+
#. module: pos_odoo_driver_payment
44+
#. odoo-javascript
45+
#: code:addons/pos_odoo_driver_payment/static/src/js/ProxyStatus.esm.js:0
46+
#, python-format
47+
msgid "EPT Offline"
48+
msgstr "TPE hors ligne"
49+
50+
#. module: pos_odoo_driver_payment
51+
#: model:ir.model.fields,field_description:pos_odoo_driver_payment.field_pos_payment_method__is_payment_terminal
52+
msgid "Is Payment Terminal"
53+
msgstr "Est un terminal de paiement"
54+
55+
#. module: pos_odoo_driver_payment
56+
#: model:ir.model.fields,field_description:pos_odoo_driver_payment.field_pos_config__iface_payment_terminal
57+
#: model:ir.model.fields,field_description:pos_odoo_driver_payment.field_res_config_settings__pos_iface_payment_terminal
58+
#: model_terms:ir.ui.view,arch_db:pos_odoo_driver_payment.view_res_config_settings_form
59+
msgid "Payment Terminal"
60+
msgstr "Terminal de paiement"
61+
62+
#. module: pos_odoo_driver_payment
63+
#: model:ir.model,name:pos_odoo_driver_payment.model_pos_config
64+
msgid "Point of Sale Configuration"
65+
msgstr "Configuration du point de vente"
66+
67+
#. module: pos_odoo_driver_payment
68+
#: model:ir.model,name:pos_odoo_driver_payment.model_pos_payment_method
69+
msgid "Point of Sale Payment Methods"
70+
msgstr "Modes de paiement du point de vente"
71+
72+
#. module: pos_odoo_driver_payment
73+
#: model:ir.model,name:pos_odoo_driver_payment.model_pos_session
74+
msgid "Point of Sale Session"
75+
msgstr "Session du point de vente"
76+
77+
#. module: pos_odoo_driver_payment
78+
#. odoo-javascript
79+
#: code:addons/pos_odoo_driver_payment/static/src/js/PaymentScreen.esm.js:0
80+
#, python-format
81+
msgid ""
82+
"Possible reasons: \n"
83+
"- the terminal payment is not connected\n"
84+
"- the device is busy for the time being (still processing a payment)."
85+
msgstr ""
86+
"Raisons possibles: \n"
87+
"- Le terminal de paiement n'est pas connecté\n"
88+
"- Le périphérique est occupé pour le moment (déjà en train de traiter un paiement)"
89+
90+
#. module: pos_odoo_driver_payment
91+
#. odoo-javascript
92+
#: code:addons/pos_odoo_driver_payment/static/src/xml/PaymentScreenPaymentLines.xml:0
93+
#: code:addons/pos_odoo_driver_payment/static/src/xml/PaymentScreenPaymentLines.xml:0
94+
#, python-format
95+
msgid "Send to Payment Terminal"
96+
msgstr "Envoyer au terminal de paiement"
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
from . import pos_config
2+
from . import res_config_settings
3+
from . import pos_session
4+
from . import pos_payment_method
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Copyright (C) 2024 - Today: GRAP (http://www.grap.coop)
2+
# @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
3+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
4+
5+
from odoo import fields, models
6+
7+
8+
class PosConfig(models.Model):
9+
_inherit = "pos.config"
10+
11+
iface_payment_terminal = fields.Boolean(
12+
"Payment Terminal",
13+
help="A payment terminal is available on the Proxy",
14+
)
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Copyright (C) 2024 - Today: GRAP (http://www.grap.coop)
2+
# @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
3+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
4+
5+
from odoo import fields, models
6+
7+
8+
class PosPaymentMethod(models.Model):
9+
_inherit = "pos.payment.method"
10+
11+
is_payment_terminal = fields.Boolean()
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Copyright (C) 2024 - Today: GRAP (http://www.grap.coop)
2+
# @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
3+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
4+
5+
from odoo import models
6+
7+
8+
class PosSession(models.Model):
9+
_inherit = "pos.session"
10+
11+
def _get_pos_ui_pos_config(self, params):
12+
config = super()._get_pos_ui_pos_config(params)
13+
config["use_proxy"] = config["use_proxy"] or (
14+
config["is_posbox"] and config["iface_payment_terminal"]
15+
)
16+
return config
17+
18+
def _loader_params_pos_payment_method(self):
19+
res = super()._loader_params_pos_payment_method()
20+
res["search_params"]["fields"] += ["is_payment_terminal"]
21+
return res
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Copyright (C) 2024 - Today: GRAP (http://www.grap.coop)
2+
# @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
3+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
4+
5+
from odoo import fields, models
6+
7+
8+
class ResConfigSettings(models.TransientModel):
9+
_inherit = "res.config.settings"
10+
11+
pos_iface_payment_terminal = fields.Boolean(
12+
related="pos_config_id.iface_payment_terminal",
13+
readonly=False,
14+
)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
* go to the "Point of Sale > Configuration > Payment Method"
2+
3+
* Check the option *Is Payment Terminal*
4+
5+
.. figure:: ../static/img/pos_payment_method_form.png
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
This module is a full refactor of the OCA V16 module ``pos_terminal_payment``.
2+
Original authors and ideas are:
3+
4+
* Aurelien Dumaine
5+
* Alexis de Lattre <alexis.delattre@akretion.com>
6+
* Sylvain LE GAL (https://twitter.com/legalsylvain)
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
This module extends the Point of Sale odoo module, to add compatibility with the ``odoo-pos-driver``
2+
python library, when using Telium Payment Terminal.
3+
4+
More information: https://pypi.org/project/odoo-pos-driver/
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
* Open the Point of sale
2+
3+
* make an order, and select a payment that is marked as "Is Payment Terminal"
4+
5+
* Click on the button "Send to Payment Terminal"
6+
7+
.. figure:: ../static/img/pos_front_end.png
Loading
Loading
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
div.send-payment-terminal-button {
2+
font-size: x-large;
3+
padding: 8px;
4+
margin: 8px;
5+
border: 2px solid gray;
6+
border-radius: 10px;
7+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// Copyright (C) 2024 - Today: GRAP (http://www.grap.coop)
2+
// @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
3+
// License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
4+
5+
odoo.define("pos_odoo_driver_payment.PaymentScreen", function (require) {
6+
7+
const PaymentScreen = require("point_of_sale.PaymentScreen");
8+
const Registries = require("point_of_sale.Registries");
9+
const { useListener } = require("@web/core/utils/hooks");
10+
11+
const OverloadPaymentScreen = (OriginalPaymentScreen) =>
12+
class extends OriginalPaymentScreen {
13+
14+
setup() {
15+
super.setup();
16+
useListener('send-payment-terminal', this.SendPaymentTerminal);
17+
}
18+
19+
SendPaymentTerminal(event) {
20+
var self = this;
21+
const { cid } = event.detail;
22+
const payment_line = this.paymentLines.find((line) => line.cid === cid);
23+
this.env.proxy.payment_terminal_push_amount(payment_line)
24+
.then(function (result) {
25+
if (!result) {
26+
self.showPopup('ErrorTracebackPopup', {
27+
title: self.env._t('Communication failed'),
28+
body: self.env._t('Possible reasons: \n- the terminal payment is not connected\n- the device is busy for the time being (still processing a payment).'),
29+
});
30+
}
31+
32+
});
33+
}
34+
35+
};
36+
37+
Registries.Component.extend(PaymentScreen, OverloadPaymentScreen);
38+
return PaymentScreen;
39+
});
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// Copyright (C) 2024 - Today: GRAP (http://www.grap.coop)
2+
// @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
3+
// License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
4+
5+
odoo.define("pos_odoo_driver_payment.ProxyStatus", function (require) {
6+
var Registries = require("point_of_sale.Registries");
7+
var ProxyStatus = require("point_of_sale.ProxyStatus");
8+
9+
const OverloadProxyStatus = (OriginalProxyStatus) =>
10+
class extends OriginalProxyStatus {
11+
_setStatus(newStatus) {
12+
super._setStatus(newStatus);
13+
if (
14+
newStatus.status === "connected" &&
15+
this.env.pos.config.iface_payment_terminal
16+
) {
17+
var paymentStatus = newStatus.drivers.payment
18+
? newStatus.drivers.payment.status
19+
: false;
20+
if (
21+
paymentStatus !== "connected" &&
22+
paymentStatus !== "connecting"
23+
) {
24+
if (this.state.msg) {
25+
this.state.msg =
26+
this.env._t("EPT") + " & " + this.state.msg;
27+
} else {
28+
this.state.msg = this.env._t("EPT Offline");
29+
this.state.status = "warning";
30+
}
31+
}
32+
}
33+
}
34+
};
35+
36+
Registries.Component.extend(ProxyStatus, OverloadProxyStatus);
37+
});
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Copyright (C) 2024 - Today: GRAP (http://www.grap.coop)
2+
// @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
3+
// License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
4+
5+
odoo.define("pos_odoo_driver_payment.devices", function (require) {
6+
7+
var ProxyDevice = require("point_of_sale.devices").ProxyDevice;
8+
9+
ProxyDevice.include({
10+
11+
payment_terminal_push_amount: function (payment_line) {
12+
var data = {
13+
amount: payment_line.amount,
14+
currency_iso: this.pos.currency.name,
15+
};
16+
return this.message(
17+
"payment_terminal_transaction_start",
18+
{payment_info: JSON.stringify(data)}
19+
)
20+
},
21+
22+
});
23+
});
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<templates id="template" xml:space="preserve">
3+
4+
<t t-name="pos_odoo_driver_payment.PaymentScreenPaymentLines"
5+
t-inherit="point_of_sale.PaymentScreenPaymentLines"
6+
t-inherit-mode="extension" owl="1">
7+
<xpath expr="//div[hasclass('payment-name')]" position="after">
8+
<t t-if="line.payment_method.is_payment_terminal">
9+
<div class="send-payment-terminal-button"
10+
t-on-click="() => this.trigger('send-payment-terminal', { cid: line.cid })"
11+
aria-label="Send to Payment Terminal"
12+
title="Send to Payment Terminal">
13+
<i class="fa fa-credit-card" />
14+
<i class="fa fa-share-square" />
15+
</div>
16+
</t>
17+
</xpath>
18+
</t>
19+
20+
</templates>
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" ?>
2+
<!--
3+
Copyright (C) 2024 - Today: GRAP (http://www.grap.coop)
4+
@author: Sylvain LE GAL (https://twitter.com/legalsylvain)
5+
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
6+
-->
7+
<odoo>
8+
9+
<record id="view_pos_payment_method_form" model="ir.ui.view">
10+
<field name="model">pos.payment.method</field>
11+
<field name="inherit_id" ref="point_of_sale.pos_payment_method_view_form" />
12+
<field name="arch" type="xml">
13+
<field name="journal_id" position="after">
14+
<field name="is_payment_terminal"/>
15+
</field>
16+
</field>
17+
</record>
18+
19+
</odoo>

0 commit comments

Comments
 (0)