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. 43
      pos_payment_terminal/i18n/fr.po
  5. 30
      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. 9
      pos_payment_terminal/views/account_journal.xml
  16. 13
      pos_payment_terminal/views/assets.xml
  17. 11
      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', 'version': '12.0.0.1.1',
'category': 'Point Of Sale', 'category': 'Point Of Sale',
'summary': 'Manage Payment Terminal device from POS front end', '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', 'license': 'AGPL-3',
'depends': ['point_of_sale'], 'depends': ['point_of_sale'],
'data': [ 'data': [
'views/pos_config.xml', 'views/pos_config.xml',
'views/account_journal.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'], 'qweb': ['static/src/xml/pos_payment_terminal.xml'],
'installable': True, '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>

43
pos_payment_terminal/i18n/fr.po

@ -2,22 +2,23 @@
# This file contains the translation of the following modules: # 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 "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: Odoo Server 10.0\n"
"Project-Id-Version: Odoo Server 12.0\n"
"Report-Msgid-Bugs-To: \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" "MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \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 #. module: pos_payment_terminal
#: selection:account.journal,payment_mode:0 #: selection:account.journal,payment_mode:0
@ -35,17 +36,28 @@ msgid "Journal"
msgstr "Journal" msgstr "Journal"
#. module: pos_payment_terminal #. 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" msgid "Payment Mode"
msgstr "Moyen de paiement" 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 #. module: pos_payment_terminal
#: model:ir.model,name:pos_payment_terminal.model_pos_order #: model:ir.model,name:pos_payment_terminal.model_pos_order
msgid "Point of Sale Orders" msgid "Point of Sale Orders"
msgstr ""
msgstr "Commandes du point de vente"
#. module: pos_payment_terminal #. 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" msgid "Select the payment mode sent to the payment terminal"
msgstr "Sélectionner le mode de paiement envoyé au terminal de paiement" 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 #, python-format
msgid "Start transaction" msgid "Start transaction"
msgstr "Démarrer la 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"

30
pos_payment_terminal/i18n/pos_payment_terminal.pot

@ -4,8 +4,10 @@
# #
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: Odoo Server 10.0\n"
"Project-Id-Version: Odoo Server 12.0\n"
"Report-Msgid-Bugs-To: \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" "Last-Translator: <>\n"
"Language-Team: \n" "Language-Team: \n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
@ -13,6 +15,11 @@ msgstr ""
"Content-Transfer-Encoding: \n" "Content-Transfer-Encoding: \n"
"Plural-Forms: \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 #. module: pos_payment_terminal
#: selection:account.journal,payment_mode:0 #: selection:account.journal,payment_mode:0
msgid "Card" msgid "Card"
@ -29,17 +36,28 @@ msgid "Journal"
msgstr "" msgstr ""
#. module: pos_payment_terminal #. 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" msgid "Payment Mode"
msgstr "" 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 #. module: pos_payment_terminal
#: model:ir.model,name:pos_payment_terminal.model_pos_order #: model:ir.model,name:pos_payment_terminal.model_pos_order
msgid "Point of Sale Orders" msgid "Point of Sale Orders"
msgstr "" msgstr ""
#. module: pos_payment_terminal #. 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" msgid "Select the payment mode sent to the payment terminal"
msgstr "" msgstr ""
@ -49,9 +67,3 @@ msgstr ""
#, python-format #, python-format
msgid "Start transaction" msgid "Start transaction"
msgstr "" 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>) # © 2015-2016 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import models, fields from odoo import models, fields

3
pos_payment_terminal/models/pos_order.py

@ -1,9 +1,10 @@
# © 2018 ACSONE SA/NV # © 2018 ACSONE SA/NV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from collections import defaultdict from collections import defaultdict
import logging import logging
from odoo import models, api
from odoo import api, models
_logger = logging.getLogger(__name__) _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 * Aurelien Dumaine
* Alexis de Lattre <alexis.delattre@akretion.com> * 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). 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"; "use strict";
var screens = require('point_of_sale.screens');
var devices = require('point_of_sale.devices'); 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({ devices.ProxyDevice.include({
init: function(parents, options) { init: function(parents, options) {
var self = this; var self = this;
self._super(parents, options); 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>');
}
}
});
});

9
pos_payment_terminal/views/account_journal.xml

@ -1,14 +1,15 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<odoo> <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="model">account.journal</field>
<field name="inherit_id" ref="point_of_sale.view_account_journal_pos_user_form"/> <field name="inherit_id" ref="point_of_sale.view_account_journal_pos_user_form"/>
<field name="arch" type="xml"> <field name="arch" type="xml">
<field name="amount_authorized_diff" position="after">
<group name="amount_authorized" position="after">
<group name="payment_mode_group" attrs="{'invisible': [('type', '!=', 'bank')]}">
<field name="payment_mode"/> <field name="payment_mode"/>
</field>
</group>
</group>
</field> </field>
</record> </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>

11
pos_payment_terminal/views/pos_config.xml

@ -1,14 +1,17 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<odoo> <odoo>
<record id="view_pos_config_form" model="ir.ui.view"> <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="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="arch" type="xml">
<field name="iface_cashdrawer" position="after">
<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"/> <field name="iface_payment_terminal"/>
</field>
</div>
</xpath>
</field> </field>
</record> </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