[REF] pos_reprint: migration to OWL framework
This commit is contained in:
@@ -18,7 +18,9 @@ Allow cashier to reprint receipts
|
||||
'views/pos_config_views.xml'
|
||||
],
|
||||
'qweb': [
|
||||
'static/src/xml/reprint.xml',
|
||||
'static/src/xml/OrderReceipt.xml',
|
||||
'static/src/xml/ReprintButton.xml',
|
||||
'static/src/xml/ReprintScreen.xml',
|
||||
],
|
||||
'installable': True,
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
odoo.define('pos_reprint.OrderReceipt', function(require) {
|
||||
'use strict';
|
||||
|
||||
const OrderReceipt = require('point_of_sale.OrderReceipt');
|
||||
const Registries = require('point_of_sale.Registries');
|
||||
|
||||
const PosReprintOrderReceipt = OrderReceipt =>
|
||||
class extends OrderReceipt {
|
||||
get receiptEnv () {
|
||||
if (this.props.isReprint) {
|
||||
return this.env.pos.last_receipt_render_env;
|
||||
}
|
||||
else {
|
||||
const receipt_render_env = super.receiptEnv;
|
||||
this.env.pos.last_receipt_render_env = receipt_render_env;
|
||||
return receipt_render_env;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Registries.Component.extend(OrderReceipt, PosReprintOrderReceipt);
|
||||
|
||||
return OrderReceipt;
|
||||
});
|
||||
@@ -0,0 +1,37 @@
|
||||
odoo.define('pos_reprint.ReprintButton', function(require) {
|
||||
'use strict';
|
||||
|
||||
const PosComponent = require('point_of_sale.PosComponent');
|
||||
const ProductScreen = require('point_of_sale.ProductScreen');
|
||||
const { useListener } = require('web.custom_hooks');
|
||||
const Registries = require('point_of_sale.Registries');
|
||||
|
||||
class ReprintButton extends PosComponent {
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
useListener('click', this.onClick);
|
||||
}
|
||||
async onClick() {
|
||||
if (this.env.pos.last_receipt_render_env) {
|
||||
await this.showTempScreen('ReprintScreen');
|
||||
} else {
|
||||
await this.showPopup('ErrorPopup', {
|
||||
title: this.env._t('Nothing to Print'),
|
||||
body: this.env._t('There is no previous receipt to print.'),
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
ReprintButton.template = 'ReprintButton';
|
||||
|
||||
ProductScreen.addControlButton({
|
||||
component: ReprintButton,
|
||||
condition: function() {
|
||||
return this.env.pos.config.module_pos_reprint;
|
||||
},
|
||||
});
|
||||
|
||||
Registries.Component.add(ReprintButton);
|
||||
|
||||
return ReprintButton;
|
||||
});
|
||||
@@ -0,0 +1,21 @@
|
||||
odoo.define('pos_reprint.ReprintScreen', function (require) {
|
||||
'use strict';
|
||||
|
||||
const ReceiptScreen = require('point_of_sale.ReceiptScreen');
|
||||
const Registries = require('point_of_sale.Registries');
|
||||
|
||||
const ReprintScreen = (ReceiptScreen) => {
|
||||
class ReprintScreen extends ReceiptScreen {
|
||||
confirm() {
|
||||
this.props.resolve();
|
||||
this.trigger('close-temp-screen');
|
||||
}
|
||||
}
|
||||
ReprintScreen.template = 'ReprintScreen';
|
||||
return ReprintScreen;
|
||||
};
|
||||
|
||||
Registries.Component.addByExtending(ReprintScreen, ReceiptScreen);
|
||||
|
||||
return ReprintScreen;
|
||||
});
|
||||
@@ -1,58 +0,0 @@
|
||||
odoo.define('pos_reprint.pos_reprint', function (require) {
|
||||
"use strict";
|
||||
|
||||
var screens = require('point_of_sale.screens');
|
||||
var gui = require('point_of_sale.gui');
|
||||
var core = require('web.core');
|
||||
|
||||
var _t = core._t;
|
||||
|
||||
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() {
|
||||
this.pos.last_receipt_render_env.receipt.reprint = true;
|
||||
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.last_receipt_render_env) {
|
||||
this.gui.show_screen('reprint_receipt');
|
||||
} else {
|
||||
this.gui.show_popup('error', {
|
||||
'title': _t('Nothing to Print'),
|
||||
'body': _t('There is no previous receipt to print.'),
|
||||
});
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
screens.define_action_button({
|
||||
'name': 'reprint',
|
||||
'widget': ReprintButton,
|
||||
'condition': function(){
|
||||
return this.pos.config.module_pos_reprint;
|
||||
},
|
||||
});
|
||||
|
||||
return {
|
||||
ReprintReceiptScreenWidget: ReprintReceiptScreenWidget,
|
||||
};
|
||||
|
||||
});
|
||||
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<templates id="template" xml:space="preserve">
|
||||
|
||||
<t t-name="OrderReceipt" t-inherit="point_of_sale.OrderReceipt" t-inherit-mode="extension" owl="1">
|
||||
<xpath expr="//div[hasclass('pos-receipt-order-data')]" position="inside">
|
||||
<t t-if="props.isReprint">
|
||||
<div>DUPLICATA</div>
|
||||
</t>
|
||||
</xpath>
|
||||
</t>
|
||||
|
||||
</templates>
|
||||
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<templates id="template" xml:space="preserve">
|
||||
|
||||
<t t-name="ReprintButton" owl="1">
|
||||
<span class="control-button js_reprint">
|
||||
<i class="fa fa-retweet"></i>
|
||||
<span> </span>
|
||||
<span>Reprint Receipt</span>
|
||||
</span>
|
||||
</t>
|
||||
|
||||
</templates>
|
||||
@@ -0,0 +1,29 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<templates id="template" xml:space="preserve">
|
||||
|
||||
<t t-name="ReprintScreen" owl="1">
|
||||
<div class="receipt-screen screen">
|
||||
<div class="screen-content">
|
||||
<div class="top-content">
|
||||
<h1>Last Receipt</h1>
|
||||
<span class="button next highlight" t-on-click="confirm">
|
||||
<span>Ok</span>
|
||||
<span> </span>
|
||||
<i class="fa fa-angle-double-right"></i>
|
||||
</span>
|
||||
</div>
|
||||
<div class="centered-content">
|
||||
<div class="button print" t-on-click="printReceipt">
|
||||
<i class="fa fa-print"></i>
|
||||
<span> </span>
|
||||
<span>Print</span>
|
||||
</div>
|
||||
<div class="pos-receipt-container">
|
||||
<OrderReceipt order="currentOrder" isReprint="true"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</t>
|
||||
|
||||
</templates>
|
||||
@@ -1,27 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<templates id="template" xml:space="preserve">
|
||||
|
||||
<t t-name="ReprintButton">
|
||||
<div class='control-button js_reprint'>
|
||||
<i class="fa fa-retweet"></i> Reprint Receipt
|
||||
</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>
|
||||
|
||||
<t t-extend="OrderReceipt">
|
||||
<t t-jquery='.pos-receipt-order-data' t-operation='append'>
|
||||
<t t-if='receipt.reprint === true'>
|
||||
<div>DUPLICATA</div>
|
||||
</t>
|
||||
</t>
|
||||
</t>
|
||||
|
||||
</templates>
|
||||
@@ -2,7 +2,9 @@
|
||||
<odoo>
|
||||
<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>
|
||||
<script type="text/javascript" src="/pos_reprint/static/src/js/OrderReceipt.js"></script>
|
||||
<script type="text/javascript" src="/pos_reprint/static/src/js/ReprintButton.js"></script>
|
||||
<script type="text/javascript" src="/pos_reprint/static/src/js/ReprintScreen.js"></script>
|
||||
</xpath>
|
||||
</template>
|
||||
</odoo>
|
||||
|
||||
Reference in New Issue
Block a user