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

Odoo 10 : Make a specific field of popup window only readable

Iscriviti

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

La domanda è stata contrassegnata
viewsrelationshipreadonlyodoo10
5 Risposte
6252 Visualizzazioni
Avatar
Zied Haffoudhi

Hi guys,


I'm stuck here :


<notebook>
<page string="purchase_inquiry_ids">
<!--This is a One2many field relation-->
<field name="purchase_inquiry_ids" context="{'default_purchase_order_id': active_id}"/>
</page>
</notebook>
 


When I click add an item, the purchase_order_id display the current id but I want to add a readonly="1" attribute to this field. 

I really appreciate your help to resolve this.

0
Avatar
Abbandona
Avatar
Bejaoui Souheil
Risposta migliore

Hi,

First, create a new form view for your model where you do all customization needed.

After that use "fields_view_get" for the purchase_inquiry_ids model to return this custom view when your context has "default_purchase_order_id" as a key.

@api.model
def fields_view_get(self, view_id=None, view_type=False, toolbar=False, submenu=False):
     if view_type == 'form' and self.env.context.get('default_purchase_order_id'):
         view_id = "the_custom_view_id"
     return super(YourClass, self).fields_view_get(view_id=view_id, view_type=view_type, toolbar=toolbar, submenu=submenu)

Best regards.

1
Avatar
Abbandona
Avatar
Zied Haffoudhi
Autore Risposta migliore

I tried to simplify the code by inherit the default view of the 'purchase_inquiry' and pass an attribute to a specific field but it lead me up to a blind alley.

I was obligated to follow the long way.

I write the view from scratch and there I customize what I need :


<notebook>
<page string="purchase_inquiry_ids">
<!-- <field name="purchase_inquiry_ids" context="{'default_purchase_order_id': active_id}" options="{'always_reload': True}"/> -->
<field name="purchase_inquiry_ids" context="{'default_purchase_order_id': active_id}">
<form string="Demande d'offre Form">
<header>
<button string="Set to draft" type="object" name="draft_progressbar" attrs="{'invisible': [('state', '=', 'draft')]}"/>
<button string="Sent" type="object" name="sent_progressbar" attrs="{'invisible': [('state','=','sent')]}"/>
<button string="Received" type="object" name="received_progressbar" attrs="{'invisible': [('state','=','received')]}"/>
<button string="Accepted" type="object" name="accepted_progressbar" class="oe_highlight" attrs="{'invisible': [('state','=','accepted')]}"/>
<button string="Refused" type="object" name="refused_progressbar" class="oe_highlight" attrs="{'invisible': [('state','=','refused')]}"/>
<button string="Create Command" type="object" name="create_command" class="oe_highlight" attrs="{'invisible': [('state','!=','accepted')]}"/>
<field name="state" widget="statusbar" statusbar_visible="draft, sent, received, accepted, refused"/>
</header>
<sheet>
<group>
<field name="name"/>
<field name="purchase_order_id" readonly="1"/>
<field name="provider_id"/>
<field name="date_inquiry"/>
<field name="datefinal_inquiry"/>
</group>
<group col="6">
<field name="product" placeholder="Product Name"/>
<field name="qte" placeholder="Nbr Emballage"/>
<field name="qte_total_unity" placeholder="Qte Totale"/>
</group>
<notebook>
<page string="Informations">
<group>
<field name="price"/>
</group>
</page>
<page string="Description">
<label for="description" string="Description"/>
<field name="description"/>
</page>
</notebook>
</sheet>
</form>
</field>
</page>
</notebook>



0
Avatar
Abbandona
Avatar
Mohammed Amal N
Risposta migliore

You can give readonly="1" for a one2many field

just add

<field name="purchase_inquiry_ids" readonly="1" context="{'default_purchase_order_id': active_id}"/>


0
Avatar
Abbandona
Zied Haffoudhi
Autore

Thank you for your reply Mohamed.

Readonly="1" there disable the possibility to create other record by clicking 'add an item'.

I want to display the popup to create another purchase_inquiry record using the current purchase_order id and I would like in this inherited form the purchase_order_id be disabled or readonly.

Mohammed Amal N

I didn't clearly understand what you are trying to say,

but if you want to add some thing to your one2many and make fields in its view readonly try this:

<field name='your_one2many'>

<tree>

<field name='field1_in_the_one2many_model' readonly='1'/>

<field name='field2> readonly='1'/>

</tree>

</field>

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à
How to have 2 lists for the same relation field in a form view?
views relationship odoo10
Avatar
0
mar 19
3920
odoo 10 : form for picking with only one field
views odoo10
Avatar
Avatar
Avatar
2
dic 19
3728
How to hide fields in the create and edit popup view?
views odoo10
Avatar
0
nov 18
3872
Make readonly start_date, end_date from sale order view Risolto
views readonly sale.order.form
Avatar
Avatar
Avatar
2
ago 25
1316
[Odoo 10] what is the best way to duplicate an existing view? Risolto
views xml odoo10
Avatar
Avatar
Avatar
2
nov 23
8302
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