Se rendre au contenu
Odoo Menu
  • Se connecter
  • Essai gratuit
  • Applications
    Finance
    • Comptabilité
    • Facturation
    • Notes de frais
    • Feuilles de calcul (BI)
    • Documents
    • Signature
    Ventes
    • CRM
    • Ventes
    • PdV Boutique
    • PdV Restaurant
    • Abonnements
    • Location
    Sites web
    • Site Web
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Chaîne d'approvisionnement
    • Inventaire
    • Fabrication
    • PLM
    • Achats
    • Maintenance
    • Qualité
    Ressources Humaines
    • Employés
    • Recrutement
    • Congés
    • Évaluations
    • Recommandations
    • Parc automobile
    Marketing
    • Marketing Social
    • E-mail Marketing
    • SMS Marketing
    • Événements
    • Marketing Automation
    • Sondages
    Services
    • Projet
    • Feuilles de temps
    • Services sur Site
    • Assistance
    • Planification
    • Rendez-vous
    Productivité
    • Discussion
    • Validations
    • Internet des Objets
    • VoIP
    • Connaissances
    • WhatsApp
    Applications tierces Odoo Studio Plateforme Cloud d'Odoo
  • Industries
    Commerce de détail
    • Librairie
    • Magasin de vêtements
    • Magasin de meubles
    • Épicerie
    • Quincaillerie
    • Magasin de jouets
    Food & Hospitality
    • Bar et Pub
    • Restaurant
    • Fast-food
    • Maison d’hôtes
    • Distributeur de boissons
    • Hôtel
    Immobilier
    • Agence immobilière
    • Cabinet d'architecture
    • Construction
    • Gestion immobilière
    • Jardinage
    • Association de copropriétaires
    Consultance
    • Cabinet d'expertise comptable
    • Partenaire Odoo
    • Agence Marketing
    • Cabinet d'avocats
    • Aquisition de talents
    • Audit & Certification
    Fabrication
    • Textile
    • Métal
    • Meubles
    • Alimentation
    • Brewery
    • Cadeaux d'entreprise
    Santé & Fitness
    • Club de sports
    • Opticien
    • Salle de fitness
    • Praticiens bien-être
    • Pharmacie
    • Salon de coiffure
    Trades
    • Bricoleur
    • Matériel informatique et support
    • Systèmes photovoltaïques
    • Cordonnier
    • Services de nettoyage
    • Services CVC
    Autres
    • Organisation à but non lucratif
    • Agence environnementale
    • Location de panneaux d'affichage
    • Photographie
    • Leasing de vélos
    • Revendeur de logiciel
    Browse all Industries
  • Communauté
    Apprenez
    • Tutoriels
    • Documentation
    • Certifications
    • Formation
    • Blog
    • Podcast
    Renforcer l'éducation
    • Programme éducatif
    • Business Game Scale-Up!
    • Rendez-nous visite
    Obtenir le logiciel
    • Téléchargement
    • Comparez les éditions
    • Versions
    Collaborer
    • Github
    • Forum
    • Événements
    • Traductions
    • Devenez partenaire
    • Services for Partners
    • Enregistrer votre cabinet comptable
    Nos Services
    • Trouver un partenaire
    • Trouver un comptable
    • Rencontrer un conseiller
    • Services de mise en œuvre
    • Références clients
    • Assistance
    • Mises à niveau
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Obtenir une démonstration
  • Tarification
  • Aide

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

  • CRM
  • e-Commerce
  • Comptabilité
  • Inventaire
  • PoS
  • Projet
  • MRP
All apps
Vous devez être inscrit pour interagir avec la communauté.
Toutes les publications Personnes Badges
Étiquettes (Voir toutl)
odoo accounting v14 pos v15
À propos de ce forum
Vous devez être inscrit pour interagir avec la communauté.
Toutes les publications Personnes Badges
Étiquettes (Voir toutl)
odoo accounting v14 pos v15
À propos de ce forum
Aide

Module - Hide Cost Price from some user groups

S'inscrire

Recevez une notification lorsqu'il y a de l'activité sur ce poste

Cette question a été signalée
moduleproductviewcost_price
6 Réponses
10286 Vues
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
Ignorer
Zbik

Do you have installed the module stock_account?

Budi Hartono
Auteur

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

Avatar
Zbik
Meilleure réponse

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
Ignorer
Avatar
JORDI BALLESTER ALOMAR
Meilleure réponse

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
Ignorer
Budi Hartono
Auteur

Thanks, I'll take a look.

Avatar
Budi Hartono
Auteur Meilleure réponse

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
Ignorer
Zbik

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

Budi Hartono
Auteur

Nowhere, I didn't even put that '

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

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.

Vous appréciez la discussion ? Ne vous contentez pas de lire, rejoignez-nous !

Créez un compte dès aujourd'hui pour profiter de fonctionnalités exclusives et échanger avec notre formidable communauté !

S'inscrire
Publications associées Réponses Vues Activité
Does OpenERP support textile requirements?
module product
Avatar
Avatar
Avatar
Avatar
Avatar
4
juin 24
8400
V10 CE - unable to set cost price for imported products
product cost_price
Avatar
0
mai 17
3097
error in view adding new field to product
module product view v7 custom
Avatar
Avatar
Avatar
2
mars 15
7366
Evaluation of production cost
product cost_price
Avatar
0
mars 15
4015
Odoo 12 maintain cost price when a product is archived
product cost_price sheet
Avatar
Avatar
1
oct. 24
1363
Communauté
  • Tutoriels
  • Documentation
  • Forum
Open Source
  • Téléchargement
  • Github
  • Runbot
  • Traductions
Services
  • Hébergement Odoo.sh
  • Assistance
  • Migration
  • Développements personnalisés
  • Éducation
  • Trouver un comptable
  • Trouver un partenaire
  • Devenez partenaire
À propos
  • Notre société
  • Actifs de la marque
  • Contactez-nous
  • Emplois
  • Événements
  • Podcast
  • Blog
  • Clients
  • Informations légales • Confidentialité
  • Sécurité.
الْعَرَبيّة 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 est une suite d'applications open source couvrant tous les besoins de votre entreprise : CRM, eCommerce, Comptabilité, Inventaire, Point de Vente, Gestion de Projet, etc.

Le positionnement unique d'Odoo est d'être à la fois très facile à utiliser et totalement intégré.

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