Aurélien DUMAINE
9 years ago
committed by
Sylvain LE GAL
5 changed files with 91 additions and 44 deletions
-
6pos_payment_terminal/__manifest__.py
-
18pos_payment_terminal/pos_payment_terminal.xml
-
2pos_payment_terminal/pos_payment_terminal_view.xml
-
90pos_payment_terminal/static/src/js/pos_payment_terminal.js
-
13pos_payment_terminal/static/src/xml/pos_payment_terminal.xml
@ -1,18 +0,0 @@ |
|||
<?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> |
|||
|
|||
<template id="index" name="pos_payment_terminal index" inherit_id="point_of_sale.index"> |
|||
<xpath expr="//link[@id='pos-stylesheet']" position="after"> |
|||
<link rel="stylesheet" href="/pos_payment_terminal/static/src/css/pos_payment_terminal.css" id="pos_payment_terminal-stylesheet"/> |
|||
</xpath> |
|||
</template> |
|||
|
|||
</data> |
|||
</openerp> |
@ -1,34 +1,96 @@ |
|||
/* |
|||
POS Payment Terminal module for Odoo |
|||
Copyright (C) 2014 Aurélien DUMAINE |
|||
Copyright (C) 2014-2016 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; |
|||
odoo.define('pos_payment_terminal.pos_payment_terminal', function (require) { |
|||
"use strict"; |
|||
|
|||
var screens = require('point_of_sale.screens'); |
|||
var devices = require('point_of_sale.devices'); |
|||
var models = require('point_of_sale.models'); |
|||
// var gui = require('point_of_sale.gui');
|
|||
var core = require('web.core'); |
|||
var _t = core._t; |
|||
var QWeb = core.qweb; |
|||
|
|||
/* |
|||
//TODO : surcharger models.exports.PosModel.load_server_data pour récupérer le champ 'payement_mode' des journaux
|
|||
var _r_ = models.exports.PosModel.prototype.load_server_data; |
|||
models.exports.PosModel.prototype.load_server_data = function(){ |
|||
var self = this; |
|||
for (var i = 0; i < self.models.length; i++){ |
|||
if (self.models[i].model== 'account.journal'){ |
|||
self.models[i].fields.push('payment_mode'); |
|||
} |
|||
} |
|||
_r_.call(this); |
|||
}); |
|||
*/ |
|||
devices.ProxyDevice.include({ |
|||
payment_terminal_transaction_start: function(line_cid, currency_iso){ |
|||
var lines = this.pos.get_order().get_paymentlines(); |
|||
var line; |
|||
for ( var i = 0; i < lines.length; i++ ) { |
|||
if (lines[i].cid === line_cid) { |
|||
line = lines[i]; |
|||
} |
|||
} |
|||
|
|||
module.ProxyDevice = module.ProxyDevice.extend({ |
|||
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)}); |
|||
}, |
|||
}); |
|||
|
|||
module.PaymentScreenWidget.include({ |
|||
render_paymentline: function(line){ |
|||
el_node = this._super(line); |
|||
|
|||
// TODO : overload instead of redefine
|
|||
// var _render_paymentlines_ = screens.PaymentScreenWidget.prototype.render_paymentlines;
|
|||
screens.PaymentScreenWidget.prototype.render_paymentlines = function(){ |
|||
// _render_paymentlines_.call(this);
|
|||
var self = this; |
|||
if (line.cashregister.journal.payment_mode && this.pos.config.iface_payment_terminal){ |
|||
el_node.querySelector('.payment-terminal-transaction-start') |
|||
.addEventListener('click', function(){self.pos.proxy.payment_terminal_transaction_start(line, self.pos.currency.name)}); |
|||
var order = this.pos.get_order(); |
|||
if (!order) { |
|||
return; |
|||
} |
|||
return el_node; |
|||
}, |
|||
|
|||
var lines = order.get_paymentlines(); |
|||
var due = order.get_due(); |
|||
var extradue = 0; |
|||
if (due && lines.length && due !== order.get_due(lines[lines.length-1])) { |
|||
extradue = due; |
|||
} |
|||
|
|||
|
|||
this.$('.paymentlines-container').empty(); |
|||
var lines = $(QWeb.render('PaymentScreen-Paymentlines', { |
|||
widget: this, |
|||
order: order, |
|||
paymentlines: lines, |
|||
extradue: extradue, |
|||
})); |
|||
|
|||
lines.on('click','.delete-button',function(){ |
|||
self.click_delete_paymentline($(this).data('cid')); |
|||
}); |
|||
|
|||
}; |
|||
lines.on('click','.paymentline',function(){ |
|||
self.click_paymentline($(this).data('cid')); |
|||
}); |
|||
|
|||
lines.on('click','.payment-terminal-transaction-start',function(){ |
|||
self.pos.proxy.payment_terminal_transaction_start($(this).data('cid'), self.pos.currency.name); |
|||
}); |
|||
|
|||
|
|||
lines.appendTo(this.$('.paymentlines-container')); |
|||
//if (line.cashregister.journal.payment_mode && this.pos.config.iface_payment_terminal){
|
|||
|
|||
}; |
|||
}); |
@ -1,11 +1,14 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<templates id="template" xml:space="preserve"> |
|||
<t t-extend="Paymentline" > |
|||
<t t-jquery=".paymentline-input" t-operation="append"> |
|||
<t t-extend="PaymentScreen-Paymentlines" > |
|||
<t t-jquery=".col-name" t-operation="append"> |
|||
<!-- |
|||
<button class="payment-terminal-transaction-start" t-att-data-cid='line.cid'>Start transaction</button> |
|||
<t t-esc='line.cashregister.journal.type' /> |
|||
<t t-esc='line.cashregister.journal.payment_mode' /> |
|||
--> |
|||
<t t-if="line.cashregister.journal.payment_mode"> |
|||
<span class="payment-terminal-transaction-start"> |
|||
<button>Start transaction</button> |
|||
</span> |
|||
<button class="payment-terminal-transaction-start" t-att-data-cid='line.cid'>Start transaction</button> |
|||
</t> |
|||
</t> |
|||
</t> |
|||
|
Write
Preview
Loading…
Cancel
Save
Reference in new issue