Browse Source

Remove currency_iso_numeric (replaced by pycountry)

Adapt JS code of pos_payment_terminal
Some cleanup
pull/440/head
Alexis de Lattre 10 years ago
committed by Sylvain LE GAL
parent
commit
0996c84a28
  1. 2
      pos_payment_terminal/__openerp__.py
  2. 4
      pos_payment_terminal/pos_payment_terminal.py
  3. 97
      pos_payment_terminal/static/src/js/pos_payment_terminal.js

2
pos_payment_terminal/__openerp__.py

@ -36,7 +36,7 @@ This module support two payment methods : cards and checks. The payment method s
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 ! 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', 'author': 'Aurélien DUMAINE',
'depends': ['point_of_sale', 'currency_iso_numeric'],
'depends': ['point_of_sale'],
'data': [ 'data': [
'pos_payment_terminal.xml', 'pos_payment_terminal.xml',
'pos_payment_terminal_view.xml', 'pos_payment_terminal_view.xml',

4
pos_payment_terminal/pos_payment_terminal.py

@ -23,7 +23,6 @@ from openerp import models, fields
class account_journal(models.Model): class account_journal(models.Model):
_name = 'account.journal'
_inherit = 'account.journal' _inherit = 'account.journal'
payment_mode = fields.Selection( payment_mode = fields.Selection(
@ -32,11 +31,8 @@ class account_journal(models.Model):
class pos_config(models.Model): class pos_config(models.Model):
_name = 'pos.config'
_inherit = 'pos.config' _inherit = 'pos.config'
iface_payment_terminal = fields.Boolean( iface_payment_terminal = fields.Boolean(
'Payment Terminal', 'Payment Terminal',
help="A payment terminal is available on the Proxy") help="A payment terminal is available on the Proxy")
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

97
pos_payment_terminal/static/src/js/pos_payment_terminal.js

@ -2,84 +2,49 @@ openerp.pos_payment_terminal = function(instance){
module = instance.point_of_sale; module = instance.point_of_sale;
module.ProxyDevice = module.ProxyDevice.extend({ 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)});
payment_terminal_transaction_start: function(line, currency_iso){
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)});
}, },
});
});
//TODO make the button bigger and with better name
//TODO make the button bigger and with better name
var _super_PaymentScreenWidget_init_ = module.PaymentScreenWidget.prototype.init; var _super_PaymentScreenWidget_init_ = module.PaymentScreenWidget.prototype.init;
module.PaymentScreenWidget.prototype.init = function(parent, options){ module.PaymentScreenWidget.prototype.init = function(parent, options){
_super_PaymentScreenWidget_init_.call(this, 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();
};
};
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; var _super_renderPaymentline_ = module.PaymentScreenWidget.prototype.render_paymentline;
module.PaymentScreenWidget.prototype.render_paymentline = function(line){ module.PaymentScreenWidget.prototype.render_paymentline = function(line){
var el_node = _super_renderPaymentline_.call(this, line); var el_node = _super_renderPaymentline_.call(this, line);
if (line.cashregister.journal.payment_mode && this.pos.config.iface_payment_terminal){ 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);
}
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');
}
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;
});
} }
msg = msg ? msg + ' ' + _t('Offline') : msg;
this.set_status(warning ? 'warning' : 'connected', msg);
}else{
this.set_status(status.status,'');
el_node.querySelector('.payment-terminal-transaction-start')
.addEventListener('click', this.payment_terminal_transaction_start);
} }
return el_node;
}; };
*/
}; };
Loading…
Cancel
Save