Browse Source

Initial check-in of the module pos_payment_terminal.

pull/10/head
Auélien DUMAINE 10 years ago
parent
commit
80603dc163
  1. 16
      pos_customer_display/static/src/js/customer_display.js
  2. 1
      pos_payment_terminal/__init__.py
  3. 45
      pos_payment_terminal/__openerp__.py
  4. 36
      pos_payment_terminal/pos_payment_terminal.py
  5. 10
      pos_payment_terminal/pos_payment_terminal.xml
  6. 25
      pos_payment_terminal/pos_payment_terminal_view.xml
  7. 86
      pos_payment_terminal/static/src/js/pos_payment_terminal.js
  8. 16
      pos_payment_terminal/static/src/xml/pos_payment_terminal.xml

16
pos_customer_display/static/src/js/customer_display.js

@ -41,15 +41,15 @@ openerp.pos_customer_display = function(instance){
var total = this.get('selectedOrder').getTotalTaxIncluded().toFixed(currency_rounding);
var lines_to_send = new Array(
this.proxy.complete_string_right(_t("TOTAL : "), line_length - 1 - total.length) + ' ' + total,
this.proxy.complete_string_right(_t("Paiement :"), line_length - 1 - cashregister.journal_id[1].length) + ' ' + cashregister.journal_id[1]
this.proxy.complete_string_right(_t("Payment :"), line_length - 1 - cashregister.journal_id[1].length) + ' ' + cashregister.journal_id[1]
);
} else if (type == 'removePaymentline') {
var line = data['line'];
var amount = line.get_amount().toFixed(currency_rounding);
var lines_to_send = new Array(
this.proxy.complete_string_right(_t("Suppression paiement"), line_length),
this.proxy.complete_string_right(line.cashregister.journal_id[1] , line_length - 1- amount.length) + ' ' + amount
this.proxy.complete_string_right(_t("Delete payment"), line_length),
this.proxy.complete_string_right(line.cashregister.journal_id[1] , line_length - 1 - amount.length) + ' ' + amount
);
} else if (type == 'pushOrder') {
var currentOrder = data['currentOrder'];
@ -80,6 +80,7 @@ openerp.pos_customer_display = function(instance){
return;
}
// alert("aa" + line_length);
this.proxy.send_text_customer_display(lines_to_send, line_length);
},
@ -88,11 +89,17 @@ openerp.pos_customer_display = function(instance){
module.ProxyDevice = module.ProxyDevice.extend({
send_text_customer_display: function(data, line_length){
//FIXME : this function is call twice. The first time, it is not called by prepare_text_customer_display : WHY ?
// alert("bb" + line_length);
if (data[0].length != line_length)
console.warn(data[0].length + " " + data[0]);
if (data[1].length != line_length)
console.warn(data[1].length + " " + data[1]);
if (data[0].length != line_length || data[1].length != line_length){
console.warn("Data components have to have " + line_length + " chars.");
console.log(data[0].length + " -> "+ data[0] + "\n" + data[1].length + " -> " + data[1]);
} else {
//alert(JSON.stringify(data));
// alert(JSON.stringify(data));
return this.message('send_text_customer_display', {'text_to_display' : JSON.stringify(data)});
}
return;
@ -143,6 +150,7 @@ openerp.pos_customer_display = function(instance){
});
//FIXME : nothing append on customer display deconnection
var _super_setSmartStatus_ = module.ProxyStatusWidget.prototype.set_smart_status;
module.ProxyStatusWidget.prototype.set_smart_status = function(status){
_super_setSmartStatus_.call(this, status);

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