-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d532352
commit 7e22721
Showing
22 changed files
with
245 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Copyright (C) 2024 - Today: GRAP (http://www.grap.coop) | ||
# @author: Sylvain LE GAL (https://twitter.com/legalsylvain) | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
{ | ||
"name": "Point of Sale - Devices List (odoo-pos-driver)", | ||
"version": "16.0.1.0.0", | ||
"category": "Point Of Sale", | ||
"summary": "Get devices information from odoo-pos-driver library", | ||
"author": "GRAP", | ||
"website": "https://github.com/grap/odoo-addons-pos", | ||
"license": "AGPL-3", | ||
"depends": ["point_of_sale"], | ||
"assets": { | ||
"point_of_sale.assets": [ | ||
# "pos_odoo_driver_payment/static/src/css/pos.css", | ||
# "pos_odoo_driver_payment/static/src/js/devices.esm.js", | ||
# "pos_odoo_driver_payment/static/src/js/ProxyStatus.esm.js", | ||
# "pos_odoo_driver_payment/static/src/js/PaymentScreen.esm.js", | ||
# "pos_odoo_driver_payment/static/src/xml/PaymentScreenPaymentLines.xml", | ||
], | ||
}, | ||
"data": ["views/view_pos_device.xml"], | ||
"installable": True, | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from . import pos_config | ||
from . import pos_device |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Copyright (C) 2024 - Today: GRAP (http://www.grap.coop) | ||
# @author: Sylvain LE GAL (https://twitter.com/legalsylvain) | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
from odoo import fields, models | ||
|
||
|
||
class PosConfig(models.Model): | ||
_inherit = "pos.config" | ||
|
||
device_ids = fields.One2many(comodel_name="pos.device", inverse_name="config_id") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Copyright (C) 2024 - Today: GRAP (http://www.grap.coop) | ||
# @author: Sylvain LE GAL (https://twitter.com/legalsylvain) | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
from odoo import fields, models | ||
|
||
|
||
class PosDevice(models.Model): | ||
_name = "pos.device" | ||
|
||
config_id = fields.Many2one(comodel_name="pos.config") | ||
|
||
company_id = fields.Many2one( | ||
commodel_name="res.company", default=lambda x: x._default_company_id() | ||
) | ||
|
||
name = fields.Char(readonly=True) | ||
|
||
product_name = fields.Char(readonly=True) | ||
|
||
vendor_product_code = fields.Char(readonly=True) | ||
|
||
serial_number = fields.Char(readonly=True) | ||
|
||
manufacturer = fields.Char(readonly=True) | ||
|
||
last_connexion_date = fields.Datetime(readonly=True) | ||
|
||
def _default_company_id(self): | ||
return self.env.company | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* Sylvain LE GAL (https://twitter.com/legalsylvain) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
This module extends the Point of Sale odoo module, to add compatibility with the ``odoo-pos-driver`` | ||
python library. | ||
|
||
It will store connected devices information in Odoo for analysis. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
* Open the Point of sale, with usb devices connected. | ||
|
||
* Close the point of sale. | ||
|
||
* Go to " / Devices". | ||
|
||
you can see the devices information, with last usage date. | ||
|
||
.. figure:: ../static/img/pos_device_tree.png |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+9.92 KB
pos_odoo_driver_device_list/static/description/pos_payment_method_form.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
div.send-payment-terminal-button { | ||
font-size: x-large; | ||
padding: 8px; | ||
margin: 8px; | ||
border: 2px solid gray; | ||
border-radius: 10px; | ||
} |
39 changes: 39 additions & 0 deletions
39
pos_odoo_driver_device_list/static/src/js/PaymentScreen.esm.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// Copyright (C) 2024 - Today: GRAP (http://www.grap.coop) | ||
// @author: Sylvain LE GAL (https://twitter.com/legalsylvain) | ||
// License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
odoo.define("pos_odoo_driver_payment.PaymentScreen", function (require) { | ||
|
||
const PaymentScreen = require("point_of_sale.PaymentScreen"); | ||
const Registries = require("point_of_sale.Registries"); | ||
const { useListener } = require("@web/core/utils/hooks"); | ||
|
||
const OverloadPaymentScreen = (OriginalPaymentScreen) => | ||
class extends OriginalPaymentScreen { | ||
|
||
setup() { | ||
super.setup(); | ||
useListener('send-payment-terminal', this.SendPaymentTerminal); | ||
} | ||
|
||
SendPaymentTerminal(event) { | ||
var self = this; | ||
const { cid } = event.detail; | ||
const payment_line = this.paymentLines.find((line) => line.cid === cid); | ||
this.env.proxy.payment_terminal_push_amount(payment_line) | ||
.then(function (result) { | ||
if (!result) { | ||
self.showPopup('ErrorTracebackPopup', { | ||
title: self.env._t('Communication failed'), | ||
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).'), | ||
}); | ||
} | ||
|
||
}); | ||
} | ||
|
||
}; | ||
|
||
Registries.Component.extend(PaymentScreen, OverloadPaymentScreen); | ||
return PaymentScreen; | ||
}); |
37 changes: 37 additions & 0 deletions
37
pos_odoo_driver_device_list/static/src/js/ProxyStatus.esm.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// Copyright (C) 2024 - Today: GRAP (http://www.grap.coop) | ||
// @author: Sylvain LE GAL (https://twitter.com/legalsylvain) | ||
// License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
odoo.define("pos_odoo_driver_payment.ProxyStatus", function (require) { | ||
var Registries = require("point_of_sale.Registries"); | ||
var ProxyStatus = require("point_of_sale.ProxyStatus"); | ||
|
||
const OverloadProxyStatus = (OriginalProxyStatus) => | ||
class extends OriginalProxyStatus { | ||
_setStatus(newStatus) { | ||
super._setStatus(newStatus); | ||
if ( | ||
newStatus.status === "connected" && | ||
this.env.pos.config.iface_payment_terminal | ||
) { | ||
var paymentStatus = newStatus.drivers.payment | ||
? newStatus.drivers.payment.status | ||
: false; | ||
if ( | ||
paymentStatus !== "connected" && | ||
paymentStatus !== "connecting" | ||
) { | ||
if (this.state.msg) { | ||
this.state.msg = | ||
this.env._t("EPT") + " & " + this.state.msg; | ||
} else { | ||
this.state.msg = this.env._t("EPT Offline"); | ||
this.state.status = "warning"; | ||
} | ||
} | ||
} | ||
} | ||
}; | ||
|
||
Registries.Component.extend(ProxyStatus, OverloadProxyStatus); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// Copyright (C) 2024 - Today: GRAP (http://www.grap.coop) | ||
// @author: Sylvain LE GAL (https://twitter.com/legalsylvain) | ||
// License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
odoo.define("pos_odoo_driver_payment.devices", function (require) { | ||
|
||
var ProxyDevice = require("point_of_sale.devices").ProxyDevice; | ||
|
||
ProxyDevice.include({ | ||
|
||
payment_terminal_push_amount: function (payment_line) { | ||
var data = { | ||
amount: payment_line.amount, | ||
currency_iso: this.pos.currency.name, | ||
}; | ||
return this.message( | ||
"payment_terminal_transaction_start", | ||
{payment_info: JSON.stringify(data)} | ||
) | ||
}, | ||
|
||
}); | ||
}); |
20 changes: 20 additions & 0 deletions
20
pos_odoo_driver_device_list/static/src/xml/PaymentScreenPaymentLines.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<templates id="template" xml:space="preserve"> | ||
|
||
<t t-name="pos_odoo_driver_payment.PaymentScreenPaymentLines" | ||
t-inherit="point_of_sale.PaymentScreenPaymentLines" | ||
t-inherit-mode="extension" owl="1"> | ||
<xpath expr="//div[hasclass('payment-name')]" position="after"> | ||
<t t-if="line.payment_method.name == 'Bank'"> | ||
<div class="send-payment-terminal-button" | ||
t-on-click="() => this.trigger('send-payment-terminal', { cid: line.cid })" | ||
aria-label="Send to Payment Terminal" | ||
title="Send to Payment Terminal"> | ||
<i class="fa fa-credit-card" /> | ||
<i class="fa fa-share-square" /> | ||
</div> | ||
</t> | ||
</xpath> | ||
</t> | ||
|
||
</templates> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?xml version="1.0" ?> | ||
<!-- | ||
Copyright (C) 2024 - Today: GRAP (http://www.grap.coop) | ||
@author: Sylvain LE GAL (https://twitter.com/legalsylvain) | ||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
--> | ||
<odoo> | ||
|
||
<record id="view_pos_device_tree" model="ir.ui.view"> | ||
<field name="model">pos.device</field> | ||
<field name="arch" type="xml"> | ||
<tree> | ||
<field name="name"/> | ||
<field name="vendor_product_code"/> | ||
<field name="product_name"/> | ||
<field name="serial_number"/> | ||
<field name="manufacturer"/> | ||
<field name="last_connexion_date"/> | ||
<field name="config_id"/> | ||
<field name="company_id"/> | ||
</tree> | ||
</field> | ||
</record> | ||
|
||
</odoo> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# addons listed in this file are ignored by | ||
# setuptools-odoo-make-default (one addon per line) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
To learn more about this directory, please visit | ||
https://pypi.python.org/pypi/setuptools-odoo |
1 change: 1 addition & 0 deletions
1
setup/pos_odoo_driver_device_list/odoo/addons/pos_odoo_driver_device_list
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../../../pos_odoo_driver_device_list |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import setuptools | ||
|
||
setuptools.setup( | ||
setup_requires=['setuptools-odoo'], | ||
odoo_addon=True, | ||
) |