Passa al contenuto
Odoo Menu
  • Accedi
  • Provalo gratis
  • App
    Finanze
    • Contabilità
    • Fatturazione
    • Note spese
    • Fogli di calcolo (BI)
    • Documenti
    • Firma
    Vendite
    • CRM
    • Vendite
    • Punto vendita Negozio
    • Punto vendita Ristorante
    • Abbonamenti
    • Noleggi
    Siti web
    • Configuratore sito web
    • E-commerce
    • Blog
    • Forum
    • Live chat
    • E-learning
    Supply chain
    • Magazzino
    • Produzione
    • PLM
    • Acquisti
    • Manutenzione
    • Qualità
    Risorse umane
    • Dipendenti
    • Assunzioni
    • Ferie
    • Valutazioni
    • Referral dipendenti
    • Parco veicoli
    Marketing
    • Social marketing
    • E-mail marketing
    • SMS marketing
    • Eventi
    • Marketing automation
    • Sondaggi
    Servizi
    • Progetti
    • Fogli ore
    • Assistenza sul campo
    • Helpdesk
    • Pianificazione
    • Appuntamenti
    Produttività
    • Comunicazioni
    • Approvazioni
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    App di terze parti Odoo Studio Piattaforma cloud Odoo
  • Settori
    Retail
    • Libreria
    • Negozio di abbigliamento
    • Negozio di arredamento
    • Alimentari
    • Ferramenta
    • Negozio di giocattoli
    Cibo e ospitalità
    • Bar e pub
    • Ristorante
    • Fast food
    • Pensione
    • Grossista di bevande
    • Hotel
    Agenzia immobiliare
    • Agenzia immobiliare
    • Studio di architettura
    • Edilizia
    • Gestione immobiliare
    • Impresa di giardinaggio
    • Associazione di proprietari immobiliari
    Consulenza
    • Società di contabilità
    • Partner Odoo
    • Agenzia di marketing
    • Studio legale
    • Selezione del personale
    • Audit e certificazione
    Produzione
    • Tessile
    • Metallo
    • Arredamenti
    • Alimentare
    • Birrificio
    • Ditta di regalistica aziendale
    Benessere e sport
    • Club sportivo
    • Negozio di ottica
    • Centro fitness
    • Centro benessere
    • Farmacia
    • Parrucchiere
    Commercio
    • Tuttofare
    • Hardware e assistenza IT
    • Ditta di installazione di pannelli solari
    • Calzolaio
    • Servizi di pulizia
    • Servizi di climatizzazione
    Altro
    • Organizzazione non profit
    • Ente per la tutela ambientale
    • Agenzia di cartellonistica pubblicitaria
    • Studio fotografico
    • Punto noleggio di biciclette
    • Rivenditore di software
    Carica tutti i settori
  • Community
    Apprendimento
    • Tutorial
    • Documentazione
    • Certificazioni 
    • Formazione
    • Blog
    • Podcast
    Potenzia la tua formazione
    • Programma educativo
    • Scale Up! Business Game
    • Visita Odoo
    Ottieni il software
    • Scarica
    • Versioni a confronto
    • Note di versione
    Collabora
    • Github
    • Forum
    • Eventi
    • Traduzioni
    • Diventa nostro partner
    • Servizi per partner
    • Registra la tua società di contabilità
    Ottieni servizi
    • Trova un partner
    • Trova un contabile
    • Incontra un esperto
    • Servizi di implementazione
    • Testimonianze dei clienti
    • Supporto
    • Aggiornamenti
    GitHub Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Richiedi una demo
  • Prezzi
  • Aiuto

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

  • CRM
  • e-Commerce
  • Contabilità
  • Magazzino
  • PoS
  • Progetti
  • MRP
All apps
È necessario essere registrati per interagire con la community.
Tutti gli articoli Persone Badge
Etichette (Mostra tutto)
odoo accounting v14 pos v15
Sul forum
È necessario essere registrati per interagire con la community.
Tutti gli articoli Persone Badge
Etichette (Mostra tutto)
odoo accounting v14 pos v15
Sul forum
Assistenza

How to completely replace res.partner.form view?

Iscriviti

Ricevi una notifica quando c'è un'attività per questo post

La domanda è stata contrassegnata
viewsv7
3 Risposte
22517 Visualizzazioni
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
Abbandona
Avatar
Jasad Moozhiyan
Risposta migliore

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
Abbandona
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
Risposta migliore

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
Abbandona
Avatar
AJ Schrafel Paper Corp
Risposta migliore

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
Abbandona
David Dean
Autore

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.

Ti stai godendo la conversazione? Non leggere soltanto, partecipa anche tu!

Crea un account oggi per scoprire funzionalità esclusive ed entrare a far parte della nostra fantastica community!

Registrati
Post correlati Risposte Visualizzazioni Attività
What is the different between col and colspan? Risolto
views v7
Avatar
Avatar
1
ott 24
70337
What does the "no_open : True" widget option do in a view definition? Risolto
views v7
Avatar
Avatar
2
dic 23
26787
How do I search by country_id in view? Risolto
views v7
Avatar
Avatar
1
ott 21
10192
How to edit/consult one2many without popup?
views v7
Avatar
Avatar
1
mar 15
7467
Is it possible to join several tables in one view
views v7
Avatar
Avatar
1
mar 15
7347
Community
  • Tutorial
  • Documentazione
  • Forum
Open source
  • Scarica
  • Github
  • Runbot
  • Traduzioni
Servizi
  • Hosting Odoo.sh
  • Supporto
  • Aggiornamenti
  • Sviluppi personalizzati
  • Formazione
  • Trova un contabile
  • Trova un partner
  • Diventa nostro partner
Chi siamo
  • La nostra azienda
  • Branding
  • Contattaci
  • Lavora con noi
  • Eventi
  • Podcast
  • Blog
  • Clienti
  • Note legali • Privacy
  • Sicurezza
الْعَرَبيّة 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 è un gestionale di applicazioni aziendali open source pensato per coprire tutte le esigenze della tua azienda: CRM, Vendite, E-commerce, Magazzino, Produzione, Fatturazione elettronica, Project Management e molto altro.

Il punto di forza di Odoo è quello di offrire un ecosistema unico di app facili da usare, intuitive e completamente integrate tra loro.

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