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

Odoo Evaluating Record Rules for Both Current and Target States

Inscrever

Seja notificado quando houver atividade nesta publicação

Esta pergunta foi sinalizada
v18V18
2295 Visualizações
Avatar
alshehri.hass@gmail.com

Hi everyone,

I’ve come across what appears to be an inconsistency in how Odoo evaluates record rules, and it might be a bug. Specifically, when attempting to confirm a purchase order from "draft" to "purchase," it seems like Odoo checks permissions for both the current state and the target state at the same time. This results in an access error, even though the rules should allow the transition.

Example Rules:

Here are the two record rules applied to the user’s group:

{
    "id": 386,
    "name": "All Purchase Orders",
    "model_id": [759, "Purchase Order"],
    "groups": [79],
    "domain_force": "[('state', 'not in', ('purchase', 'cancel', 'done'))]",
    "perm_read": true,
    "perm_write": true,
    "perm_create": true,
    "perm_unlink": false
},
{
    "id": 387,
    "name": "Prevent Purchase Orders Cancel",
    "model_id": [759, "Purchase Order"],
    "groups": [79],
    "domain_force": "[('state', 'in', ('purchase', 'cancel', 'done'))]",
    "perm_read": true,
    "perm_write": false,
    "perm_create": false,
    "perm_unlink": false
}

Expected Behavior:

  • Rule 386 allows write access for purchase orders in "draft" state.
  • Rule 387 restricts write access only in the "purchase," "cancel," and "done" states.

Since the user is in the "draft" state, they should have permission to confirm the order, moving it to the "purchase" state.

Observed Behavior:

It seems Odoo requires write permissions for both the "draft" (current) and "purchase" (target) states simultaneously, resulting in an access error due to the restrictions in Rule 387. This doesn’t align with expected behavior, where only the current state’s permissions should apply during the action.

Question:

Is this simultaneous evaluation of current and target states intended in Odoo’s rule logic, or might this be a bug? Any insights or workarounds would be helpful!


Thanks in advance for any guidance.

0
Avatar
Cancelar
Ray Carnes (ray)

Have your ruled out that confirm doesn't need two write calls in the database where you are seeing this?

alshehri.hass@gmail.com
Autor

I'm seeing this issue with sale orders as well and I could only see a single write operation in the `action_confirm`​ method: https://github.com/odoo/odoo/blob/b560ba3897c764220663b9ac19f556573a4c9e2a/addons/sale/models/sale_order.py#L1110

Ray Carnes (ray)

Each of these modules is potentially calling WRITE on Purchase Orders: account_budget, mrp_mps, mrp_subcontracting_dropshipping, mrp_subcontracting_purchase, partner_commission, project_purchase, project_purchase_stock, purchase, purchase_edi_ubl_bis3, purchase_intrastat, purchase_mrp, purchase_product_matrix, purchase_repair, purchase_requisition, purchase_requisition_stock, purchase_stock, sale_purchase, sale_purchase_inter_company_rules, sale_purchase_stock, sale_purchase_stock_inter_company_rules, stock_dropshipping.

I just tested and write is called 7 times during PO confirmation with all of the modules above loaded.

Ray Carnes (ray)

This list shows you what fields are being updated during each call:
OLD: {'state': 'draft', 'date_approve': False} - NEW: {'state': 'purchase', 'date_approve': datetime.datetime(2024, 11, 8, 15, 30, 37)}
OLD: {'group_id': procurement.group()} - NEW: {'group_id': procurement.group(68,)}
OLD: {'invoice_status': 'no'} - NEW: {'invoice_status': 'no'}
OLD: {'date_calendar_start': datetime.datetime(2024, 11, 8, 11, 50, 44)} - NEW: {'date_calendar_start': datetime.datetime(2024, 11, 8, 15, 30, 37)}
OLD: {'picking_ids': stock.picking()} - NEW: {'picking_ids': stock.picking(67,)}
OLD: {'effective_date': False} - NEW: {'effective_date': False}
OLD: {'receipt_status': False} - NEW: {'receipt_status': 'pending'}

alshehri.hass@gmail.com
Autor

Thanks for looking into this. Are all of these write operations performed on the PO model? How are you getting this list of updated fields? Even if multiple write operations are being executed on the PO model, I’m not observing the PO order transitioning to a different state or getting stuck between states. Instead, the access error is raised, and the order remains in draft.

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
Where I can find Company Properties in Odoo 18? Resolvido
v18 V18
Avatar
Avatar
Avatar
Avatar
3
mar. 25
6437
IMPORTING AND EXPORTING DATA
v18 V18
Avatar
Avatar
1
nov. 24
2520
Where is the PDF Partner Ledger QWeb Report and View in Odoo Online?
v18
Avatar
Avatar
1
dez. 25
3265
Change Sign & Pay Button on Quotation E-mails
v18
Avatar
Avatar
Avatar
Avatar
3
nov. 25
577
Problem including JS asset in v18
v18
Avatar
Avatar
Avatar
3
nov. 25
8921
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