From 1f6fffd45c29382145246a2ac8a7a93105cdb62b Mon Sep 17 00:00:00 2001 From: trisdoan Date: Fri, 26 Apr 2024 15:53:30 +0700 Subject: [PATCH] [MIG] pos_hide_cost_price_and_margin: Migration to 17.0 --- pos_hide_cost_price_and_margin/README.rst | 15 +++-- pos_hide_cost_price_and_margin/__init__.py | 1 + .../__manifest__.py | 10 ++-- pos_hide_cost_price_and_margin/i18n/es.po | 24 -------- pos_hide_cost_price_and_margin/i18n/it.po | 24 -------- .../i18n/pos_hide_cost_price_and_margin.pot | 55 ++++++++++++++++--- .../models/__init__.py | 2 + .../models/pos_config.py | 24 ++++++++ .../models/res_config_settings.py | 12 ++++ .../readme/CONTRIBUTORS.md | 1 + .../readme/CREDITS.md | 3 +- .../readme/DESCRIPTION.md | 4 +- .../readme/USAGE.md | 0 .../static/description/index.html | 46 +++++++++------- .../static/src/js/product_info_popup.esm.js | 18 ++++++ .../static/src/xml/pos_margin.xml | 38 ------------- .../views/res_config_settings_views.xml | 29 ++++++++++ 17 files changed, 179 insertions(+), 127 deletions(-) delete mode 100644 pos_hide_cost_price_and_margin/i18n/es.po delete mode 100644 pos_hide_cost_price_and_margin/i18n/it.po create mode 100644 pos_hide_cost_price_and_margin/models/__init__.py create mode 100644 pos_hide_cost_price_and_margin/models/pos_config.py create mode 100644 pos_hide_cost_price_and_margin/models/res_config_settings.py create mode 100644 pos_hide_cost_price_and_margin/readme/USAGE.md create mode 100644 pos_hide_cost_price_and_margin/static/src/js/product_info_popup.esm.js delete mode 100644 pos_hide_cost_price_and_margin/static/src/xml/pos_margin.xml create mode 100644 pos_hide_cost_price_and_margin/views/res_config_settings_views.xml diff --git a/pos_hide_cost_price_and_margin/README.rst b/pos_hide_cost_price_and_margin/README.rst index c19e1d0d2a..02a851d782 100644 --- a/pos_hide_cost_price_and_margin/README.rst +++ b/pos_hide_cost_price_and_margin/README.rst @@ -28,14 +28,20 @@ PoS Hide Cost and Margin |badge1| |badge2| |badge3| |badge4| |badge5| -This module extends the functionality of point of sale to hide cost and -margin on product detail. +By default since odoo v16.0, Margin/Cost is hidden for PoS/User. But you +also want it hidden for PoS/Manager, in some contexts. Installing this +module will hide it for every user **Table of contents** .. contents:: :local: +Usage +===== + + + Changelog ========= @@ -68,12 +74,13 @@ Contributors - `Trobz `__: - Hai Lang + - Tri Doan Other credits ------------- -The development of this module for 15.0 was financially supported by -Camptocamp +The migration of this module from 15.0 to 17.0 was financially supported +by Camptocamp Maintainers ----------- diff --git a/pos_hide_cost_price_and_margin/__init__.py b/pos_hide_cost_price_and_margin/__init__.py index e69de29bb2..0650744f6b 100644 --- a/pos_hide_cost_price_and_margin/__init__.py +++ b/pos_hide_cost_price_and_margin/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/pos_hide_cost_price_and_margin/__manifest__.py b/pos_hide_cost_price_and_margin/__manifest__.py index 908eada1b3..3660052e67 100644 --- a/pos_hide_cost_price_and_margin/__manifest__.py +++ b/pos_hide_cost_price_and_margin/__manifest__.py @@ -4,7 +4,7 @@ { "name": "PoS Hide Cost and Margin", "summary": "Hide Cost and Margin on PoS", - "version": "15.0.1.0.1", + "version": "17.0.1.0.0", "category": "Point Of Sale", "author": "CampToCamp, Odoo Community Association (OCA)", "maintainers": [], @@ -13,10 +13,12 @@ "depends": [ "point_of_sale", ], - "data": [], + "data": [ + "views/res_config_settings_views.xml", + ], "assets": { - "web.assets_qweb": [ - "pos_hide_cost_price_and_margin/static/src/xml/pos_margin.xml", + "point_of_sale.assets_prod": [ + "pos_hide_cost_price_and_margin/static/src/js/**/*", ], }, "installable": True, diff --git a/pos_hide_cost_price_and_margin/i18n/es.po b/pos_hide_cost_price_and_margin/i18n/es.po deleted file mode 100644 index cd1855a0cb..0000000000 --- a/pos_hide_cost_price_and_margin/i18n/es.po +++ /dev/null @@ -1,24 +0,0 @@ -# Translation of Odoo Server. -# This file contains the translation of the following modules: -# * pos_hide_cost_price_and_margin -# -msgid "" -msgstr "" -"Project-Id-Version: Odoo Server 15.0\n" -"Report-Msgid-Bugs-To: \n" -"PO-Revision-Date: 2023-07-11 09:09+0000\n" -"Last-Translator: Ivorra78 \n" -"Language-Team: none\n" -"Language: es\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: \n" -"Plural-Forms: nplurals=2; plural=n != 1;\n" -"X-Generator: Weblate 4.17\n" - -#. module: pos_hide_cost_price_and_margin -#. openerp-web -#: code:addons/pos_hide_cost_price_and_margin/static/src/xml/pos_margin.xml:0 -#, python-format -msgid "env.pos.config.iface_display_margin" -msgstr "env.pos.config.iface_display_margin" diff --git a/pos_hide_cost_price_and_margin/i18n/it.po b/pos_hide_cost_price_and_margin/i18n/it.po deleted file mode 100644 index 7b756d8f98..0000000000 --- a/pos_hide_cost_price_and_margin/i18n/it.po +++ /dev/null @@ -1,24 +0,0 @@ -# Translation of Odoo Server. -# This file contains the translation of the following modules: -# * pos_hide_cost_price_and_margin -# -msgid "" -msgstr "" -"Project-Id-Version: Odoo Server 15.0\n" -"Report-Msgid-Bugs-To: \n" -"PO-Revision-Date: 2023-03-09 18:23+0000\n" -"Last-Translator: mymage \n" -"Language-Team: none\n" -"Language: it\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: \n" -"Plural-Forms: nplurals=2; plural=n != 1;\n" -"X-Generator: Weblate 4.14.1\n" - -#. module: pos_hide_cost_price_and_margin -#. openerp-web -#: code:addons/pos_hide_cost_price_and_margin/static/src/xml/pos_margin.xml:0 -#, python-format -msgid "env.pos.config.iface_display_margin" -msgstr "env.pos.config.iface_display_margin" diff --git a/pos_hide_cost_price_and_margin/i18n/pos_hide_cost_price_and_margin.pot b/pos_hide_cost_price_and_margin/i18n/pos_hide_cost_price_and_margin.pot index 520e3d921e..5ba7400cc2 100644 --- a/pos_hide_cost_price_and_margin/i18n/pos_hide_cost_price_and_margin.pot +++ b/pos_hide_cost_price_and_margin/i18n/pos_hide_cost_price_and_margin.pot @@ -4,8 +4,10 @@ # msgid "" msgstr "" -"Project-Id-Version: Odoo Server 15.0\n" +"Project-Id-Version: Odoo Server 17.0+e\n" "Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2024-04-26 10:08+0000\n" +"PO-Revision-Date: 2024-04-26 10:08+0000\n" "Last-Translator: \n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -14,12 +16,47 @@ msgstr "" "Plural-Forms: \n" #. module: pos_hide_cost_price_and_margin -#. openerp-web -#: code:addons/pos_hide_cost_price_and_margin/static/src/xml/pos_margin.xml:0 -#: code:addons/pos_hide_cost_price_and_margin/static/src/xml/pos_margin.xml:0 -#: code:addons/pos_hide_cost_price_and_margin/static/src/xml/pos_margin.xml:0 -#: code:addons/pos_hide_cost_price_and_margin/static/src/xml/pos_margin.xml:0 -#: code:addons/pos_hide_cost_price_and_margin/static/src/xml/pos_margin.xml:0 -#, python-format -msgid "env.pos.config.iface_display_margin" +#: model:ir.model,name:pos_hide_cost_price_and_margin.model_res_config_settings +msgid "Config Settings" +msgstr "" + +#. module: pos_hide_cost_price_and_margin +#: model:ir.model.fields,field_description:pos_hide_cost_price_and_margin.field_pos_config__is_margins_costs_accessible_to_every_user +msgid "Margins & Costs" +msgstr "" + +#. module: pos_hide_cost_price_and_margin +#: model:ir.model.fields,field_description:pos_hide_cost_price_and_margin.field_pos_config__is_margins_costs_accessible_to_admin +#: model:ir.model.fields,field_description:pos_hide_cost_price_and_margin.field_res_config_settings__pos_is_margins_costs_accessible_to_admin +#: model_terms:ir.ui.view,arch_db:pos_hide_cost_price_and_margin.res_config_settings_view_form +msgid "Margins & Costs (Admin)" +msgstr "" + +#. module: pos_hide_cost_price_and_margin +#: model_terms:ir.ui.view,arch_db:pos_hide_cost_price_and_margin.res_config_settings_view_form +msgid "Margins & Costs (every user)" +msgstr "" + +#. module: pos_hide_cost_price_and_margin +#: model:ir.model,name:pos_hide_cost_price_and_margin.model_pos_config +msgid "Point of Sale Configuration" +msgstr "" + +#. module: pos_hide_cost_price_and_margin +#: model_terms:ir.ui.view,arch_db:pos_hide_cost_price_and_margin.res_config_settings_view_form +msgid "Show margins & costs on product information for Admin" +msgstr "" + +#. module: pos_hide_cost_price_and_margin +#: model:ir.model.fields,help:pos_hide_cost_price_and_margin.field_pos_config__is_margins_costs_accessible_to_admin +#: model:ir.model.fields,help:pos_hide_cost_price_and_margin.field_res_config_settings__pos_is_margins_costs_accessible_to_admin +msgid "" +"When disabled, margin and cost of product are hide in the Product info." +msgstr "" + +#. module: pos_hide_cost_price_and_margin +#: model:ir.model.fields,help:pos_hide_cost_price_and_margin.field_pos_config__is_margins_costs_accessible_to_every_user +msgid "" +"When disabled, only PoS manager can view the margin and cost of product " +"among the Product info." msgstr "" diff --git a/pos_hide_cost_price_and_margin/models/__init__.py b/pos_hide_cost_price_and_margin/models/__init__.py new file mode 100644 index 0000000000..2b92809a3b --- /dev/null +++ b/pos_hide_cost_price_and_margin/models/__init__.py @@ -0,0 +1,2 @@ +from . import pos_config +from . import res_config_settings diff --git a/pos_hide_cost_price_and_margin/models/pos_config.py b/pos_hide_cost_price_and_margin/models/pos_config.py new file mode 100644 index 0000000000..dfca5a96e3 --- /dev/null +++ b/pos_hide_cost_price_and_margin/models/pos_config.py @@ -0,0 +1,24 @@ +# Copyright 2024 Camptocamp SA +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo import api, fields, models + + +class PosConfig(models.Model): + _inherit = "pos.config" + + is_margins_costs_accessible_to_admin = fields.Boolean( + string="Margins & Costs (Admin)", + default=False, + ) + is_margins_costs_accessible_to_every_user = fields.Boolean( + compute="_compute_is_margins_costs_accessible_to_every_user", + readonly=False, + store=True, + ) + + @api.depends("is_margins_costs_accessible_to_admin") + def _compute_is_margins_costs_accessible_to_every_user(self): + for rec in self: + if not rec.is_margins_costs_accessible_to_admin: + rec.is_margins_costs_accessible_to_every_user = False diff --git a/pos_hide_cost_price_and_margin/models/res_config_settings.py b/pos_hide_cost_price_and_margin/models/res_config_settings.py new file mode 100644 index 0000000000..4a5bdafe0c --- /dev/null +++ b/pos_hide_cost_price_and_margin/models/res_config_settings.py @@ -0,0 +1,12 @@ +# Copyright 2024 Camptocamp SA +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo import fields, models + + +class ResConfigSettings(models.TransientModel): + _inherit = "res.config.settings" + + pos_is_margins_costs_accessible_to_admin = fields.Boolean( + related="pos_config_id.is_margins_costs_accessible_to_admin", readonly=False + ) diff --git a/pos_hide_cost_price_and_margin/readme/CONTRIBUTORS.md b/pos_hide_cost_price_and_margin/readme/CONTRIBUTORS.md index 6a20a4f5c0..6e91b64732 100644 --- a/pos_hide_cost_price_and_margin/readme/CONTRIBUTORS.md +++ b/pos_hide_cost_price_and_margin/readme/CONTRIBUTORS.md @@ -1,2 +1,3 @@ - [Trobz](https://trobz.com): - Hai Lang \<\> + - Tri Doan \<\> diff --git a/pos_hide_cost_price_and_margin/readme/CREDITS.md b/pos_hide_cost_price_and_margin/readme/CREDITS.md index 5e6120f303..c7d684fc1b 100644 --- a/pos_hide_cost_price_and_margin/readme/CREDITS.md +++ b/pos_hide_cost_price_and_margin/readme/CREDITS.md @@ -1,2 +1 @@ -The development of this module for 15.0 was financially supported by -Camptocamp +The migration of this module from 15.0 to 17.0 was financially supported by Camptocamp diff --git a/pos_hide_cost_price_and_margin/readme/DESCRIPTION.md b/pos_hide_cost_price_and_margin/readme/DESCRIPTION.md index 7bcce08ece..b3d4a56189 100644 --- a/pos_hide_cost_price_and_margin/readme/DESCRIPTION.md +++ b/pos_hide_cost_price_and_margin/readme/DESCRIPTION.md @@ -1,2 +1,2 @@ -This module extends the functionality of point of sale to hide cost and -margin on product detail. +By default since odoo v16.0, Margin/Cost is hidden for PoS/User. But you also want it hidden for PoS/Manager, in some contexts. +Installing this module will hide it for every user diff --git a/pos_hide_cost_price_and_margin/readme/USAGE.md b/pos_hide_cost_price_and_margin/readme/USAGE.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/pos_hide_cost_price_and_margin/static/description/index.html b/pos_hide_cost_price_and_margin/static/description/index.html index b0db4cc96e..e829318d52 100644 --- a/pos_hide_cost_price_and_margin/static/description/index.html +++ b/pos_hide_cost_price_and_margin/static/description/index.html @@ -370,36 +370,41 @@

PoS Hide Cost and Margin

!! source digest: sha256:9eb4f117b7596b2076213a1a04f614cb65967b56fabab9e83d53fcec56f33f99 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->

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

-

This module extends the functionality of point of sale to hide cost and -margin on product detail.

+

By default since odoo v16.0, Margin/Cost is hidden for PoS/User. But you +also want it hidden for PoS/Manager, in some contexts. Installing this +module will hide it for every user

Table of contents

+
+

Usage

+
-

Bug Tracker

+

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 @@ -407,29 +412,30 @@

Bug Tracker

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

-

Credits

+

Credits

-

Authors

+

Authors

  • CampToCamp
-

Other credits

-

The development of this module for 15.0 was financially supported by -Camptocamp

+

Other credits

+

The migration of this module from 15.0 to 17.0 was financially supported +by Camptocamp

-

Maintainers

+

Maintainers

This module is maintained by the OCA.

Odoo Community Association

OCA, or the Odoo Community Association, is a nonprofit organization whose diff --git a/pos_hide_cost_price_and_margin/static/src/js/product_info_popup.esm.js b/pos_hide_cost_price_and_margin/static/src/js/product_info_popup.esm.js new file mode 100644 index 0000000000..3ac278a011 --- /dev/null +++ b/pos_hide_cost_price_and_margin/static/src/js/product_info_popup.esm.js @@ -0,0 +1,18 @@ +/** @odoo-module */ + +import {ProductInfoPopup} from "@point_of_sale/app/screens/product_screen/product_info_popup/product_info_popup"; +import {patch} from "@web/core/utils/patch"; + +patch(ProductInfoPopup.prototype, { + /** + * @override + */ + _hasMarginsCostsAccessRights() { + const isAccessibleToAdmin = + this.pos.config.is_margins_costs_accessible_to_admin; + const isAccessibleToEveryUser = + this.pos.config.is_margins_costs_accessible_to_every_user; + const isCashierManager = this.pos.get_cashier().role === "manager"; + return isAccessibleToEveryUser || (isAccessibleToAdmin && isCashierManager); + }, +}); diff --git a/pos_hide_cost_price_and_margin/static/src/xml/pos_margin.xml b/pos_hide_cost_price_and_margin/static/src/xml/pos_margin.xml deleted file mode 100644 index aa684cc01c..0000000000 --- a/pos_hide_cost_price_and_margin/static/src/xml/pos_margin.xml +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - env.pos.config.iface_display_margin - - - env.pos.config.iface_display_margin - - - env.pos.config.iface_display_margin - - - env.pos.config.iface_display_margin - - - env.pos.config.iface_display_margin - - - - diff --git a/pos_hide_cost_price_and_margin/views/res_config_settings_views.xml b/pos_hide_cost_price_and_margin/views/res_config_settings_views.xml new file mode 100644 index 0000000000..dda03ea270 --- /dev/null +++ b/pos_hide_cost_price_and_margin/views/res_config_settings_views.xml @@ -0,0 +1,29 @@ + + + + res.config.settings + + + + + + + + + Margins & Costs (every user) + not pos_is_margins_costs_accessible_to_admin + + + +