Skip to Content
Odoo Menu
  • Prijavi
  • Try it free
  • Aplikacije
    Finance
    • Knjigovodstvo
    • Obračun
    • Stroški
    • Spreadsheet (BI)
    • Dokumenti
    • Podpisovanje
    Prodaja
    • CRM
    • Prodaja
    • POS Shop
    • POS Restaurant
    • Naročnine
    • Najem
    Spletne strani
    • Website Builder
    • Spletna trgovina
    • Blog
    • Forum
    • Pogovor v živo
    • eUčenje
    Dobavna veriga
    • Zaloga
    • Proizvodnja
    • PLM
    • Nabava
    • Vzdrževanje
    • Kakovost
    Kadri
    • Kadri
    • Kadrovanje
    • Odsotnost
    • Ocenjevanja
    • Priporočila
    • Vozni park
    Marketing
    • Družbeno Trženje
    • Email Marketing
    • SMS Marketing
    • Dogodki
    • Avtomatizacija trženja
    • Ankete
    Storitve
    • Projekt
    • Časovnice
    • Storitve na terenu
    • Služba za pomoč
    • Načrtovanje
    • Termini
    Produktivnost
    • Razprave
    • Odobritve
    • IoT
    • Voip
    • Znanje
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Industrije
    Trgovina na drobno
    • Book Store
    • Trgovina z oblačili
    • Trgovina s pohištvom
    • Grocery Store
    • Trgovina s strojno opremo računalnikov
    • Trgovina z igračami
    Food & Hospitality
    • Bar and Pub
    • Restavracija
    • Hitra hrana
    • Guest House
    • Beverage Distributor
    • Hotel
    Nepremičnine
    • Real Estate Agency
    • Arhitekturno podjetje
    • Gradbeništvo
    • Estate Management
    • Vrtnarjenje
    • Združenje lastnikov nepremičnin
    Svetovanje
    • Računovodsko podjetje
    • Odoo Partner
    • Marketinška agencija
    • Law firm
    • Pridobivanje talentov
    • Audit & Certification
    Proizvodnja
    • Tekstil
    • Metal
    • Pohištvo
    • Hrana
    • Brewery
    • Poslovna darila
    Health & Fitness
    • Športni klub
    • Trgovina z očali
    • Fitnes center
    • Wellness Practitioners
    • Lekarna
    • Frizerski salon
    Trades
    • Handyman
    • IT Hardware & Support
    • Sistemi sončne energije
    • Izdelovalec čevljev
    • Čistilne storitve
    • HVAC Services
    Ostali
    • Neprofitna organizacija
    • Agencija za okolje
    • Najem oglasnih panojev
    • Fotografija
    • Najem koles
    • Prodajalec programske opreme
    Browse all Industries
  • Skupnost
    Learn
    • Tutorials
    • Dokumentacija
    • Certifikati
    • Šolanje
    • Blog
    • Podcast
    Empower Education
    • Education Program
    • Scale Up! Business Game
    • Visit Odoo
    Get the Software
    • Prenesi
    • Compare Editions
    • Releases
    Collaborate
    • Github
    • Forum
    • Dogodki
    • Prevodi
    • Become a Partner
    • Services for Partners
    • Register your Accounting Firm
    Get Services
    • Find a Partner
    • Find an Accountant
    • Meet an advisor
    • Implementation Services
    • Sklici kupca
    • Podpora
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Get a demo
  • Določanje cen
  • Pomoč

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Knjigovodstvo
  • Zaloga
  • PoS
  • Projekt
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Ključne besede (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Ključne besede (View all)
odoo accounting v14 pos v15
About this forum
Pomoč

Module - Hide Cost Price from some user groups

Naroči se

Get notified when there's activity on this post

This question has been flagged
moduleproductviewcost_price
6 Odgovori
10288 Prikazi
Avatar
Budi Hartono

I'm trying to create a module to restrict access to Cost Price in the Procurement tab of the Product view. I want to let only Administrator and Purchase Manager see the Cost Price and make the other groups cannot see the Cost Price. I have created a module below. But It doesn't work. Nothing changes and everyone still can see the Cost Price. Can anybody tell me what my mistake is?

__init__.py

import product_template 

__openerp__.py

{
	"name": "Hide Cost Price from Some Groups",
	"version": "1.0.0",
	"author": "Budi Hartono",
	"depends": ["product"],
	"category": "",
	"description": """
	Hide Cost Price from Some Groups.
	""",
	"website": "http://www.recoremedia.com",
	"data": [
		"product_view.xml",
    ],
	"installable": True,
	"active": False,
}

product_template.py

from openerp.osv import fields, osv
from openerp.tools.translate import _
class product_template(osv.osv):
    _inherit = "product.template"

product_view.xml

<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
  <record id="product_template_form_view_restricted" model="ir.ui.view">
    <field name="name">product.template.common.form</field>
    <field name="model">product.template</field>
    <field name="inherit_id" ref="product.product_template_form_view"/>
    <field name="arch" type="xml">
      <field name="standard_price" position="replace">          
        <field name="standard_price" groups="base.group_erp_manager,purchase.group_purchase_manager"/>
      </field>
    </field>
  </record>
</data>
</openerp>



0
Avatar
Opusti
Zbik

Do you have installed the module stock_account?

Budi Hartono
Avtor

Yes I have installed it. It is the "WMS Accounting" isn't it?

Avatar
Zbik
Best Answer

Module stock_account inherit model product.template and replace standard_price view,  see ir.ui.viiew with id=view_template_property_form

Probably your module replace product and in next step module stock_account replace your definition

You must define:

"depends": ["stock_account"],

and redefine groups in this xml (code from view_template_property_form):


<div groups="base.group_user">

<field name="standard_price" attrs="{'readonly':['&', ('valuation','=','real_time'), ('cost_method', 'in', ['standard', 'average'])]}" nolabel="1"/>
<button name="%(action_view_change_standard_price)d" string="- update" type="action" attrs="{'invisible':['|', ('valuation','!=', 'real_time'), ('cost_method', 'not in', ['standard', 'average'])]}" class="oe_link" groups="stock_account.group_inventory_valuation"/>

</div>


1
Avatar
Opusti
Avatar
JORDI BALLESTER ALOMAR
Best Answer

Hi Budi,

Check this module:

https://github.com/Vauxoo/addons-vauxoo/tree/8.0/product_price_visible


And adjust it to your needs.

Regards,

Jordi Ballester

www.eficent.com



1
Avatar
Opusti
Budi Hartono
Avtor

Thanks, I'll take a look.

Avatar
Budi Hartono
Avtor Best Answer

Thanks zbik, you pointed out the problem, now I'm able to change something with this:

<xpath expr="//label[@string='Cost Price']" position="replace">
  <label string="Cost Price New" for="standard_price" align="1.0" groups="base.group_user"/> 
</xpath>

I just wanted to see if my code works, so I just changed the string into "Cost Price New" like above. I see that it's working. But I still don't know why my code below won't work:

<xpath expr="//div[@groups='base.group_user']" position="replace">
<div>Nothing Here!</div>
</xpath>

I guess it's the Xpath code because I got this error message when trying to install my module:

Element '<div name="options">' cannot be located in parent view 
I try to change the Xpath expression but still cannot find a way to make it work. 

0
Avatar
Opusti
Zbik

Where, in your module xpath, you change ... div name="options"...?

Budi Hartono
Avtor

Nowhere, I didn't even put that '

' in the code. But this error occurs when I put in the stock_account module.
Budi Hartono
Avtor

Well, I found alternative solution. I changed my xpath target, I don't try to change the div anymore, but instead I replace the field standard_price (which is the child node of that div). And it works.

Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Prijavi
Related Posts Odgovori Prikazi Aktivnost
Does OpenERP support textile requirements?
module product
Avatar
Avatar
Avatar
Avatar
Avatar
4
jun. 24
8402
V10 CE - unable to set cost price for imported products
product cost_price
Avatar
0
maj 17
3097
error in view adding new field to product
module product view v7 custom
Avatar
Avatar
Avatar
2
mar. 15
7368
Evaluation of production cost
product cost_price
Avatar
0
mar. 15
4015
Odoo 12 maintain cost price when a product is archived
product cost_price sheet
Avatar
Avatar
1
okt. 24
1365
Community
  • Tutorials
  • Dokumentacija
  • Forum
Open Source
  • Prenesi
  • Github
  • Runbot
  • Prevodi
Services
  • Odoo.sh Hosting
  • Podpora
  • Nadgradnja
  • Custom Developments
  • Izobraževanje
  • Find an Accountant
  • Find a Partner
  • Become a Partner
About us
  • Our company
  • Sredstva blagovne znamke
  • Kontakt
  • Zaposlitve
  • Dogodki
  • Podcast
  • Blog
  • Stranke
  • Pravno • Zasebnost
  • Varnost
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo is a suite of open source business apps that cover all your company needs: CRM, eCommerce, accounting, inventory, point of sale, project management, etc.

Odoo's unique value proposition is to be at the same time very easy to use and fully integrated.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now