[IMP] point_of_sale,pos_reprint: allow reprinting without POSBox
Closes #16452
This commit is contained in:
@@ -1452,19 +1452,23 @@ var ReceiptScreenWidget = ScreenWidget.extend({
|
||||
this.$('.next').addClass('highlight');
|
||||
}
|
||||
},
|
||||
get_receipt_render_env: function() {
|
||||
var order = this.pos.get_order();
|
||||
return {
|
||||
widget: this,
|
||||
pos: this.pos,
|
||||
order: order,
|
||||
receipt: order.export_for_printing(),
|
||||
orderlines: order.get_orderlines(),
|
||||
paymentlines: order.get_paymentlines(),
|
||||
};
|
||||
},
|
||||
print_web: function() {
|
||||
window.print();
|
||||
this.pos.get_order()._printed = true;
|
||||
},
|
||||
print_xml: function() {
|
||||
var env = {
|
||||
widget: this,
|
||||
pos: this.pos,
|
||||
order: this.pos.get_order(),
|
||||
receipt: this.pos.get_order().export_for_printing(),
|
||||
paymentlines: this.pos.get_order().get_paymentlines()
|
||||
};
|
||||
var receipt = QWeb.render('XmlReceipt',env);
|
||||
var receipt = QWeb.render('XmlReceipt', this.get_receipt_render_env());
|
||||
|
||||
this.pos.proxy.print_receipt(receipt);
|
||||
this.pos.get_order()._printed = true;
|
||||
@@ -1532,14 +1536,7 @@ var ReceiptScreenWidget = ScreenWidget.extend({
|
||||
this.$('.change-value').html(this.format_currency(this.pos.get_order().get_change()));
|
||||
},
|
||||
render_receipt: function() {
|
||||
var order = this.pos.get_order();
|
||||
this.$('.pos-receipt-container').html(QWeb.render('PosTicket',{
|
||||
widget:this,
|
||||
order: order,
|
||||
receipt: order.export_for_printing(),
|
||||
orderlines: order.get_orderlines(),
|
||||
paymentlines: order.get_paymentlines(),
|
||||
}));
|
||||
this.$('.pos-receipt-container').html(QWeb.render('PosTicket', this.get_receipt_render_env()));
|
||||
},
|
||||
});
|
||||
gui.define_screen({name:'receipt', widget: ReceiptScreenWidget});
|
||||
|
||||
@@ -8,13 +8,3 @@ class PosConfig(models.Model):
|
||||
|
||||
iface_reprint = fields.Boolean(
|
||||
string='Receipt Reprinting', help="This allows you to reprint a previously printed receipt.")
|
||||
|
||||
@api.onchange('iface_reprint')
|
||||
def _onchange_iface_print(self):
|
||||
if self.iface_reprint:
|
||||
self.iface_print_via_proxy = self.iface_reprint
|
||||
|
||||
@api.onchange('iface_print_via_proxy')
|
||||
def _onchange_iface_print_via_proxy(self):
|
||||
super(PosConfig, self)._onchange_iface_print_via_proxy()
|
||||
self.iface_reprint = self.iface_print_via_proxy if self.iface_reprint else None
|
||||
|
||||
@@ -1,24 +1,38 @@
|
||||
odoo.define('pos_reprint.pos_reprint', function (require) {
|
||||
"use strict";
|
||||
|
||||
var devices = require('point_of_sale.devices');
|
||||
var screens = require('point_of_sale.screens');
|
||||
var gui = require('point_of_sale.gui');
|
||||
var core = require('web.core');
|
||||
|
||||
var _t = core._t;
|
||||
|
||||
devices.ProxyDevice.include({
|
||||
print_receipt: function(receipt) {
|
||||
this._super(receipt);
|
||||
this.pos.old_receipt = receipt || this.pos.old_receipt;
|
||||
screens.ReceiptScreenWidget.include({
|
||||
get_receipt_render_env: function() {
|
||||
this.pos.last_receipt_render_env = this._super();
|
||||
return this.pos.last_receipt_render_env;
|
||||
}
|
||||
});
|
||||
|
||||
var ReprintReceiptScreenWidget = screens.ReceiptScreenWidget.extend({
|
||||
template: 'ReprintReceiptScreenWidget',
|
||||
render_change: function() {},
|
||||
click_next: function() {},
|
||||
click_back: function() {
|
||||
this._super();
|
||||
this.gui.show_screen('products');
|
||||
},
|
||||
get_receipt_render_env: function() {
|
||||
return this.pos.last_receipt_render_env;
|
||||
},
|
||||
});
|
||||
gui.define_screen({name:'reprint_receipt', widget: ReprintReceiptScreenWidget});
|
||||
|
||||
var ReprintButton = screens.ActionButtonWidget.extend({
|
||||
template: 'ReprintButton',
|
||||
button_click: function() {
|
||||
if (this.pos.old_receipt) {
|
||||
this.pos.proxy.print_receipt(this.pos.old_receipt);
|
||||
if (this.pos.last_receipt_render_env) {
|
||||
this.gui.show_screen('reprint_receipt');
|
||||
} else {
|
||||
this.gui.show_popup('error', {
|
||||
'title': _t('Nothing to Print'),
|
||||
@@ -31,9 +45,13 @@ var ReprintButton = screens.ActionButtonWidget.extend({
|
||||
screens.define_action_button({
|
||||
'name': 'reprint',
|
||||
'widget': ReprintButton,
|
||||
'condition': function(){
|
||||
return this.pos.config.iface_reprint && this.pos.config.iface_print_via_proxy;
|
||||
'condition': function() {
|
||||
return this.pos.config.iface_reprint;
|
||||
},
|
||||
});
|
||||
|
||||
return {
|
||||
ReprintReceiptScreenWidget: ReprintReceiptScreenWidget,
|
||||
};
|
||||
|
||||
});
|
||||
|
||||
@@ -7,4 +7,13 @@
|
||||
</div>
|
||||
</t>
|
||||
|
||||
<t t-name="ReprintReceiptScreenWidget" t-extend="ReceiptScreenWidget">
|
||||
<t t-jquery="div.top-content" t-operation="inner">
|
||||
<span class='button back'>
|
||||
<i class='fa fa-angle-double-left'></i>
|
||||
Back
|
||||
</span>
|
||||
</t>
|
||||
</t>
|
||||
|
||||
</templates>
|
||||
|
||||
Reference in New Issue
Block a user