تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
3 الردود
13030 أدوات العرض

Hi,

Is it possible to hide the cost price of the product in the Product view?

I have standard sales staff and we want to restrict the access to the cost price. We want them to see the product attributes but hide the cost (standard price).

I tried with the access control list but I could not figure it out.


الصورة الرمزية
إهمال
أفضل إجابة

Hi Emad,
To hide the product cost you have code a custom module  like below. To hide from the UI,  you can activate the developer mode and then in the edit form view you can change the code. Either you can remove the field from view or you can give invisible attribute.(If the field is available in the edit form view). Or you have to change it in the original code
Thank You

<record model="ir.ui.view" id="invisible_product_cost">
<field name="model">product.template</field>
<field name="name">product.template.rental</field>
<field name="inherit_id" ref="product.product_template_only_form_view"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='standard_price']" position="attributes">
<attribute name="invisible">1</attribute>
</xpath>
</field>
</record>
الصورة الرمزية
إهمال
الكاتب

Thank Niyas,

I believe this will hide it from all and we need to give certain staff the ability to see.

Hi Emad ,

Did you get what you are looking for ?

الكاتب

I am not sure Niyas,

I am asking you if the above code will totally hide the cost price or it can be controlled by say a sales manager?

yes it is possible, admin can control it. What we have to do is have to replace the cost field and has to add a group for it. so that the field will be visible only for the users in the group. Admin can control it by adding the users to the group

الكاتب

SO how do I do that exactly? what code to add and where?

Are you trying to change the original code or trying to develop a new module for it ?

الكاتب

I am trying to make it work either way. which is the easiest way and how?

الكاتب أفضل إجابة

In Odoo 10, it can be done easily by going to User Interface > Views and search for "product.template.common.form". Edit this View and search for the following line that start with

 <label for="standard_price"
Change this line and the following line to be as following: 

<label for="standard_price" groups="account.group_account_manager"/>
div name="standard_price_uom" groups="account.group_account_manager">

This will make the Cost price shows only to Advisors. you can change that to any group of users that you want.

this will make the field totally invisible and it will show to Advisors. Please note that will not affect Administrators.



الصورة الرمزية
إهمال

This works fully if you change the source code.

But what about the code to insert into the custom module ?

Could you give us a piece of code on that ?

أفضل إجابة

You can use this module: https://apps.odoo.com/apps/modules/17.0/as_hide_product_price/

الصورة الرمزية
إهمال
المنشورات ذات الصلة الردود أدوات العرض النشاط
2
يوليو 25
4808
2
ديسمبر 24
7900
2
نوفمبر 24
28709
2
مايو 24
7597
3
مارس 24
7047