Skip to content

Commit

Permalink
[MIG] pos_hide_cost_price_and_margin: Migration to 17.0
Browse files Browse the repository at this point in the history
  • Loading branch information
trisdoan committed May 5, 2024
1 parent 195115c commit 1f6fffd
Show file tree
Hide file tree
Showing 17 changed files with 179 additions and 127 deletions.
15 changes: 11 additions & 4 deletions pos_hide_cost_price_and_margin/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
=========

Expand Down Expand Up @@ -68,12 +74,13 @@ Contributors
- `Trobz <https://trobz.com>`__:

- Hai Lang <[email protected]>
- Tri Doan <[email protected]>

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
-----------
Expand Down
1 change: 1 addition & 0 deletions pos_hide_cost_price_and_margin/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
10 changes: 6 additions & 4 deletions pos_hide_cost_price_and_margin/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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": [],
Expand All @@ -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,
Expand Down
24 changes: 0 additions & 24 deletions pos_hide_cost_price_and_margin/i18n/es.po

This file was deleted.

24 changes: 0 additions & 24 deletions pos_hide_cost_price_and_margin/i18n/it.po

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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 &amp; 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 ""
2 changes: 2 additions & 0 deletions pos_hide_cost_price_and_margin/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import pos_config
from . import res_config_settings
24 changes: 24 additions & 0 deletions pos_hide_cost_price_and_margin/models/pos_config.py
Original file line number Diff line number Diff line change
@@ -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

Check warning on line 24 in pos_hide_cost_price_and_margin/models/pos_config.py

View check run for this annotation

Codecov / codecov/patch

pos_hide_cost_price_and_margin/models/pos_config.py#L24

Added line #L24 was not covered by tests
12 changes: 12 additions & 0 deletions pos_hide_cost_price_and_margin/models/res_config_settings.py
Original file line number Diff line number Diff line change
@@ -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
)
1 change: 1 addition & 0 deletions pos_hide_cost_price_and_margin/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
- [Trobz](https://trobz.com):
- Hai Lang \<<[email protected]>\>
- Tri Doan \<<[email protected]>\>
3 changes: 1 addition & 2 deletions pos_hide_cost_price_and_margin/readme/CREDITS.md
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions pos_hide_cost_price_and_margin/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -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
Empty file.
46 changes: 26 additions & 20 deletions pos_hide_cost_price_and_margin/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -370,66 +370,72 @@ <h1 class="title">PoS Hide Cost and Margin</h1>
!! source digest: sha256:9eb4f117b7596b2076213a1a04f614cb65967b56fabab9e83d53fcec56f33f99
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/pos/tree/17.0/pos_hide_cost_price_and_margin"><img alt="OCA/pos" src="https://img.shields.io/badge/github-OCA%2Fpos-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/pos-17-0/pos-17-0-pos_hide_cost_price_and_margin"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/pos&amp;target_branch=17.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>This module extends the functionality of point of sale to hide cost and
margin on product detail.</p>
<p>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</p>
<p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents">
<ul class="simple">
<li><a class="reference internal" href="#changelog" id="toc-entry-1">Changelog</a><ul>
<li><a class="reference internal" href="#section-1" id="toc-entry-2">15.0.1.0.0</a></li>
<li><a class="reference internal" href="#usage" id="toc-entry-1">Usage</a></li>
<li><a class="reference internal" href="#changelog" id="toc-entry-2">Changelog</a><ul>
<li><a class="reference internal" href="#section-1" id="toc-entry-3">15.0.1.0.0</a></li>
</ul>
</li>
<li><a class="reference internal" href="#bug-tracker" id="toc-entry-3">Bug Tracker</a></li>
<li><a class="reference internal" href="#credits" id="toc-entry-4">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="toc-entry-5">Authors</a></li>
<li><a class="reference internal" href="#contributors" id="toc-entry-6">Contributors</a></li>
<li><a class="reference internal" href="#other-credits" id="toc-entry-7">Other credits</a></li>
<li><a class="reference internal" href="#maintainers" id="toc-entry-8">Maintainers</a></li>
<li><a class="reference internal" href="#bug-tracker" id="toc-entry-4">Bug Tracker</a></li>
<li><a class="reference internal" href="#credits" id="toc-entry-5">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="toc-entry-6">Authors</a></li>
<li><a class="reference internal" href="#contributors" id="toc-entry-7">Contributors</a></li>
<li><a class="reference internal" href="#other-credits" id="toc-entry-8">Other credits</a></li>
<li><a class="reference internal" href="#maintainers" id="toc-entry-9">Maintainers</a></li>
</ul>
</li>
</ul>
</div>
<div class="section" id="usage">
<h1><a class="toc-backref" href="#toc-entry-1">Usage</a></h1>
</div>
<div class="section" id="changelog">
<h1><a class="toc-backref" href="#toc-entry-1">Changelog</a></h1>
<h1><a class="toc-backref" href="#toc-entry-2">Changelog</a></h1>
<div class="section" id="section-1">
<h2><a class="toc-backref" href="#toc-entry-2">15.0.1.0.0</a></h2>
<h2><a class="toc-backref" href="#toc-entry-3">15.0.1.0.0</a></h2>
<ul class="simple">
<li>Add to V15.0</li>
</ul>
</div>
</div>
<div class="section" id="bug-tracker">
<h1><a class="toc-backref" href="#toc-entry-3">Bug Tracker</a></h1>
<h1><a class="toc-backref" href="#toc-entry-4">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/pos/issues">GitHub Issues</a>.
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
<a class="reference external" href="https://github.com/OCA/pos/issues/new?body=module:%20pos_hide_cost_price_and_margin%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
<h1><a class="toc-backref" href="#toc-entry-4">Credits</a></h1>
<h1><a class="toc-backref" href="#toc-entry-5">Credits</a></h1>
<div class="section" id="authors">
<h2><a class="toc-backref" href="#toc-entry-5">Authors</a></h2>
<h2><a class="toc-backref" href="#toc-entry-6">Authors</a></h2>
<ul class="simple">
<li>CampToCamp</li>
</ul>
</div>
<div class="section" id="contributors">
<h2><a class="toc-backref" href="#toc-entry-6">Contributors</a></h2>
<h2><a class="toc-backref" href="#toc-entry-7">Contributors</a></h2>
<ul class="simple">
<li><a class="reference external" href="https://trobz.com">Trobz</a>:<ul>
<li>Hai Lang &lt;<a class="reference external" href="mailto:hailn&#64;trobz.com">hailn&#64;trobz.com</a>&gt;</li>
<li>Tri Doan &lt;<a class="reference external" href="mailto:tridm&#64;trobz.com">tridm&#64;trobz.com</a>&gt;</li>
</ul>
</li>
</ul>
</div>
<div class="section" id="other-credits">
<h2><a class="toc-backref" href="#toc-entry-7">Other credits</a></h2>
<p>The development of this module for 15.0 was financially supported by
Camptocamp</p>
<h2><a class="toc-backref" href="#toc-entry-8">Other credits</a></h2>
<p>The migration of this module from 15.0 to 17.0 was financially supported
by Camptocamp</p>
</div>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#toc-entry-8">Maintainers</a></h2>
<h2><a class="toc-backref" href="#toc-entry-9">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
},
});
38 changes: 0 additions & 38 deletions pos_hide_cost_price_and_margin/static/src/xml/pos_margin.xml

This file was deleted.

Loading

0 comments on commit 1f6fffd

Please sign in to comment.