diff --git a/pos_disable_pricelist_selection/README.rst b/pos_disable_pricelist_selection/README.rst new file mode 100644 index 0000000000..38929e8775 --- /dev/null +++ b/pos_disable_pricelist_selection/README.rst @@ -0,0 +1,35 @@ +**This file is going to be generated by oca-gen-addon-readme.** + +*Manual changes will be overwritten.* + +Please provide content in the ``readme`` directory: + +* **DESCRIPTION.rst** (required) +* INSTALL.rst (optional) +* CONFIGURE.rst (optional) +* **USAGE.rst** (optional, highly recommended) +* DEVELOP.rst (optional) +* ROADMAP.rst (optional) +* HISTORY.rst (optional, recommended) +* **CONTRIBUTORS.rst** (optional, highly recommended) +* CREDITS.rst (optional) + +Content of this README will also be drawn from the addon manifest, +from keys such as name, authors, maintainers, development_status, +and license. + +A good, one sentence summary in the manifest is also highly recommended. + + +Automatic changelog generation +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`HISTORY.rst` can be auto generated using `towncrier `_. + +Just put towncrier compatible changelog fragments into `readme/newsfragments` +and the changelog file will be automatically generated and updated when a new fragment is added. + +Please refer to `towncrier` documentation to know more. + +NOTE: the changelog will be automatically generated when using `/ocabot merge $option`. +If you need to run it manually, refer to `OCA/maintainer-tools README `_. diff --git a/pos_disable_pricelist_selection/__init__.py b/pos_disable_pricelist_selection/__init__.py new file mode 100644 index 0000000000..0650744f6b --- /dev/null +++ b/pos_disable_pricelist_selection/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/pos_disable_pricelist_selection/__manifest__.py b/pos_disable_pricelist_selection/__manifest__.py new file mode 100644 index 0000000000..0cd54e7afb --- /dev/null +++ b/pos_disable_pricelist_selection/__manifest__.py @@ -0,0 +1,17 @@ +{ + "name": "Disable Pricelist selection button in POS", + "version": "14.0.1.0.0", + "summary": "Disable Pricelist selection button in POS", + "author": "Ooops, Cetmix, Odoo Community Association (OCA)", + "contributors": "Cetmix", + "license": "LGPL-3", + "category": "Purchase", + "website": "https://github.com/OCA/pos", + "depends": ["point_of_sale"], + "external_dependencies": {}, + "demo": [], + "data": ["views/assets.xml", "views/pos_config_view.xml"], + "qweb": ["static/src/xml/ClientDetailsEdit.xml"], + "installable": True, + "application": False, +} diff --git a/pos_disable_pricelist_selection/models/__init__.py b/pos_disable_pricelist_selection/models/__init__.py new file mode 100644 index 0000000000..db8634ade1 --- /dev/null +++ b/pos_disable_pricelist_selection/models/__init__.py @@ -0,0 +1 @@ +from . import pos_config diff --git a/pos_disable_pricelist_selection/models/pos_config.py b/pos_disable_pricelist_selection/models/pos_config.py new file mode 100644 index 0000000000..50931cfba1 --- /dev/null +++ b/pos_disable_pricelist_selection/models/pos_config.py @@ -0,0 +1,9 @@ +from odoo import fields, models + + +class PosConfig(models.Model): + _inherit = "pos.config" + + hide_pricelist_button = fields.Boolean( + default=False, + ) diff --git a/pos_disable_pricelist_selection/readme/CONFIGURE.rst b/pos_disable_pricelist_selection/readme/CONFIGURE.rst new file mode 100644 index 0000000000..0862077f45 --- /dev/null +++ b/pos_disable_pricelist_selection/readme/CONFIGURE.rst @@ -0,0 +1 @@ +* No configuration is required diff --git a/pos_disable_pricelist_selection/readme/CONTRIBUTORS.rst b/pos_disable_pricelist_selection/readme/CONTRIBUTORS.rst new file mode 100644 index 0000000000..a3385a623e --- /dev/null +++ b/pos_disable_pricelist_selection/readme/CONTRIBUTORS.rst @@ -0,0 +1,2 @@ +* Ooops404 +* Cetmix diff --git a/pos_disable_pricelist_selection/readme/DESCRIPTION.rst b/pos_disable_pricelist_selection/readme/DESCRIPTION.rst new file mode 100644 index 0000000000..8d58904f52 --- /dev/null +++ b/pos_disable_pricelist_selection/readme/DESCRIPTION.rst @@ -0,0 +1,4 @@ +Disable Pricelist selection button in POS +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +* Disable Pricelist selection button in POS diff --git a/pos_disable_pricelist_selection/readme/HISTORY.rst b/pos_disable_pricelist_selection/readme/HISTORY.rst new file mode 100644 index 0000000000..f838e0c680 --- /dev/null +++ b/pos_disable_pricelist_selection/readme/HISTORY.rst @@ -0,0 +1,4 @@ +14.0.1.0.0 +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +* Initial release diff --git a/pos_disable_pricelist_selection/readme/USAGE.rst b/pos_disable_pricelist_selection/readme/USAGE.rst new file mode 100644 index 0000000000..e4ee197bca --- /dev/null +++ b/pos_disable_pricelist_selection/readme/USAGE.rst @@ -0,0 +1,3 @@ +* In POS configuration enable multiple pricelists +* There will be a checkbox "Hide Pricelist Button" +* If checked pricelist selection button will be hidden in POS Screen diff --git a/pos_disable_pricelist_selection/static/description/icon.png b/pos_disable_pricelist_selection/static/description/icon.png new file mode 100644 index 0000000000..3a0328b516 Binary files /dev/null and b/pos_disable_pricelist_selection/static/description/icon.png differ diff --git a/pos_disable_pricelist_selection/static/src/js/ProductScreen.js b/pos_disable_pricelist_selection/static/src/js/ProductScreen.js new file mode 100644 index 0000000000..6485ae9c02 --- /dev/null +++ b/pos_disable_pricelist_selection/static/src/js/ProductScreen.js @@ -0,0 +1,28 @@ +odoo.define("pos_disable_pricelist_selection.ProductScreen", function (require) { + "use strict"; + + const ProductScreen = require("point_of_sale.ProductScreen"); + const Registries = require("point_of_sale.Registries"); + + const PosProductScreen = (ProductScreen) => + class extends ProductScreen { + constructor() { + super(...arguments); + _.each(this.constructor.controlButtons, function (button) { + if (button.name === "SetPricelistButton") { + button.condition = function () { + return ( + this.env.pos.config.use_pricelist && + this.env.pos.pricelists.length > 1 && + !this.env.pos.config.hide_pricelist_button + ); + }; + } + }); + } + }; + + Registries.Component.extend(ProductScreen, PosProductScreen); + + return ProductScreen; +}); diff --git a/pos_disable_pricelist_selection/static/src/xml/ClientDetailsEdit.xml b/pos_disable_pricelist_selection/static/src/xml/ClientDetailsEdit.xml new file mode 100644 index 0000000000..a1aca8fa6f --- /dev/null +++ b/pos_disable_pricelist_selection/static/src/xml/ClientDetailsEdit.xml @@ -0,0 +1,20 @@ + + + + + + env.pos.pricelists.length gt 1 and !env.pos.config.hide_pricelist_button + + + + diff --git a/pos_disable_pricelist_selection/views/assets.xml b/pos_disable_pricelist_selection/views/assets.xml new file mode 100644 index 0000000000..e4cde6aab1 --- /dev/null +++ b/pos_disable_pricelist_selection/views/assets.xml @@ -0,0 +1,11 @@ + + +