Browse Source

pos_payment_terminal: smiplify JS code

Move description from __openerp__.py to README.rst
Update demo data
pull/440/head
Alexis de Lattre 10 years ago
committed by Sylvain LE GAL
parent
commit
3ebc6c7d80
  1. 55
      pos_payment_terminal/README.rst
  2. 24
      pos_payment_terminal/__openerp__.py
  3. 5
      pos_payment_terminal/pos_payment_terminal.py
  4. 4
      pos_payment_terminal/pos_payment_terminal_demo.xml
  5. 44
      pos_payment_terminal/static/src/js/pos_payment_terminal.js

55
pos_payment_terminal/README.rst

@ -0,0 +1,55 @@
POS Payment Terminal
====================
This module adds support for credit card reader and checks printer
in the Point of Sale.
This module has been developped during a POS code sprint at Akretion
France from July 7th to July 10th 2014. This module is part of the POS
project of the Odoo Community Association http://odoo-community.org/.
You are invited to become a member and/or get involved in the
Association !
Installation
============
This module is designed to be installed on the
*main Odoo server*. On the *POSbox*, you should install the module
*hw_x* depending on the protocol implemented in your device.
`Ingenico <http://en.wikipedia.org/wiki/Ingenico>`
and old Sagem devices support the Telium protocol implemented in the
*hw_telium_payment_terminal* module.
Configuration
=============
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.
Usage
=====
In the frontend of the POS, when you select a payment method that has a payment mode *card* or *check*, you will have a *Start Transaction* button : if you click on that button, the amount, the currency and the payment mode will be sent to the POSbox.
Credits
=======
Contributors
------------
* Aurelien Dumaine
* Alexis de Lattre <alexis.delattre@akretion.com>
Maintainer
----------
.. image:: http://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: http://odoo-community.org
This module is maintained by the OCA.
OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use.
To contribute to this module, please visit http://odoo-community.org.

24
pos_payment_terminal/__openerp__.py

@ -3,6 +3,7 @@
#
# POS Payment Terminal module for Odoo
# Copyright (C) 2014 Aurélien DUMAINE
# Copyright (C) 2015 Akretion (www.akretion.com)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
@ -25,28 +26,7 @@
'version': '0.1',
'category': 'Point Of Sale',
'summary': 'Manage Payment Terminal device from POS front end',
'description': """
POS Payment Terminal
====================
This module adds support for credit card reader and checks printer
in the Point of Sale. This module is designed to be installed on the
*main Odoo server*. On the *POSbox*, you should install the module
*hw_x* depending on the protocol implemented in your device. Ingenico
and Sagem devices support the Telium protocol implemented in the
*hw_telium_payment_terminal* module.
This module support two payment methods : cards and checks. The payment
method should be configured on the main Odoo server, in the menu Point
of Sale > Configuration > Payment Methods.
This module has been developped during a POS code sprint at Akretion
France from July 7th to July 10th 2014. This module is part of the POS
project of the Odoo Community Association http://odoo-community.org/.
You are invited to become a member and/or get involved in the
Association !
""",
'author': "Aurélien DUMAINE,Odoo Community Association (OCA)",
'author': "Aurélien DUMAINE,Akretion,Odoo Community Association (OCA)",
'license': 'AGPL-3',
'depends': ['point_of_sale'],
'data': [

5
pos_payment_terminal/pos_payment_terminal.py

@ -3,6 +3,7 @@
#
# POS Payment Terminal module for Odoo
# Copyright (C) 2014 Aurélien DUMAINE
# Copyright (C) 2015 Akretion (www.akretion.com)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
@ -22,7 +23,7 @@
from openerp import models, fields
class account_journal(models.Model):
class AccountJournal(models.Model):
_inherit = 'account.journal'
payment_mode = fields.Selection(
@ -30,7 +31,7 @@ class account_journal(models.Model):
help="Select the payment mode sent to the payment terminal")
class pos_config(models.Model):
class PosConfig(models.Model):
_inherit = 'pos.config'
iface_payment_terminal = fields.Boolean(

4
pos_payment_terminal/pos_payment_terminal_demo.xml

@ -6,5 +6,9 @@
<field name="payment_mode">check</field>
</record>
<record id="point_of_sale.pos_config_main" model="pos.config">
<field name="iface_payment_terminal" eval="True"/>
</record>
</data>
</openerp>

44
pos_payment_terminal/static/src/js/pos_payment_terminal.js

@ -1,3 +1,12 @@
/*
POS Payment Terminal module for Odoo
Copyright (C) 2014 Aurélien DUMAINE
Copyright (C) 2014-2015 Akretion (www.akretion.com)
@author: Aurélien DUMAINE
@author: Alexis de Lattre <alexis.delattre@akretion.com>
The licence is in the file __openerp__.py
*/
openerp.pos_payment_terminal = function(instance){
module = instance.point_of_sale;
@ -6,43 +15,20 @@ openerp.pos_payment_terminal = function(instance){
var data = {'amount' : line.get_amount(),
'currency_iso' : currency_iso,
'payment_mode' : line.cashregister.journal.payment_mode};
// alert(JSON.stringify(data));
this.message('payment_terminal_transaction_start', {'payment_info' : JSON.stringify(data)});
},
});
var _super_PaymentScreenWidget_init_ = module.PaymentScreenWidget.prototype.init;
module.PaymentScreenWidget.prototype.init = function(parent, options){
_super_PaymentScreenWidget_init_.call(this, parent, options);
module.PaymentScreenWidget.include({
render_paymentline: function(line){
el_node = this._super(line);
var self = this;
this.payment_terminal_transaction_start = function(event){
var node = this;
while (node && !node.classList.contains('paymentline')){
node = node.parentNode;
}
if (node && !_.isEmpty(node.line) && self.pos.config.iface_payment_terminal){
self.pos.proxy.payment_terminal_transaction_start(node.line, self.pos.currency.name);
}
event.stopPropagation();
};
};
var _super_renderPaymentline_ = module.PaymentScreenWidget.prototype.render_paymentline;
module.PaymentScreenWidget.prototype.render_paymentline = function(line){
var el_node = _super_renderPaymentline_.call(this, line);
if (line.cashregister.journal.payment_mode && this.pos.config.iface_payment_terminal){
if (!this.pos.currency.name){
var self = this;
var currencies = new instance.web.Model('res.currency').query(['name'])
.filter([['id','=',this.pos.currency.id]])
.all().then(function (currency) {
self.pos.currency.name = currency[0].name;
});
}
el_node.querySelector('.payment-terminal-transaction-start')
.addEventListener('click', this.payment_terminal_transaction_start);
.addEventListener('click', function(){self.pos.proxy.payment_terminal_transaction_start(line, self.pos.currency.name)});
}
return el_node;
};
},
});
};
Loading…
Cancel
Save