summaryrefslogtreecommitdiff
path: root/addons/point_of_sale/static/src/js/ChromeWidgets/SaleDetailsButton.js
diff options
context:
space:
mode:
Diffstat (limited to 'addons/point_of_sale/static/src/js/ChromeWidgets/SaleDetailsButton.js')
-rw-r--r--addons/point_of_sale/static/src/js/ChromeWidgets/SaleDetailsButton.js38
1 files changed, 38 insertions, 0 deletions
diff --git a/addons/point_of_sale/static/src/js/ChromeWidgets/SaleDetailsButton.js b/addons/point_of_sale/static/src/js/ChromeWidgets/SaleDetailsButton.js
new file mode 100644
index 00000000..e646547e
--- /dev/null
+++ b/addons/point_of_sale/static/src/js/ChromeWidgets/SaleDetailsButton.js
@@ -0,0 +1,38 @@
+odoo.define('point_of_sale.SaleDetailsButton', function(require) {
+ 'use strict';
+
+ const PosComponent = require('point_of_sale.PosComponent');
+ const Registries = require('point_of_sale.Registries');
+
+ class SaleDetailsButton extends PosComponent {
+ async onClick() {
+ // IMPROVEMENT: Perhaps put this logic in a parent component
+ // so that for unit testing, we can check if this simple
+ // component correctly triggers an event.
+ const saleDetails = await this.rpc({
+ model: 'report.point_of_sale.report_saledetails',
+ method: 'get_sale_details',
+ args: [false, false, false, [this.env.pos.pos_session.id]],
+ });
+ const report = this.env.qweb.renderToString(
+ 'SaleDetailsReport',
+ Object.assign({}, saleDetails, {
+ date: new Date().toLocaleString(),
+ pos: this.env.pos,
+ })
+ );
+ const printResult = await this.env.pos.proxy.printer.print_receipt(report);
+ if (!printResult.successful) {
+ await this.showPopup('ErrorPopup', {
+ title: printResult.message.title,
+ body: printResult.message.body,
+ });
+ }
+ }
+ }
+ SaleDetailsButton.template = 'SaleDetailsButton';
+
+ Registries.Component.add(SaleDetailsButton);
+
+ return SaleDetailsButton;
+});