-
-
Notifications
You must be signed in to change notification settings - Fork 601
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MIG] pos_hide_cost_price_and_margin: Migration to 17.0
- Loading branch information
Showing
17 changed files
with
179 additions
and
127 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 <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 | ||
----------- | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from . import pos_config | ||
from . import res_config_settings |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
12 changes: 12 additions & 0 deletions
12
pos_hide_cost_price_and_margin/models/res_config_settings.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]>\> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
pos_hide_cost_price_and_margin/static/src/js/product_info_popup.esm.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
38
pos_hide_cost_price_and_margin/static/src/xml/pos_margin.xml
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.