diff --git a/.copier-answers.yml b/.copier-answers.yml index c9ebfe4..7e620d4 100644 --- a/.copier-answers.yml +++ b/.copier-answers.yml @@ -1,5 +1,5 @@ # Do NOT update manually; changes here will be overwritten by Copier -_commit: ea28867 +_commit: b8281af _src_path: /opt/odoo-projects/var/addons-repo-template/ ci: GitHub convert_readme_fragments_to_markdown: false @@ -18,8 +18,8 @@ org_slug: it-projects-llc rebel_module_groups: [] repo_description: '' repo_name: POS Addons -repo_slug: pos-addons2 -repo_website: https://github.com/it-projects-llc/pos-addons2 +repo_slug: pos-addons +repo_website: https://github.com/it-projects-llc/pos-addons use_pyproject_toml: false use_ruff: false diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d05086f..6e8c639 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -16,6 +16,8 @@ exclude: | readme/.*\.(rst|md)$| # Ignore build and dist directories in addons /build/|/dist/| + # Ignore test files in addons + /tests/samples/*| # You don't usually want a bot to modify your legal texts (LICENSE.*|COPYING.*) default_language_version: @@ -37,20 +39,21 @@ repos: language: fail files: '[a-zA-Z0-9_]*/i18n/en\.po$' - repo: https://github.com/oca/maintainer-tools - rev: f71041f22b8cd68cf7c77b73a14ca8d8cd190a60 + rev: 9a170331575a265c092ee6b24b845ec508e8ef75 hooks: # update the NOT INSTALLABLE ADDONS section above - id: oca-update-pre-commit-excluded-addons - id: oca-fix-manifest-website - args: ["https://github.com/it-projects-llc/pos-addons2"] + args: ["https://github.com/it-projects-llc/pos-addons"] - id: oca-gen-addon-readme args: - --addons-dir=. - --branch=15.0 - --org-name=it-projects-llc - - --repo-name=pos-addons2 + - --repo-name=pos-addons - --if-source-changed - --keep-source-digest + - --convert-fragments-to-markdown - repo: https://github.com/OCA/odoo-pre-commit-hooks rev: v0.0.25 hooks: diff --git a/README.md b/README.md index 91c982f..fc6ad34 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ -[![Pre-commit Status](https://github.com/it-projects-llc/pos-addons2/actions/workflows/pre-commit.yml/badge.svg?branch=15.0)](https://github.com/it-projects-llc/pos-addons2/actions/workflows/pre-commit.yml?query=branch%3A15.0) -[![Build Status](https://github.com/it-projects-llc/pos-addons2/actions/workflows/test.yml/badge.svg?branch=15.0)](https://github.com/it-projects-llc/pos-addons2/actions/workflows/test.yml?query=branch%3A15.0) -[![codecov](https://codecov.io/gh/it-projects-llc/pos-addons2/branch/15.0/graph/badge.svg)](https://codecov.io/gh/it-projects-llc/pos-addons2) +[![Pre-commit Status](https://github.com/it-projects-llc/pos-addons/actions/workflows/pre-commit.yml/badge.svg?branch=15.0)](https://github.com/it-projects-llc/pos-addons/actions/workflows/pre-commit.yml?query=branch%3A15.0) +[![Build Status](https://github.com/it-projects-llc/pos-addons/actions/workflows/test.yml/badge.svg?branch=15.0)](https://github.com/it-projects-llc/pos-addons/actions/workflows/test.yml?query=branch%3A15.0) +[![codecov](https://codecov.io/gh/it-projects-llc/pos-addons/branch/15.0/graph/badge.svg)](https://codecov.io/gh/it-projects-llc/pos-addons) diff --git a/pos_discount_total/README.rst b/pos_discount_total/README.rst new file mode 100644 index 0000000..54d1984 --- /dev/null +++ b/pos_discount_total/README.rst @@ -0,0 +1,66 @@ +=================== +POS: Total discount +=================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:485fd26d3dca364de0dcb3d89209eaf69b131abdcb9fe0d146f0dc660f20c6be + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/licence-LGPL--3-blue.png + :target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html + :alt: License: LGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-it--projects--llc%2Fpos--addons-lightgray.png?logo=github + :target: https://github.com/it-projects-llc/pos-addons/tree/15.0/pos_discount_total + :alt: it-projects-llc/pos-addons + +|badge1| |badge2| |badge3| + +The module allows make discount for whole order. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +Just select total line and type discount at numpad as usual. The module +will apply discount for all items. + +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 +------- + +* IT-Projects LLC + +Contributors +------------ + +- Eugene Molotov (https://github.com/em230418) + +Maintainers +----------- + +This module is part of the `it-projects-llc/pos-addons `_ project on GitHub. + +You are welcome to contribute. diff --git a/pos_discount_total/__init__.py b/pos_discount_total/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/pos_discount_total/__manifest__.py b/pos_discount_total/__manifest__.py new file mode 100644 index 0000000..2cb3dbc --- /dev/null +++ b/pos_discount_total/__manifest__.py @@ -0,0 +1,25 @@ +{ + "name": """POS: Total discount""", + "version": "15.0.0.1.0", + "author": "IT-Projects LLC", + "support": "it@it-projects.info", + "website": "https://github.com/it-projects-llc/pos-addons", + "license": "LGPL-3", + "depends": [ + "point_of_sale", + ], + "assets": { + "point_of_sale.assets": [ + "pos_discount_total/static/src/css/pos.css", + "pos_discount_total/static/src/js/Screens/ProductScreen/OrderSummary.js", + "pos_discount_total/static/src/js/Screens/ProductScreen/OrderWidget.js", + "pos_discount_total/static/src/js/Screens/ProductScreen/ProductScreen.js", + ], + "web.assets_qweb": [ + "pos_discount_total/static/src/xml/**/*", + ], + "web.assets_tests": [ + "pos_discount_total/static/tests/**/*", + ], + }, +} diff --git a/pos_discount_total/readme/CONTRIBUTORS.md b/pos_discount_total/readme/CONTRIBUTORS.md new file mode 100644 index 0000000..2c1a2f5 --- /dev/null +++ b/pos_discount_total/readme/CONTRIBUTORS.md @@ -0,0 +1 @@ + - Eugene Molotov (https://github.com/em230418) diff --git a/pos_discount_total/readme/DESCRIPTION.md b/pos_discount_total/readme/DESCRIPTION.md new file mode 100644 index 0000000..26ca8c8 --- /dev/null +++ b/pos_discount_total/readme/DESCRIPTION.md @@ -0,0 +1 @@ +The module allows make discount for whole order. diff --git a/pos_discount_total/readme/USAGE.md b/pos_discount_total/readme/USAGE.md new file mode 100644 index 0000000..9392071 --- /dev/null +++ b/pos_discount_total/readme/USAGE.md @@ -0,0 +1,2 @@ +Just select total line and type discount at numpad as usual. +The module will apply discount for all items. diff --git a/pos_discount_total/static/description/index.html b/pos_discount_total/static/description/index.html new file mode 100644 index 0000000..f2f425c --- /dev/null +++ b/pos_discount_total/static/description/index.html @@ -0,0 +1,421 @@ + + + + + +POS: Total discount + + + +
+

POS: Total discount

+ + +

Beta License: LGPL-3 it-projects-llc/pos-addons

+

The module allows make discount for whole order.

+

Table of contents

+ +
+

Usage

+

Just select total line and type discount at numpad as usual. The module +will apply discount for all items.

+
+
+

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

+
    +
  • IT-Projects LLC
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is part of the it-projects-llc/pos-addons project on GitHub.

+

You are welcome to contribute.

+
+
+
+ + diff --git a/pos_discount_total/static/src/css/pos.css b/pos_discount_total/static/src/css/pos.css new file mode 100644 index 0000000..2969498 --- /dev/null +++ b/pos_discount_total/static/src/css/pos.css @@ -0,0 +1,11 @@ +.pos .order .summary { + cursor: pointer; +} + +.pos .order .summary.selected { + background: rgba(140, 143, 183, 0.2); + -webkit-transition: background 250ms ease-in-out; + -moz-transition: background 250ms ease-in-out; + transition: background 250ms ease-in-out; + cursor: default; +} diff --git a/pos_discount_total/static/src/js/Screens/ProductScreen/OrderSummary.js b/pos_discount_total/static/src/js/Screens/ProductScreen/OrderSummary.js new file mode 100644 index 0000000..3b3dcef --- /dev/null +++ b/pos_discount_total/static/src/js/Screens/ProductScreen/OrderSummary.js @@ -0,0 +1,19 @@ +odoo.define("pos_discount_total.OrderSummary", function (require) { + "use strict"; + + const OrderSummary = require("point_of_sale.OrderSummary"); + const Registries = require("point_of_sale.Registries"); + + const POSDiscountTotalOrderSummary = (x) => + class extends x { + get addedClasses() { + return { + selected: this.props.selected, + }; + } + }; + + Registries.Component.extend(OrderSummary, POSDiscountTotalOrderSummary); + + return POSDiscountTotalOrderSummary; +}); diff --git a/pos_discount_total/static/src/js/Screens/ProductScreen/OrderWidget.js b/pos_discount_total/static/src/js/Screens/ProductScreen/OrderWidget.js new file mode 100644 index 0000000..0f965b7 --- /dev/null +++ b/pos_discount_total/static/src/js/Screens/ProductScreen/OrderWidget.js @@ -0,0 +1,29 @@ +odoo.define("pos_discount_total.OrderWidget", function (require) { + "use strict"; + + const OrderWidget = require("point_of_sale.OrderWidget"); + const Registries = require("point_of_sale.Registries"); + const {useListener} = require("web.custom_hooks"); + + const POSDiscountTotalOrderWidget = (x) => + class extends x { + constructor() { + super(...arguments); + useListener("select-summary", this._selectSummary); + } + + _selectSummary() { + this.order.deselect_orderline(); + this.state.isSummarySelected = true; + } + + _selectLine() { + super._selectLine(...arguments); + this.state.isSummarySelected = false; + } + }; + + Registries.Component.extend(OrderWidget, POSDiscountTotalOrderWidget); + + return POSDiscountTotalOrderWidget; +}); diff --git a/pos_discount_total/static/src/js/Screens/ProductScreen/ProductScreen.js b/pos_discount_total/static/src/js/Screens/ProductScreen/ProductScreen.js new file mode 100644 index 0000000..2f5950a --- /dev/null +++ b/pos_discount_total/static/src/js/Screens/ProductScreen/ProductScreen.js @@ -0,0 +1,24 @@ +odoo.define("pos_discount_total.ProductScreen", function (require) { + "use strict"; + + const ProductScreen = require("point_of_sale.ProductScreen"); + const Registries = require("point_of_sale.Registries"); + + const POSDiscountTotalProductScreen = (x) => + class extends x { + _setValue(val) { + if (!this.currentOrder.get_selected_orderline()) { + if (this.state.numpadMode === "discount") { + this.currentOrder.orderlines.models.forEach((model) => { + model.set_discount(val); + }); + } + } + return super._setValue(...arguments); + } + }; + + Registries.Component.extend(ProductScreen, POSDiscountTotalProductScreen); + + return POSDiscountTotalProductScreen; +}); diff --git a/pos_discount_total/static/src/xml/Screens/ProductScreen/OrderSummary.xml b/pos_discount_total/static/src/xml/Screens/ProductScreen/OrderSummary.xml new file mode 100644 index 0000000..c4fcd3e --- /dev/null +++ b/pos_discount_total/static/src/xml/Screens/ProductScreen/OrderSummary.xml @@ -0,0 +1,14 @@ + + + + + trigger('select-summary') + addedClasses + + + diff --git a/pos_discount_total/static/src/xml/Screens/ProductScreen/OrderWidget.xml b/pos_discount_total/static/src/xml/Screens/ProductScreen/OrderWidget.xml new file mode 100644 index 0000000..6b1d824 --- /dev/null +++ b/pos_discount_total/static/src/xml/Screens/ProductScreen/OrderWidget.xml @@ -0,0 +1,13 @@ + + + + + state.isSummarySelected + + + diff --git a/pos_discount_total/static/tests/helpers/ProductScreenTourMethods.js b/pos_discount_total/static/tests/helpers/ProductScreenTourMethods.js new file mode 100644 index 0000000..8fd23e2 --- /dev/null +++ b/pos_discount_total/static/tests/helpers/ProductScreenTourMethods.js @@ -0,0 +1,33 @@ +odoo.define("pos_discount_total.tour.ProductScreenTourMethods", function (require) { + "use strict"; + + const {createTourMethods} = require("point_of_sale.tour.utils"); + const {Do, Check, Execute} = require("point_of_sale.tour.ProductScreenTourMethods"); + + class DoExt extends Do { + clickSummaryLine() { + return [ + { + content: "click summary line", + trigger: ".summary", + run: "click", + }, + ]; + } + } + + class CheckExt extends Check { + isSummarySelected() { + return [ + { + content: "is summary selected", + trigger: ".summary.selected", + // eslint-disable-next-line no-empty-function + run: () => {}, + }, + ]; + } + } + + return createTourMethods("ProductScreen", DoExt, CheckExt, Execute); +}); diff --git a/pos_discount_total/static/tests/tours.js b/pos_discount_total/static/tests/tours.js new file mode 100644 index 0000000..ecc8419 --- /dev/null +++ b/pos_discount_total/static/tests/tours.js @@ -0,0 +1,34 @@ +odoo.define("pos_discount_total.tour", function (require) { + "use strict"; + + const {ProductScreen} = require("pos_discount_total.tour.ProductScreenTourMethods"); + const {getSteps, startSteps} = require("point_of_sale.tour.utils"); + var Tour = require("web_tour.tour"); + + // Signal to start generating steps + // when finished, steps can be taken from getSteps + startSteps(); + + // Go by default to home category + ProductScreen.do.clickHomeCategory(); + + ProductScreen.do.clickDisplayedProduct("Desk Organizer"); + ProductScreen.check.selectedOrderlineHas("Desk Organizer", "1.0", "5.10"); + + ProductScreen.do.clickDisplayedProduct("Letter Tray"); + ProductScreen.check.selectedOrderlineHas("Letter Tray", "1.0", "4.80"); + + ProductScreen.do.clickSummaryLine(); + ProductScreen.check.isSummarySelected(); + + ProductScreen.do.pressNumpad("Disc"); + ProductScreen.do.pressNumpad("9 0 ."); + ProductScreen.check.isSummarySelected(); + + ProductScreen.do.clickOrderline("Desk Organizer", "1.0"); + ProductScreen.check.selectedOrderlineHas("Desk Organizer", "1.0", "0.51"); + ProductScreen.do.clickOrderline("Letter Tray", "1.0"); + ProductScreen.check.selectedOrderlineHas("Letter Tray", "1.0", "0.48"); + + Tour.register("pos_discount_total_tour", {test: true, url: "/pos/ui"}, getSteps()); +}); diff --git a/pos_discount_total/tests/__init__.py b/pos_discount_total/tests/__init__.py new file mode 100644 index 0000000..6c9812d --- /dev/null +++ b/pos_discount_total/tests/__init__.py @@ -0,0 +1 @@ +from . import test_main diff --git a/pos_discount_total/tests/test_main.py b/pos_discount_total/tests/test_main.py new file mode 100644 index 0000000..c1a72fd --- /dev/null +++ b/pos_discount_total/tests/test_main.py @@ -0,0 +1,17 @@ +from odoo.tests.common import tagged + +from odoo.addons.point_of_sale.tests.test_frontend import TestPointOfSaleHttpCommon + + +@tagged("post_install", "-at_install") +class TestUi(TestPointOfSaleHttpCommon): + def test_01_main(self): + # open a session, the /pos/ui controller will redirect to it + self.main_pos_config.open_session_cb(check_coa=False) + + self.start_tour( + "/pos/ui?config_id=%d" % self.main_pos_config.id, + "pos_discount_total_tour", + 500, + login="accountman", + ) diff --git a/setup/pos_discount_total/odoo/addons/pos_discount_total b/setup/pos_discount_total/odoo/addons/pos_discount_total new file mode 120000 index 0000000..4572080 --- /dev/null +++ b/setup/pos_discount_total/odoo/addons/pos_discount_total @@ -0,0 +1 @@ +../../../../pos_discount_total \ No newline at end of file diff --git a/setup/pos_discount_total/setup.py b/setup/pos_discount_total/setup.py new file mode 100644 index 0000000..28c57bb --- /dev/null +++ b/setup/pos_discount_total/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)