Pular para o conteúdo
Odoo Menu
  • Entrar
  • Experimente grátis
  • Aplicativos
    Finanças
    • Financeiro
    • Faturamento
    • Despesas
    • Planilhas (BI)
    • Documentos
    • Assinar Documentos
    Vendas
    • CRM
    • Vendas
    • PDV Loja
    • PDV Restaurantes
    • Assinaturas
    • Locação
    Websites
    • Criador de Sites
    • e-Commerce
    • Blog
    • Fórum
    • Chat ao Vivo
    • e-Learning
    Cadeia de mantimentos
    • Inventário
    • Fabricação
    • PLM - Ciclo de Vida do Produto
    • Compras
    • Manutenção
    • Qualidade
    Recursos Humanos
    • Funcionários
    • Recrutamento
    • Folgas
    • Avaliações
    • Indicações
    • Frota
    Marketing
    • Redes Sociais
    • Marketing por E-mail
    • Marketing por SMS
    • Eventos
    • Automação de Marketing
    • Pesquisas
    Serviços
    • Projeto
    • Planilhas de Horas
    • Serviço de Campo
    • Central de Ajuda
    • Planejamento
    • Compromissos
    Produtividade
    • Mensagens
    • Aprovações
    • Internet das Coisas
    • VoIP
    • Conhecimento
    • WhatsApp
    Aplicativos de terceiros Odoo Studio Plataforma Odoo Cloud
  • Setores
    Varejo
    • Loja de livros
    • Loja de roupas
    • Loja de móveis
    • Mercearia
    • Loja de ferramentas
    • Loja de brinquedos
    Comida e hospitalidade
    • Bar e Pub
    • Restaurante
    • Fast Food
    • Hospedagem
    • Distribuidor de bebidas
    • Hotel
    Imóveis
    • Imobiliária
    • Escritório de arquitetura
    • Construção
    • Administração de propriedades
    • Jardinagem
    • Associação de proprietários de imóveis
    Consultoria
    • Escritório de Contabilidade
    • Parceiro Odoo
    • Agência de marketing
    • Escritório de advocacia
    • Aquisição de talentos
    • Auditoria e Certificação
    Fabricação
    • Têxtil
    • Metal
    • Móveis
    • Alimentação
    • Cervejaria
    • Presentes corporativos
    Saúde e Boa forma
    • Clube esportivo
    • Loja de óculos
    • Academia
    • Profissionais de bem-estar
    • Farmácia
    • Salão de cabeleireiro
    Comércio
    • Handyman
    • Hardware e Suporte de TI
    • Sistemas de energia solar
    • Sapataria
    • Serviços de limpeza
    • Serviços de climatização
    Outros
    • Organização sem fins lucrativos
    • Agência Ambiental
    • Aluguel de outdoors
    • Fotografia
    • Aluguel de bicicletas
    • Revendedor de software
    Navegar por todos os setores
  • Comunidade
    Aprenda
    • Tutoriais
    • Documentação
    • Certificações
    • Treinamento
    • Blog
    • Podcast
    Empodere a Educação
    • Programa de educação
    • Scale Up! Jogo de Negócios
    • Visite a Odoo
    Obtenha o Software
    • Baixar
    • Comparar edições
    • Releases
    Colaborar
    • Github
    • Fórum
    • Eventos
    • Traduções
    • Torne-se um parceiro
    • Serviços para parceiros
    • Cadastre seu escritório contábil
    Obtenha os serviços
    • Encontre um parceiro
    • Encontre um Contador
    • Conheça um consultor
    • Serviços de Implementação
    • Referências de Clientes
    • Suporte
    • Upgrades
    Github YouTube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Faça uma demonstração
  • Preços
  • Ajuda

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

  • CRM
  • e-Commerce
  • Financeiro
  • Inventário
  • PoS
  • Projeto
  • MRP
All apps
É necessário estar registrado para interagir com a comunidade.
Todas as publicações Pessoas Emblemas
Marcadores (Ver tudo)
odoo accounting v14 pos v15
Sobre este fórum
É necessário estar registrado para interagir com a comunidade.
Todas as publicações Pessoas Emblemas
Marcadores (Ver tudo)
odoo accounting v14 pos v15
Sobre este fórum
Ajuda

How to make a field invisible for certain groups

Inscrever

Seja notificado quando houver atividade nesta publicação

Esta pergunta foi sinalizada
fieldsgroupsvisibility
5 Respostas
51530 Visualizações
Avatar
Shawn Varghese

This question seems to have been asked before, but I couldn't get the answers to work.

I have a field - amount_words. It should be invisible only to one group and visible to all others. This is what I have done so far:

 <record id="view_order_line_tree2" model="ir.ui.view">
    <field name="name">sale.order.line.tree.inherit</field>
    <field name="model">sale.order</field>
    <field name="inherit_id" ref="sale.view_order_form"/>
    <field name="arch" type="xml">
        <xpath expr="//page/group" position="after"> <group class="oe_subtotal_amount_footer oe_left"> <field name="amount_words" /> </group> </xpath> </field> </record>

This is to introduce the amount_words field.

Now, to hide it for the service_order group:

 <record id="view_order_line_tree3" model="ir.ui.view">
    <field name="name">sale.order.line.tree.inherit2</field>
    <field name="model">sale.order</field>
    <field name="inherit_id" ref="view_order_line_tree2"/>
    <field name="groups_id" eval="[(6, 0, [ref('custom_sale.group_service_order') ])]"/>
    <field name="arch" type="xml">
	<field name="amount_words" position="attributes">
	    <attribute name="attrs">{'invisible':1}</attribute>
	</field>
    </field>
</record>

But the effect is that it is now invisible for all groups. Does anyone know how to achieve this?



2
Avatar
Cancelar
Avatar
Cybrosys Techno Solutions Pvt.Ltd
Melhor resposta

Hi,

Add a boolean field to the xml file and make it invisible.

Add the invisible attribute to the amount_words field.

Write a compute function to compute the value of the boolean field according to the user has the group to which the field visibility is to be blocked or not.

XML file:

<record id="view_order_line_tree2" model="ir.ui.view">


    <field name="name">sale.order.line.tree.inherit</field>


    <field name="model">sale.order</field>


    <field name="inherit_id" ref="sale.view_order_form"/>


    <field name="arch" type="xml">


        <xpath expr="//page/group" position="after">


            <group class="oe_subtotal_amount_footer oe_left">


                <field name="flag" invisible="1"/>


                <field name="amount_words"  attrs="{ 'invisible': [('flag', '=', True)] }"/>


            </group>


        </xpath>


    </field>


</record>


Python file:

class SaleOrder(models.Model):
_inherit = 'sale.order'

amount_words = fields.Char()
flag = fields.Boolean(compute='check_group')

def check_group(self):
if self.user_has_groups('custom_sale.group_service_order'):
self.flag = True
else:
self.flag = False

Regards

2
Avatar
Cancelar
Avatar
Kalpana Hemnani
Melhor resposta


Hello Shawn,

You can use 'groups' for number of groups you want to show this field just like below:

<field name="amount_words" position="attributes">

    <attribute name="groups">other_than_service_order_group_name</attribute>

</field>

After doing this, field will only be seen to groups you have mentioned in group attribute.

Hope this helps!

Thanks,

Kalpana Hemnani

 

2
Avatar
Cancelar
Shawn Varghese
Autor

Thanks Kalpana, but here I would have to assign the majority of my users to a separate group which seems unnecessary. I have commented in the other post. Please let me know in case you have any other suggestions.

Avatar
Solanki Shamji
Melhor resposta

Hello,

Please check the this url.

http://pinakinnayi.blogspot.in/2013/06/field-level-security-in-openerp.html

Hope this will help you.

Thanks.

Shamji


0
Avatar
Cancelar
Shawn Varghese
Autor

Thanks Solanki, but I think the link describes how to display it for a certain group. In my case, there are only very few users who should not see the field, so I created a group for that purpose. The workaround would be to create a separate group, assign everyone else to that group and apply groups to that. But that would be a tedious task and not the ideal way to do it. I think the code snippet that I posted with some tweaks should accomplish the task. Please let me know if you have any other ideas.

Avatar
CARLOS ALBERTO GARCIA BRIZUELA
Melhor resposta

For me in the same situation works this way. First, create a new group (group_purchase_restrict) in Odoo or your module, and then declare the XML view like this:

<record id="purchase_order_form_mods" model="ir.ui.view">

    <field name="name">purchase.order.form.mods</field>

    <field name="model">purchase.order</field>

    <field name="inherit_id" ref="purchase.purchase_order_form" />

    <field name="arch" type="xml">

        <xpath expr="//button[@name='purchase_confirm'][1]" position="attributes">

            <attribute name="groups">purchase.group_purchase_user,purchase.group_purchase_manager</attribute>

        </xpath>

    </field>

</record>


<record id="purchase_order_form_mods_restrict" model="ir.ui.view">

    <field name="name">purchase.order.form.mods.restrict</field>

    <field name="model">purchase.order</field>

    <field name="inherit_id" ref="purchase.purchase_order_form" />

    <field name="groups_id" eval="[(6, 0, [ref('purchase_mods.group_purchase_restrict') ])]"/>

    <field name="arch" type="xml">

        <xpath expr="//button[@name='purchase_confirm'][1]" position="attributes">

            <attribute name="invisible">1</attribute>

        </xpath>

    </field>

</record>

This way hide the button only for the users belonging to the new group (group_purchase_restrict).

 I hope it helps

0
Avatar
Cancelar
Avatar
Farid Ghanchi
Melhor resposta

Dear Shawn,

You can create a new wizard, And in this wizard you can choose a User/Customer (Specific User) and on this User/Customer give a access to this new field is visible or invisible. 

Thanks.

Farid Ghanchi

-1
Avatar
Cancelar
Está gostando da discussão? Não fique apenas lendo, participe!

Crie uma conta hoje mesmo para aproveitar os recursos exclusivos e interagir com nossa incrível comunidade!

Inscreva-se
Publicações relacionadas Respostas Visualizações Atividade
How can I append to the existing groups for a field in a view?
fields groups
Avatar
Avatar
1
mai. 23
4997
Get all the users that belong to a group Odoo15 Resolvido
fields groups v15
Avatar
Avatar
Avatar
2
mar. 24
6613
Make Field Read Only for specific Group Resolvido
security fields groups
Avatar
Avatar
1
out. 25
10838
How to set field value based on user group?
security fields groups
Avatar
Avatar
2
jan. 16
5073
make fields as read only based on groups
fields readonly groups
Avatar
Avatar
2
set. 15
5114
Comunidade
  • Tutoriais
  • Documentação
  • Fórum
Open Source
  • Baixar
  • Github
  • Runbot
  • Traduções
Serviços
  • Odoo.sh Hosting
  • Suporte
  • Upgrade
  • Desenvolvimentos personalizados
  • Educação
  • Encontre um Contador
  • Encontre um parceiro
  • Torne-se um parceiro
Sobre nós
  • Nossa empresa
  • Ativos da marca
  • Contato
  • Empregos
  • Eventos
  • Podcast
  • Blog
  • Clientes
  • Legal • Privacidade
  • Segurança
الْعَرَبيّة 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 é um conjunto de aplicativos de negócios em código aberto que cobre todas as necessidades de sua empresa: CRM, comércio eletrônico, contabilidade, estoque, ponto de venda, gerenciamento de projetos, etc.

A proposta de valor exclusiva Odoo é ser, ao mesmo tempo, muito fácil de usar e totalmente integrado.

Site feito com

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