Browse Source

[MIG][12.0] pos_payment_terminal

pull/440/head
Sylvain LE GAL 5 years ago
parent
commit
1f10eb54fd
  1. 7
      pos_payment_terminal/__manifest__.py
  2. 8
      pos_payment_terminal/demo/pos_config.xml
  3. 8
      pos_payment_terminal/demo/pos_payment_terminal_demo.xml
  4. 45
      pos_payment_terminal/i18n/fr.po
  5. 32
      pos_payment_terminal/i18n/pos_payment_terminal.pot
  6. 1
      pos_payment_terminal/models/account_journal.py
  7. 3
      pos_payment_terminal/models/pos_order.py
  8. 13
      pos_payment_terminal/readme/CONFIGURE.rst
  9. 1
      pos_payment_terminal/readme/CONTRIBUTORS.rst
  10. BIN
      pos_payment_terminal/static/description/account_journal_form.png
  11. BIN
      pos_payment_terminal/static/description/pos_config.png
  12. 49
      pos_payment_terminal/static/src/js/devices.js
  13. 30
      pos_payment_terminal/static/src/js/models.js
  14. 42
      pos_payment_terminal/static/src/js/screens.js
  15. 11
      pos_payment_terminal/views/account_journal.xml
  16. 13
      pos_payment_terminal/views/assets.xml
  17. 13
      pos_payment_terminal/views/pos_config.xml
  18. 11
      pos_payment_terminal/views/pos_payment_terminal_template.xml

7
pos_payment_terminal/__manifest__.py

@ -7,15 +7,16 @@
'version': '12.0.0.1.1',
'category': 'Point Of Sale',
'summary': 'Manage Payment Terminal device from POS front end',
'author': "Aurélien DUMAINE,Akretion,Odoo Community Association (OCA)",
'author': "Aurélien DUMAINE,GRAP,Akretion,"
"Odoo Community Association (OCA)",
'license': 'AGPL-3',
'depends': ['point_of_sale'],
'data': [
'views/pos_config.xml',
'views/account_journal.xml',
'views/pos_payment_terminal_template.xml',
'views/assets.xml',
],
'demo': ['demo/pos_payment_terminal_demo.xml'],
'demo': ['demo/pos_config.xml'],
'qweb': ['static/src/xml/pos_payment_terminal.xml'],
'installable': True,
}

8
pos_payment_terminal/demo/pos_config.xml

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="point_of_sale.pos_config_main" model="pos.config">
<field name="iface_payment_terminal" eval="True"/>
</record>
</odoo>

8
pos_payment_terminal/demo/pos_payment_terminal_demo.xml

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo noupdate="1">
<record id="point_of_sale.pos_config_main" model="pos.config">
<field name="iface_payment_terminal" eval="True"/>
</record>
</odoo>

45
pos_payment_terminal/i18n/fr.po

@ -1,23 +1,24 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * pos_payment_terminal
# * pos_payment_terminal
#
# Translators:
# OCA Transbot <transbot@odoo-community.org>, 2017
# leemannd <denis.leemann@camptocamp.com>, 2017
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 10.0\n"
"Project-Id-Version: Odoo Server 12.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-03-01 02:01+0000\n"
"PO-Revision-Date: 2018-03-01 02:01+0000\n"
"Last-Translator: leemannd <denis.leemann@camptocamp.com>, 2017\n"
"Language-Team: French (https://www.transifex.com/oca/teams/23907/fr/)\n"
"Language: fr\n"
"POT-Creation-Date: 2020-01-18 10:52+0000\n"
"PO-Revision-Date: 2020-01-18 10:52+0000\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
"Plural-Forms: \n"
#. module: pos_payment_terminal
#: model:ir.model.fields,help:pos_payment_terminal.field_pos_config__iface_payment_terminal
msgid "A payment terminal is available on the Proxy"
msgstr "Un terminal de paiment est disponible sur le proxy"
#. module: pos_payment_terminal
#: selection:account.journal,payment_mode:0
@ -35,17 +36,28 @@ msgid "Journal"
msgstr "Journal"
#. module: pos_payment_terminal
#: model:ir.model.fields,field_description:pos_payment_terminal.field_account_journal_payment_mode
#: model:ir.model.fields,field_description:pos_payment_terminal.field_account_journal__payment_mode
msgid "Payment Mode"
msgstr "Moyen de paiement"
#. module: pos_payment_terminal
#: model:ir.model.fields,field_description:pos_payment_terminal.field_pos_config__iface_payment_terminal
#: model_terms:ir.ui.view,arch_db:pos_payment_terminal.view_pos_config_form
msgid "Payment Terminal"
msgstr "Terminal de paiement"
#. module: pos_payment_terminal
#: model:ir.model,name:pos_payment_terminal.model_pos_config
msgid "Point of Sale Configuration"
msgstr "Paramétrage du point de vente"
#. module: pos_payment_terminal
#: model:ir.model,name:pos_payment_terminal.model_pos_order
msgid "Point of Sale Orders"
msgstr ""
msgstr "Commandes du point de vente"
#. module: pos_payment_terminal
#: model:ir.model.fields,help:pos_payment_terminal.field_account_journal_payment_mode
#: model:ir.model.fields,help:pos_payment_terminal.field_account_journal__payment_mode
msgid "Select the payment mode sent to the payment terminal"
msgstr "Sélectionner le mode de paiement envoyé au terminal de paiement"
@ -55,8 +67,3 @@ msgstr "Sélectionner le mode de paiement envoyé au terminal de paiement"
#, python-format
msgid "Start transaction"
msgstr "Démarrer la transaction"
#. module: pos_payment_terminal
#: model:ir.model,name:pos_payment_terminal.model_pos_config
msgid "pos.config"
msgstr "pos.config"

32
pos_payment_terminal/i18n/pos_payment_terminal.pot

@ -1,11 +1,13 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * pos_payment_terminal
# * pos_payment_terminal
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 10.0\n"
"Project-Id-Version: Odoo Server 12.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-01-18 10:55+0000\n"
"PO-Revision-Date: 2020-01-18 10:55+0000\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
@ -13,6 +15,11 @@ msgstr ""
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: pos_payment_terminal
#: model:ir.model.fields,help:pos_payment_terminal.field_pos_config__iface_payment_terminal
msgid "A payment terminal is available on the Proxy"
msgstr ""
#. module: pos_payment_terminal
#: selection:account.journal,payment_mode:0
msgid "Card"
@ -29,17 +36,28 @@ msgid "Journal"
msgstr ""
#. module: pos_payment_terminal
#: model:ir.model.fields,field_description:pos_payment_terminal.field_account_journal_payment_mode
#: model:ir.model.fields,field_description:pos_payment_terminal.field_account_journal__payment_mode
msgid "Payment Mode"
msgstr ""
#. module: pos_payment_terminal
#: model:ir.model.fields,field_description:pos_payment_terminal.field_pos_config__iface_payment_terminal
#: model_terms:ir.ui.view,arch_db:pos_payment_terminal.view_pos_config_form
msgid "Payment Terminal"
msgstr ""
#. module: pos_payment_terminal
#: model:ir.model,name:pos_payment_terminal.model_pos_config
msgid "Point of Sale Configuration"
msgstr ""
#. module: pos_payment_terminal
#: model:ir.model,name:pos_payment_terminal.model_pos_order
msgid "Point of Sale Orders"
msgstr ""
#. module: pos_payment_terminal
#: model:ir.model.fields,help:pos_payment_terminal.field_account_journal_payment_mode
#: model:ir.model.fields,help:pos_payment_terminal.field_account_journal__payment_mode
msgid "Select the payment mode sent to the payment terminal"
msgstr ""
@ -49,9 +67,3 @@ msgstr ""
#, python-format
msgid "Start transaction"
msgstr ""
#. module: pos_payment_terminal
#: model:ir.model,name:pos_payment_terminal.model_pos_config
msgid "pos.config"
msgstr ""

1
pos_payment_terminal/models/account_journal.py

@ -2,7 +2,6 @@
# © 2015-2016 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import models, fields

3
pos_payment_terminal/models/pos_order.py

@ -1,9 +1,10 @@
# © 2018 ACSONE SA/NV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from collections import defaultdict
import logging
from odoo import models, api
from odoo import api, models
_logger = logging.getLogger(__name__)

13
pos_payment_terminal/readme/CONFIGURE.rst

@ -1,4 +1,11 @@
* Go to Point of Sale > Configuration > Point of Sale, and check
the field "Payment Terminal"
This module support two payment modes : *card* and *check*. The payment
mode should be configured on the main Odoo server, in the menu *Point
of Sale > Configuration > Payment Methods*, under the *Point of Sale* tab.
.. figure:: ../static/description/pos_config_form.png
* Then, in the same point of sale form, click on "Payment Methods" to
set correctly your account journals.
This module support two payment modes : *card* and *check*, this
option is available in te Point of sale tab.
.. figure:: ../static/description/account_journal_form.png

1
pos_payment_terminal/readme/CONTRIBUTORS.rst

@ -1,2 +1,3 @@
* Aurelien Dumaine
* Alexis de Lattre <alexis.delattre@akretion.com>
* Sylvain LE GAL (https://twitter.com/legalsylvain)

BIN
pos_payment_terminal/static/description/account_journal_form.png

After

Width: 608  |  Height: 288  |  Size: 18 KiB

BIN
pos_payment_terminal/static/description/pos_config.png

After

Width: 524  |  Height: 262  |  Size: 18 KiB

49
pos_payment_terminal/static/src/js/pos_payment_terminal.js → pos_payment_terminal/static/src/js/devices.js

@ -7,19 +7,13 @@
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
*/
odoo.define('pos_payment_terminal.pos_payment_terminal', function (require) {
odoo.define('pos_payment_terminal.devices', function (require) {
"use strict";
var screens = require('point_of_sale.screens');
var devices = require('point_of_sale.devices');
var models = require('point_of_sale.models');
var core = require('web.core');
var _t = core._t;
var QWeb = core.qweb;
models.load_fields('account.journal', ['payment_mode']);
devices.ProxyDevice.include({
init: function(parents, options) {
var self = this;
self._super(parents, options);
@ -73,43 +67,4 @@ odoo.define('pos_payment_terminal.pos_payment_terminal', function (require) {
},
});
screens.PaymentScreenWidget.include({
render_paymentlines : function(){
this._super.apply(this, arguments);
var self = this;
this.$('.paymentlines-container').unbind('click').on('click', '.payment-terminal-transaction-start', function(event){
// Why this "on" thing links severaltime the button to the action if I don't use "unlink" to reset the button links before ?
//console.log(event.target);
self.pos.get_order().in_transaction = true;
self.order_changes();
self.pos.proxy.payment_terminal_transaction_start($(this).data('cid'), self.pos.currency.name, self.pos.currency.decimals);
});
},
order_changes: function(){
this._super.apply(this, arguments);
var order = this.pos.get_order();
if (!order) {
return;
} else if (order.in_transaction) {
self.$('.next').html('<img src="/web/static/src/img/spin.png" style="animation: fa-spin 1s infinite steps(12);width: 20px;height: auto;vertical-align: middle;">');
} else {
self.$('.next').html('Validate <i class="fa fa-angle-double-right"></i>');
}
}
});
var _orderproto = models.Order.prototype;
models.Order = models.Order.extend({
initialize: function(){
_orderproto.initialize.apply(this, arguments);
this.in_transaction = false;
},
export_as_JSON: function() {
var vals = _orderproto.export_as_JSON.apply(this, arguments);
vals['transactions'] = this.transactions || {};
return vals;
}
});
});

30
pos_payment_terminal/static/src/js/models.js

@ -0,0 +1,30 @@
/*
POS Payment Terminal module for Odoo
Copyright (C) 2014-2016 Aurélien DUMAINE
Copyright (C) 2014-2016 Akretion (www.akretion.com)
@author: Aurélien DUMAINE
@author: Alexis de Lattre <alexis.delattre@akretion.com>
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
*/
odoo.define('pos_payment_terminal.models', function (require) {
"use strict";
var models = require('point_of_sale.models');
var _orderproto = models.Order.prototype;
models.load_fields('account.journal', ['payment_mode']);
models.Order = models.Order.extend({
initialize: function(){
_orderproto.initialize.apply(this, arguments);
this.in_transaction = false;
},
export_as_JSON: function() {
var vals = _orderproto.export_as_JSON.apply(this, arguments);
vals['transactions'] = this.transactions || {};
return vals;
}
});
});

42
pos_payment_terminal/static/src/js/screens.js

@ -0,0 +1,42 @@
/*
POS Payment Terminal module for Odoo
Copyright (C) 2014-2016 Aurélien DUMAINE
Copyright (C) 2014-2016 Akretion (www.akretion.com)
@author: Aurélien DUMAINE
@author: Alexis de Lattre <alexis.delattre@akretion.com>
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
*/
odoo.define('pos_payment_terminal.screens', function (require) {
"use strict";
var screens = require('point_of_sale.screens');
screens.PaymentScreenWidget.include({
render_paymentlines : function(){
this._super.apply(this, arguments);
var self = this;
this.$('.paymentlines-container').unbind('click').on('click', '.payment-terminal-transaction-start', function(event){
// Why this "on" thing links severaltime the button to the action
// if I don't use "unlink" to reset the button links before ?
self.pos.get_order().in_transaction = true;
self.order_changes();
self.pos.proxy.payment_terminal_transaction_start($(this).data('cid'), self.pos.currency.name, self.pos.currency.decimals);
});
},
order_changes: function(){
this._super.apply(this, arguments);
var order = this.pos.get_order();
if (!order) {
return;
} else if (order.in_transaction) {
self.$('.next').html('<img src="/web/static/src/img/spin.png" style="animation: fa-spin 1s infinite steps(12);width: 20px;height: auto;vertical-align: middle;">');
} else {
self.$('.next').html('Validate <i class="fa fa-angle-double-right"></i>');
}
}
});
});

11
pos_payment_terminal/views/account_journal.xml

@ -1,14 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="view_account_journal_pos_user_form" model="ir.ui.view">
<field name="name">pos.payment.terminal.journal.form</field>
<record id="view_account_journal_form" model="ir.ui.view">
<field name="model">account.journal</field>
<field name="inherit_id" ref="point_of_sale.view_account_journal_pos_user_form"/>
<field name="arch" type="xml">
<field name="amount_authorized_diff" position="after">
<field name="payment_mode"/>
</field>
<group name="amount_authorized" position="after">
<group name="payment_mode_group" attrs="{'invisible': [('type', '!=', 'bank')]}">
<field name="payment_mode"/>
</group>
</group>
</field>
</record>

13
pos_payment_terminal/views/assets.xml

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<template id="assets" inherit_id="point_of_sale.assets">
<xpath expr="." position="inside">
<script type="text/javascript" src="/pos_payment_terminal/static/src/js/screens.js"></script>
<script type="text/javascript" src="/pos_payment_terminal/static/src/js/models.js"></script>
<script type="text/javascript" src="/pos_payment_terminal/static/src/js/devices.js"></script>
<link rel="stylesheet" href="/pos_payment_terminal/static/src/css/pos_payment_terminal.css" />
</xpath>
</template>
</odoo>

13
pos_payment_terminal/views/pos_config.xml

@ -1,14 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="view_pos_config_form" model="ir.ui.view">
<field name="name">pos.payment.terminal.config.form</field>
<field name="model">pos.config</field>
<field name="inherit_id" ref="point_of_sale.view_pos_config_form"/>
<field name="inherit_id" ref="point_of_sale.pos_config_view_form"/>
<field name="arch" type="xml">
<field name="iface_cashdrawer" position="after">
<field name="iface_payment_terminal"/>
</field>
<xpath expr="//field[@name='iface_cashdrawer']/.." position="after">
<div class="row">
<label string="Payment Terminal" for="iface_payment_terminal" class="col-lg-3 o_light_label"/>
<field name="iface_payment_terminal"/>
</div>
</xpath>
</field>
</record>

11
pos_payment_terminal/views/pos_payment_terminal_template.xml

@ -1,11 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<template id="assets" inherit_id="point_of_sale.assets" name="pos_payment_terminal assets">
<xpath expr="." position="inside">
<script type="text/javascript" src="/pos_payment_terminal/static/src/js/pos_payment_terminal.js"></script>
<link rel="stylesheet" href="/pos_payment_terminal/static/src/css/pos_payment_terminal.css" />
</xpath>
</template>
</odoo>
Loading…
Cancel
Save