9 changed files with 94 additions and 6 deletions
@ -1,2 +1,22 @@ |
|||||
# -*- coding: utf-8 -*- |
# -*- coding: utf-8 -*- |
||||
|
############################################################################# |
||||
|
# |
||||
|
# Cybrosys Technologies Pvt. Ltd. |
||||
|
# |
||||
|
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>) |
||||
|
# Author: Cybrosys Techno Solutions(<https://www.cybrosys.com>) |
||||
|
# |
||||
|
# You can modify it under the terms of the GNU LESSER |
||||
|
# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. |
||||
|
# |
||||
|
# This program is distributed in the hope that it will be useful, |
||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. |
||||
|
# |
||||
|
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE |
||||
|
# (LGPL v3) along with this program. |
||||
|
# If not, see <http://www.gnu.org/licenses/>. |
||||
|
# |
||||
|
############################################################################# |
||||
from . import product_product |
from . import product_product |
@ -0,0 +1,19 @@ |
|||||
|
/** @odoo-module **/ |
||||
|
import { patch } from "@web/core/utils/patch"; |
||||
|
import { onWillStart ,useState} from "@odoo/owl"; |
||||
|
import { ProductCatalogOrderLine} from "@product/product_catalog/order_line/order_line"; |
||||
|
import {useService} from "@web/core/utils/hooks" |
||||
|
/** |
||||
|
* This patch extends the ProductCatalogOrderLine component to check if the current user |
||||
|
* belongs to a specific group ('hide_product_price_cost.hide_product_price_cost_group_user_show_product_price'). |
||||
|
**/ |
||||
|
patch(ProductCatalogOrderLine.prototype, { |
||||
|
setup(){ |
||||
|
super.setup(); |
||||
|
this.user = useService("user"); |
||||
|
onWillStart(async () => { |
||||
|
// Check if the user belongs to the specified group
|
||||
|
this.userHasGroup =await this.user.hasGroup('hide_product_price_cost.hide_product_price_cost_group_user_show_product_price'); |
||||
|
}); |
||||
|
} |
||||
|
}); |
@ -0,0 +1,16 @@ |
|||||
|
<?xml version="1.0" encoding="UTF-8" ?> |
||||
|
<templates xml:space="preserve"> |
||||
|
<!-- This template extension conditionally displays the product unit price based on the user's group. |
||||
|
The user must belong to the 'hide_product_price_cost.hide_product_price_cost_group_user_show_product_price' group to see the product price.--> |
||||
|
<t t-name="hide_product_price_cost.ProductCatalogProjectOrderLine" |
||||
|
t-inherit="product.ProductCatalogOrderLine" t-inherit-mode="extension"> |
||||
|
<xpath expr="//t[@t-portal]" position="replace"> |
||||
|
<t t-portal="`#product-${props.productId}-price`"> |
||||
|
<t t-if="userHasGroup"> |
||||
|
<span class="o_product_catalog_price">Unit price: <t t-out="props.price"/></span> |
||||
|
</t> |
||||
|
<t t-else=""/> |
||||
|
</t> |
||||
|
</xpath> |
||||
|
</t> |
||||
|
</templates> |
Loading…
Reference in new issue