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 completely replace res.partner.form view?

Inscrever

Seja notificado quando houver atividade nesta publicação

Esta pergunta foi sinalizada
viewsv7
3 Respostas
22539 Visualizações
Avatar
David Dean

I would like to replace the default res.partner.form view with a completely new view from a simple module I've created.

I want to replace instead of inherit because I don't just want to change the fields, I also want to change the HTML and other markup around those fields. Inheriting the form and adjusting individual fields won't give me the control I'm looking for.

I've managed to create a module with a new view, load the module into OpenERP and confirmed the view is registered but my changes are not visible. When I enable debug mode and look at "Manage Views" the "View Type" is "undefined" and res.partner is still using the default view.

Can anyone point me in the direction of where I'm going wrong? I've spent hours reading the documentation and Googling but still not managed to get this working.

andromeda_customer_form.py

from osv import osv, fields
from tools.translate import _

class andromeda_customers(osv.osv):

  _inherit = 'res.partner'

  _columns = {
    'andromeda_customer_type': fields.selection([('individual','Individual'),('business','Business'),('charity','Charity / Non-Profit'),('government','Government')],'Customer Type'),
    'andromeda_business_type': fields.selection([('sole_trader','Sole Trader'),('limited','Limited Company / Limited Liability Partnership'),('partnership','Partnership'),('other','Other')],'Business Type'),
    'andromeda_customer_title': fields.selection([('mr','Mr'),('mrs','Mrs'),('miss','Miss'),('ms','Ms'),('dr','Dr'),('prof','Prof'),('rev','Rev'),('sir','Sir')],'Title'),
    'andromeda_customer_firstname': fields.char('First name', size=16),
    'andromeda_customer_lastname': fields.char('Last name', size=16),
    'andromeda_customer_phone': fields.integer('Contact number', size=16),
    'andromeda_customer_email': fields.char('E-mail address', size=16),
  }

andromeda_customers()

andromeda_customer_form.xml

<?xml version="1.0" encoding="utf-8"?>
<openerp>
  <data>
    <record model="ir.ui.view" id="andromeda_customer_form">
      <field name="name">res.partner.form</field>
      <field name="model">res.partner</field>
      <field name="priority" eval="1"/>
      <field name="arch" type="xml">
          <field name="andromeda_customer_type" />
          <field name="andromeda_business_type" />
          <field name="andromeda_customer_title" />
          <field name="andromeda_customer_firstname" />
          <field name="andromeda_customer_lastname" />
          <field name="andromeda_customer_phone" />
          <field name="andromeda_customer_email" />
      </field>
    </record>
  </data>
</openerp>

Screenshot: I don't have enough karma to post links, so replace ** with the http prefix to view the image.

**dl.dropboxusercontent.com/u/41195444/openerp.png

1
Avatar
Cancelar
Avatar
Jasad Moozhiyan
Melhor resposta

Hi David Dean,

There are two solutions:

  1. Give the same id of partner form to your form.

ie,

<record model="ir.ui.view" id="base.view_partner_form">
      <field name="name">res.partner.form</field>
      <field name="model">res.partner</field>
      <field name="priority" eval="1"/>
      <field name="arch" type="xml">
          <field name="andromeda_customer_type" />
          <field name="andromeda_business_type" />
          <field name="andromeda_customer_title" />
          <field name="andromeda_customer_firstname" />
          <field name="andromeda_customer_lastname" />
          <field name="andromeda_customer_phone" />
          <field name="andromeda_customer_email" />
      </field>
    </record>

So it will replace the view with same id.

  1. Change the view_id in partner form menu.

ie,

<record id="base.action_partner_form_view2" model="ir.actions.act_window.view">
            <field eval="2" name="sequence"/>
            <field name="view_mode">form</field>
            <field name="view_id" ref="andromeda_customer_form"/>
            <field name="act_window_id" ref="action_partner_form"/>
        </record>

So here, the action inheriting, and it takes your form view.

1
Avatar
Cancelar
Levi Bensley

I tried the top method, but for the sale view, but then couldn't update the base sale module or modules such as sale_purchase do to a missing field (one that i added in my custom module)

Avatar
Paty L L
Melhor resposta

Hello David.

Did you manage to replace completely the res_partner_form_view? Can it be done? Im having issues with this topic, and don't see a formal answer.

Greetings.

Nestor

0
Avatar
Cancelar
Avatar
AJ Schrafel Paper Corp
Melhor resposta

You just tossed the fields into the XML.

You need to wrap the type of view it is around you fields.

<field name="arch" type="xml">
    <form string="You need to include this around your fields to define it as a form" version="7.0">
        <your fields>
    </form>
</field>
0
Avatar
Cancelar
David Dean
Autor

Hi - thanks for your reply! Wrapping the fields inside "<form string="Partners">" has fixed the problem where the "View Type" was "undefined". It's now correctly listed as Form. But I still have the problem where view "res.partner.form" is taking precedence over my replacement view (as-per the screenshot). How can I force my new view to be used by default? Thanks again, I appreciate your help.

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
What is the different between col and colspan? Resolvido
views v7
Avatar
Avatar
1
out. 24
70356
What does the "no_open : True" widget option do in a view definition? Resolvido
views v7
Avatar
Avatar
2
dez. 23
26813
How do I search by country_id in view? Resolvido
views v7
Avatar
Avatar
1
out. 21
10200
How to edit/consult one2many without popup?
views v7
Avatar
Avatar
1
mar. 15
7474
Is it possible to join several tables in one view
views v7
Avatar
Avatar
1
mar. 15
7350
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