Browse Source

begin of porting pos_payment_terminal to Odoo 9.0

pull/105/head
Aurélien DUMAINE 9 years ago
parent
commit
417b708415
  1. 6
      pos_payment_terminal/__openerp__.py
  2. 18
      pos_payment_terminal/pos_payment_terminal.xml
  3. 2
      pos_payment_terminal/pos_payment_terminal_view.xml
  4. 96
      pos_payment_terminal/static/src/js/pos_payment_terminal.js
  5. 13
      pos_payment_terminal/static/src/xml/pos_payment_terminal.xml

6
pos_payment_terminal/__openerp__.py

@ -23,17 +23,17 @@
{ {
'name': 'POS Payment Terminal', 'name': 'POS Payment Terminal',
'version': '8.0.0.1.0',
'version': '9.0.0.1.0',
'category': 'Point Of Sale', 'category': 'Point Of Sale',
'summary': 'Manage Payment Terminal device from POS front end', 'summary': 'Manage Payment Terminal device from POS front end',
'author': "Aurélien DUMAINE,Akretion,Odoo Community Association (OCA)", 'author': "Aurélien DUMAINE,Akretion,Odoo Community Association (OCA)",
'license': 'AGPL-3', 'license': 'AGPL-3',
'depends': ['point_of_sale'], 'depends': ['point_of_sale'],
'data': [ 'data': [
'pos_payment_terminal.xml',
'pos_payment_terminal_view.xml', 'pos_payment_terminal_view.xml',
'static/src/xml/templates.xml',
], ],
'demo': ['pos_payment_terminal_demo.xml'], 'demo': ['pos_payment_terminal_demo.xml'],
'qweb': ['static/src/xml/pos_payment_terminal.xml'], 'qweb': ['static/src/xml/pos_payment_terminal.xml'],
'installable': False,
'installable': True,
} }

18
pos_payment_terminal/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>

2
pos_payment_terminal/pos_payment_terminal_view.xml

@ -18,7 +18,7 @@
<field name="model">account.journal</field> <field name="model">account.journal</field>
<field name="inherit_id" ref="point_of_sale.view_account_journal_pos_user_form"/> <field name="inherit_id" ref="point_of_sale.view_account_journal_pos_user_form"/>
<field name="arch" type="xml"> <field name="arch" type="xml">
<field name="self_checkout_payment_method" position="after">
<field name="amount_authorized_diff" position="after">
<field name="payment_mode"/> <field name="payment_mode"/>
</field> </field>
</field> </field>

96
pos_payment_terminal/static/src/js/pos_payment_terminal.js

@ -1,34 +1,96 @@
/* /*
POS Payment Terminal module for Odoo 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) Copyright (C) 2014-2015 Akretion (www.akretion.com)
@author: Aurélien DUMAINE @author: Aurélien DUMAINE
@author: Alexis de Lattre <alexis.delattre@akretion.com> @author: Alexis de Lattre <alexis.delattre@akretion.com>
The licence is in the file __openerp__.py 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(), var data = {'amount' : line.get_amount(),
'currency_iso' : currency_iso, 'currency_iso' : currency_iso,
'payment_mode' : line.cashregister.journal.payment_mode}; 'payment_mode' : line.cashregister.journal.payment_mode};
alert(JSON.stringify(data));
this.message('payment_terminal_transaction_start', {'payment_info' : 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);
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)});
}
return el_node;
},
});
};
// 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;
var order = this.pos.get_order();
if (!order) {
return;
}
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){
};
});

13
pos_payment_terminal/static/src/xml/pos_payment_terminal.xml

@ -1,11 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<templates id="template" xml:space="preserve"> <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"> <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> </t>
</t> </t>

Loading…
Cancel
Save