[IMP] pos_reprint: port the module to the new internal pos api

This commit is contained in:
Frédéric van der Essen
2015-01-21 12:12:40 +01:00
parent c3127ac48b
commit b3f0a0e744
5 changed files with 36 additions and 42 deletions
+6 -3
View File
@@ -21,16 +21,16 @@
{
'name': 'Point of Sale Reprint',
'name': 'Point of Sale Receipt Reprinting',
'version': '1.0',
'category': 'Point of Sale',
'sequence': 6,
'summary': 'Allow cashier to reprint tickets',
'summary': 'Allow cashier to reprint receipts',
'description': """
=======================
Allow cashier to reprint tickets
Allow cashier to reprint receipts
""",
'author': 'Odoo SA',
@@ -39,6 +39,9 @@ Allow cashier to reprint tickets
'views/templates.xml',
'views/views.xml',
],
'qweb': [
'static/src/xml/reprint.xml',
],
'installable': True,
'website': 'https://www.odoo.com/page/point-of-sale',
'auto_install': False,
+2 -2
View File
@@ -25,8 +25,8 @@ from openerp.osv import fields, osv
class pos_config(osv.osv):
_inherit = 'pos.config'
_columns = {
'reprint': fields.boolean('Reprint Receipt', help='Reprint Receipt'),
'iface_reprint': fields.boolean('Receipt Reprinting', help="This allows you to reprint a previously printed receipt."),
}
_defaults = {
'reprint': False,
'iface_reprint': False,
}
+25 -32
View File
@@ -3,40 +3,33 @@ openerp.pos_reprint = function(instance){
var QWeb = instance.web.qweb;
var _t = instance.web._t;
QWeb.add_template('/pos_reprint/static/src/xml/reprint.xml');
module.PosWidget.include({
build_widgets: function(){
var self = this;
this._super();
this.pos.old_receipt = null;
if(!this.pos.config.reprint) return;
var reprint = $(QWeb.render('ReprintButton'));
reprint.click(function(){
if(self.pos.old_receipt) {
self.pos.proxy.print_receipt(self.pos.old_receipt);
}
else {
self.pos_widget.screen_selector.show_popup("error", {
message: _t("Nothing to Print"),
comment: _t("There is no previous receipt to print."),
});
}
});
reprint.appendTo(this.$('.control-buttons'));
this.$('.control-buttons').removeClass('oe_hidden');
module.ProxyDevice.include({
print_receipt: function(receipt) {
this._super(receipt);
this.pos.old_receipt = receipt || this.pos.old_receipt;
},
});
module.ProxyDevice.include({
print_receipt: function(receipt) {
this.pos.old_receipt = receipt || this.pos.old_receipt;
this._super(receipt);
}
module.ReprintButton = module.ActionButtonWidget.extend({
template: 'ReprintButton',
button_click: function() {
if (this.pos.old_receipt) {
this.pos.proxy.print_receipt(this.pos.old_receipt);
} else {
this.gui.show_popup('error', {
'title': _t('Nothing to Print'),
'body': _t('There is no previous receipt to print.'),
});
}
},
});
};
module.define_action_button({
'name': 'reprint',
'widget': module.ReprintButton,
'condition': function(){
return this.pos.config.iface_reprint && this.pos.config.iface_print_via_proxy;
},
});
};
+1 -1
View File
@@ -2,7 +2,7 @@
<openerp>
<data>
<template id="assets_frontend" inherit_id="web.assets_common">
<template id="assets" inherit_id="point_of_sale.assets">
<xpath expr="." position="inside">
<script type="text/javascript" src="/pos_reprint/static/src/js/reprint.js"></script>
</xpath>
+2 -4
View File
@@ -7,10 +7,8 @@
<field name="model">pos.config</field>
<field name="inherit_id" ref="point_of_sale.view_pos_config_form" />
<field name="arch" type="xml">
<xpath expr="//group[@string='Receipt']" position="after">
<group string="Receipts" col="4" >
<field name='reprint' />
</group>
<xpath expr="//group[@string='Receipt']" position="inside">
<field string="Reprinting" name='iface_reprint' />
</xpath>
</field>
</record>