From 5b2790b6c4424f09788be6d0afdef30138acee3a Mon Sep 17 00:00:00 2001 From: LorenzoC0 Date: Mon, 14 Oct 2024 15:13:30 +0200 Subject: [PATCH 1/2] [ADD] pos_full_refund: Added module to autocomplete full refunds on ticket screen. --- pos_full_refund/README.rst | 94 ++++ pos_full_refund/__manifest__.py | 19 + pos_full_refund/readme/CONTRIBUTORS.md | 4 + pos_full_refund/readme/DESCRIPTION.md | 1 + pos_full_refund/static/description/index.html | 437 ++++++++++++++++++ .../static/src/js/pos_full_refund.js | 19 + .../static/src/xml/pos_full_refund.xml | 21 + setup/_metapackage/pyproject.toml | 20 - 8 files changed, 595 insertions(+), 20 deletions(-) create mode 100644 pos_full_refund/README.rst create mode 100644 pos_full_refund/__manifest__.py create mode 100644 pos_full_refund/readme/CONTRIBUTORS.md create mode 100644 pos_full_refund/readme/DESCRIPTION.md create mode 100644 pos_full_refund/static/description/index.html create mode 100644 pos_full_refund/static/src/js/pos_full_refund.js create mode 100644 pos_full_refund/static/src/xml/pos_full_refund.xml delete mode 100644 setup/_metapackage/pyproject.toml diff --git a/pos_full_refund/README.rst b/pos_full_refund/README.rst new file mode 100644 index 0000000000..7e32c71168 --- /dev/null +++ b/pos_full_refund/README.rst @@ -0,0 +1,94 @@ +================ +Point of Sale - +================ + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:cc92aeed4d5986a6c3a0e7860d32d67c2aceec105975c3a9ffca2caab7ae128f + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Alpha-red.png + :target: https://odoo-community.org/page/development-status + :alt: Alpha +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fpos-lightgray.png?logo=github + :target: https://github.com/OCA/pos/tree/17.0/pos_full_refund + :alt: OCA/pos +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/pos-17-0/pos-17-0-pos_full_refund + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png + :target: https://runboat.odoo-community.org/builds?repo=OCA/pos&target_branch=17.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module adds a new button in the ticket screen to automatically add +the lines of the selected order and returns to the main screen. + +.. IMPORTANT:: + This is an alpha version, the data model and design can change at any time without warning. + Only for development or testing purpose, do not use in production. + `More details on development status `_ + +**Table of contents** + +.. contents:: + :local: + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us to smash it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +------- + +* Innovyou + +Contributors +------------ + +- [Innovyou] (https://www.innovyou.it): + + - Lorenzo Carta + - Lorenzo Battistini + - Valerio Paretta + +Maintainers +----------- + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +.. |maintainer-LorenzoC0| image:: https://github.com/LorenzoC0.png?size=40px + :target: https://github.com/LorenzoC0 + :alt: LorenzoC0 + +Current `maintainer `__: + +|maintainer-LorenzoC0| + +This module is part of the `OCA/pos `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/pos_full_refund/__manifest__.py b/pos_full_refund/__manifest__.py new file mode 100644 index 0000000000..7d25d13d6c --- /dev/null +++ b/pos_full_refund/__manifest__.py @@ -0,0 +1,19 @@ +{ + "name": "Point of Sale - ", + "summary": "Short (1 phrase/line) summary of the module's purpose", + "author": "Innovyou, Odoo Community Association (OCA)", + "website": "https://github.com/OCA/pos", + "development_status": "Alpha", + "category": "Point of sale", + "maintainers": ["LorenzoC0"], + "version": "17.0.1.0.0", + "license": "AGPL-3", + "installable": True, + "depends": ["point_of_sale"], + "assets": { + "point_of_sale._assets_pos": [ + "pos_full_refund/static/src/js/pos_full_refund.js", + "pos_full_refund/static/src/xml/pos_full_refund.xml", + ], + }, +} diff --git a/pos_full_refund/readme/CONTRIBUTORS.md b/pos_full_refund/readme/CONTRIBUTORS.md new file mode 100644 index 0000000000..85e9d7f0dd --- /dev/null +++ b/pos_full_refund/readme/CONTRIBUTORS.md @@ -0,0 +1,4 @@ +- [Innovyou] (https://www.innovyou.it): + - Lorenzo Carta + - Lorenzo Battistini + - Valerio Paretta \ No newline at end of file diff --git a/pos_full_refund/readme/DESCRIPTION.md b/pos_full_refund/readme/DESCRIPTION.md new file mode 100644 index 0000000000..c2936156a7 --- /dev/null +++ b/pos_full_refund/readme/DESCRIPTION.md @@ -0,0 +1 @@ +This module adds a new button in the ticket screen to automatically add the lines of the selected order and returns to the main screen. \ No newline at end of file diff --git a/pos_full_refund/static/description/index.html b/pos_full_refund/static/description/index.html new file mode 100644 index 0000000000..5a233b6d9c --- /dev/null +++ b/pos_full_refund/static/description/index.html @@ -0,0 +1,437 @@ + + + + + +Point of Sale - + + + +
+

Point of Sale -

+ + +

Alpha License: AGPL-3 OCA/pos Translate me on Weblate Try me on Runboat

+

This module adds a new button in the ticket screen to automatically add +the lines of the selected order and returns to the main screen.

+
+

Important

+

This is an alpha version, the data model and design can change at any time without warning. +Only for development or testing purpose, do not use in production. +More details on development status

+
+

Table of contents

+ +
+

Bug Tracker

+

Bugs are tracked on GitHub Issues. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us to smash it by providing a detailed and welcomed +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • Innovyou
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+ +Odoo Community Association + +

OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use.

+

Current maintainer:

+

LorenzoC0

+

This module is part of the OCA/pos project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/pos_full_refund/static/src/js/pos_full_refund.js b/pos_full_refund/static/src/js/pos_full_refund.js new file mode 100644 index 0000000000..5de59c2fd4 --- /dev/null +++ b/pos_full_refund/static/src/js/pos_full_refund.js @@ -0,0 +1,19 @@ +/** @odoo-module **/ + +import {TicketScreen} from "@point_of_sale/app/screens/ticket_screen/ticket_screen"; +import {_t} from "@web/core/l10n/translation"; +import {patch} from "@web/core/utils/patch"; + +patch(TicketScreen.prototype, { + onDoFullRefund() { + var selected_order = this.getSelectedOrder(); + for (const line of selected_order.orderlines) { + this.onClickOrderline(line); + for (const char of line.quantity.toString()) { + this._onUpdateSelectedOrderline({key: char, buffer: char}); + } + } + var pay_button = document.querySelector(".pay"); + pay_button.click(); + }, +}); diff --git a/pos_full_refund/static/src/xml/pos_full_refund.xml b/pos_full_refund/static/src/xml/pos_full_refund.xml new file mode 100644 index 0000000000..eba4ae8382 --- /dev/null +++ b/pos_full_refund/static/src/xml/pos_full_refund.xml @@ -0,0 +1,21 @@ + + + + + + + + + + diff --git a/setup/_metapackage/pyproject.toml b/setup/_metapackage/pyproject.toml deleted file mode 100644 index daf9e65773..0000000000 --- a/setup/_metapackage/pyproject.toml +++ /dev/null @@ -1,20 +0,0 @@ -[project] -name = "odoo-addons-oca-pos" -version = "17.0.20241001.0" -dependencies = [ - "odoo-addon-pos_hide_cost_price_and_margin>=17.0dev,<17.1dev", - "odoo-addon-pos_lot_barcode>=17.0dev,<17.1dev", - "odoo-addon-pos_lot_selection>=17.0dev,<17.1dev", - "odoo-addon-pos_order_to_sale_order>=17.0dev,<17.1dev", - "odoo-addon-pos_partner_birthdate>=17.0dev,<17.1dev", - "odoo-addon-pos_partner_firstname>=17.0dev,<17.1dev", - "odoo-addon-pos_partner_ref>=17.0dev,<17.1dev", - "odoo-addon-pos_partner_second_lastname>=17.0dev,<17.1dev", - "odoo-addon-pos_product_expiry>=17.0dev,<17.1dev", - "odoo-addon-pos_product_template>=17.0dev,<17.1dev", -] -classifiers=[ - "Programming Language :: Python", - "Framework :: Odoo", - "Framework :: Odoo :: 17.0", -] From 687cd63c47cbdd9a40d4d96901005261390ea17e Mon Sep 17 00:00:00 2001 From: VPA Date: Tue, 12 Nov 2024 17:13:52 +0100 Subject: [PATCH 2/2] FIX corrected the refund process when pressed the Do full refund button if the quantity is lesser than 1 --- pos_full_refund/static/src/js/pos_full_refund.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/pos_full_refund/static/src/js/pos_full_refund.js b/pos_full_refund/static/src/js/pos_full_refund.js index 5de59c2fd4..d0a773392f 100644 --- a/pos_full_refund/static/src/js/pos_full_refund.js +++ b/pos_full_refund/static/src/js/pos_full_refund.js @@ -8,12 +8,14 @@ patch(TicketScreen.prototype, { onDoFullRefund() { var selected_order = this.getSelectedOrder(); for (const line of selected_order.orderlines) { - this.onClickOrderline(line); - for (const char of line.quantity.toString()) { - this._onUpdateSelectedOrderline({key: char, buffer: char}); + const toRefundDetails = line + .getAllLinesInCombo() + .map((line) => this._getToRefundDetail(line)); + for (const toRefundDetail of toRefundDetails) { + toRefundDetail.qty = line.quantity; } } var pay_button = document.querySelector(".pay"); pay_button.click(); }, -}); +}); \ No newline at end of file