Browse Source

Initial check-in of the module pos_payment_terminal.

pull/440/head
Auélien DUMAINE 11 years ago
committed by Sylvain LE GAL
parent
commit
b62263b795
  1. 1
      pos_payment_terminal/__init__.py
  2. 45
      pos_payment_terminal/__openerp__.py
  3. 36
      pos_payment_terminal/pos_payment_terminal.py
  4. 10
      pos_payment_terminal/pos_payment_terminal.xml
  5. 25
      pos_payment_terminal/pos_payment_terminal_view.xml
  6. 86
      pos_payment_terminal/static/src/js/pos_payment_terminal.js
  7. 16
      pos_payment_terminal/static/src/xml/pos_payment_terminal.xml

1
pos_payment_terminal/__init__.py

@ -0,0 +1 @@
import pos_payment_terminal

45
pos_payment_terminal/__openerp__.py

@ -0,0 +1,45 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
{
'name': 'POS Payment Terminal',
'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 Payment Terminal 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 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 !
Please contact Alexis de Lattre from Akretion <alexis.delattre@akretion.com> for any help or question about this module.
""",
'author': 'Aurélien DUMAINE',
'depends': ['point_of_sale'],
'data' : ['pos_payment_terminal.xml',
'pos_payment_terminal_view.xml'],
'qweb': ['static/src/xml/pos_payment_terminal.xml'],
}

36
pos_payment_terminal/pos_payment_terminal.py

@ -0,0 +1,36 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SP (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from openerp import models, fields
class account_journal(models.Model):
_name = 'account.journal'
_inherit = 'account.journal'
payment_mode = fields.Selection((('card', 'Card'), ('check', 'Check')), 'Payment mode', help="Select the payment mode sent to the payment terminal")
class pos_config(models.Model):
_name = 'pos.config'
_inherit = 'pos.config'
iface_payment_terminal = fields.Boolean('Payment Terminal', help="A payment terminal is available on the Proxy")
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

10
pos_payment_terminal/pos_payment_terminal.xml

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<template id="assets_backend" name="point_of_sale assets" inherit_id="web.assets_backend">
<xpath expr="." position="inside">
<script type="text/javascript" src="/pos_payment_terminal/static/src/js/pos_payment_terminal.js"></script>
</xpath>
</template>
</data>
</openerp>

25
pos_payment_terminal/pos_payment_terminal_view.xml

@ -0,0 +1,25 @@
<?xml version="1.0"?>
<openerp>
<data>
<record id="view_pos_config_form" model="ir.ui.view">
<field name="name">pos.config.form.view.inherit</field>
<field name="model">pos.config</field>
<field name="inherit_id" ref="point_of_sale.view_pos_config_form"/>
<field name="arch" type="xml">
<field name="iface_cashdrawer" position="after">
<field name="iface_payment_terminal"/>
</field>
</field>
</record>
<record id="view_account_journal_pos_user_form" model="ir.ui.view">
<field name="name">POS journal inherit</field>
<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="self_checkout_payment_method" position="after">
<field name="payment_mode"/>
</field>
</field>
</record>
</data>
</openerp>

86
pos_payment_terminal/static/src/js/pos_payment_terminal.js

@ -0,0 +1,86 @@
openerp.pos_payment_terminal = function(instance){
module = instance.point_of_sale;
module.ProxyDevice = module.ProxyDevice.extend({
payment_terminal_transaction_start: function(line, currency_iso, currency_iso_numeric){
var data = {'amount' : line.get_amount(),
'currency_iso' : currency_iso,
'currency_iso_numeric' : currency_iso_numeric,
'payment_mode' : line.cashregister.journal.payment_mode};
alert(JSON.stringify(data));
this.message('payment_terminal_transaction_start', {'payment_info' : JSON.stringify(data)});
},
});
//TODO make the button bigger and with better name
var _super_PaymentScreenWidget_init_ = module.PaymentScreenWidget.prototype.init;
module.PaymentScreenWidget.prototype.init = function(parent, options){
_super_PaymentScreenWidget_init_.call(this, parent, options);
self = this;
this.payment_terminal_transaction_start = function(event){
var node = this;
while(node && !node.classList.contains('paymentline')){
node = node.parentNode;
}
if(node){
if (self.pos.config.iface_payment_terminal)
self.pos.proxy.payment_terminal_transaction_start(node.line, self.pos.currency.name, self.pos.currency.iso_numeric);
}
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', 'iso_numeric'])
.filter([['id','=',this.pos.currency.id]])
.all().then(function (currency) {
self.pos.currency.name = currency[0].name;
self.pos.currency.iso_numeric = currency[0].iso_numeric;
});
}
el_node.querySelector('.payment-terminal-transaction-start')
.addEventListener('click', this.payment_terminal_transaction_start);
//.addEventListener('click', this.pos.proxy.payment_terminal_transaction_start(line, this.pos.currency.name, this.pos.currency.iso_numeric));
}
return el_node;
};
/*
var _super_load_server_data_ = module.PosModel.prototype.load_server_data;
module.PosModel.prototype.load_server_data = function(){
var loaded = _super_load_server_data_.call(this);
//FIXME : this is asynchronous, I can't assume the pos.currency loaded when we enter is this
this.pos.currency.name = new instance.web.Model('res.currency').query('name').filter([['id','=',this.pos_currency.id]]).all()[0]
return loaded;
};
*/
/*
var _super_setSmartStatus_ = module.ProxyStatusWidget.prototype.set_smart_status;
module.ProxyStatusWidget.prototype.set_smart_status = function(status){
_super_setSmartStatus_.call(this, status);
if(status.status === 'connected'){
var warning = false;
var msg = ''
if(this.pos.config.iface_customer_display){
var customer_display = status.drivers.customer_display ? status.drivers.customer_display.status : false;
if( customer_display != 'connected' && customer_display != 'connecting'){
warning = true;
msg = msg ? msg + ' & ' : msg;
msg += _t('Customer display');
}
}
msg = msg ? msg + ' ' + _t('Offline') : msg;
this.set_status(warning ? 'warning' : 'connected', msg);
}else{
this.set_status(status.status,'');
}
};
*/
};

16
pos_payment_terminal/static/src/xml/pos_payment_terminal.xml

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<templates id="template" xml:space="preserve">
<t t-extend="Paymentline" >
<t t-jquery=".paymentline-name" t-operation="append">
<t t-if="line.cashregister.journal.payment_mode">
<!-- <t t-if="pos.config.iface_payment_terminal">-->
<span class="payment-terminal-transaction-start">
<button>
<t t-esc="line.cashregister.journal.payment_mode"/>
</button>
</span>
<!-- </t> -->
</t>
</t>
</t>
</templates>
Loading…
Cancel
Save