Skip to Content
Odoo Meniu
  • Autentificare
  • Try it free
  • Aplicații
    Finanțe
    • Contabilitate
    • Facturare
    • Cheltuieli
    • Spreadsheet (BI)
    • Documente
    • Semn
    Vânzări
    • CRM
    • Vânzări
    • POS Shop
    • POS Restaurant
    • Abonamente
    • Închiriere
    Site-uri web
    • Constructor de site-uri
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Lanț Aprovizionare
    • Inventar
    • Producție
    • PLM
    • Achiziție
    • Maintenance
    • Calitate
    Resurse Umane
    • Angajați
    • Recrutare
    • Time Off
    • Evaluări
    • Referințe
    • Flotă
    Marketing
    • Social Marketing
    • Marketing prin email
    • SMS Marketing
    • Evenimente
    • Automatizare marketing
    • Sondaje
    Servicii
    • Proiect
    • Foi de pontaj
    • Servicii de teren
    • Centru de asistență
    • Planificare
    • Programări
    Productivitate
    • Discuss
    • Aprobări
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    Aplicații Terțe Odoo Studio Platforma Odoo Cloud
  • Industrii
    Retail
    • Book Store
    • Magazin de îmbrăcăminte
    • Magazin de Mobilă
    • Magazin alimentar
    • Magazin de materiale de construcții
    • Magazin de jucării
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Distribuitor de băuturi
    • Hotel
    Proprietate imobiliara
    • Real Estate Agency
    • Firmă de Arhitectură
    • Construcție
    • Estate Managament
    • Grădinărit
    • Asociația Proprietarilor de Proprietăți
    Consultanta
    • Firma de Contabilitate
    • Partener Odoo
    • Agenție de marketing
    • Law firm
    • Atragere de talente
    • Audit & Certification
    Producție
    • Textil
    • Metal
    • Mobilier
    • Mâncare
    • Brewery
    • Cadouri corporate
    Health & Fitness
    • Club Sportiv
    • Magazin de ochelari
    • Centru de Fitness
    • Wellness Practitioners
    • Farmacie
    • Salon de coafură
    Trades
    • Handyman
    • IT Hardware and Support
    • Asigurare socială de stat
    • Cizmar
    • Servicii de curățenie
    • HVAC Services
    Altele
    • Organizație nonprofit
    • Agenție de Mediu
    • Închiriere panouri publicitare
    • Fotografie
    • Închiriere biciclete
    • Asigurare socială
    Browse all Industries
  • Comunitate
    Învăță
    • Tutorials
    • Documentație
    • Certificări
    • Instruire
    • Blog
    • Podcast
    Empower Education
    • Program Educațional
    • Scale Up! Business Game
    • Visit Odoo
    Obține Software-ul
    • Descărcare
    • Compară Edițiile
    • Lansări
    Colaborați
    • Github
    • Forum
    • Evenimente
    • Translations
    • Devino Partener
    • Services for Partners
    • Înregistrează-ți Firma de Contabilitate
    Obține Servicii
    • Găsește un Partener
    • Găsiți un contabil
    • Meet an advisor
    • Servicii de Implementare
    • Referințe ale clienților
    • Suport
    • Actualizări
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Obține un demo
  • Prețuri
  • Ajutor

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

  • CRM
  • e-Commerce
  • Contabilitate
  • Inventar
  • PoS
  • Proiect
  • MRP
All apps
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
All Posts Oameni Insigne
Etichete (View all)
odoo accounting v14 pos v15
Despre acest forum
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
All Posts Oameni Insigne
Etichete (View all)
odoo accounting v14 pos v15
Despre acest forum
Suport

Change the field value on change of other fields OpenERP/Python

Abonare

Primiți o notificare când există activitate la acestă postare

Această întrebare a fost marcată
2 Răspunsuri
14732 Vizualizări
Imagine profil
Supreeth KV

I have some 5 fields.

field_1: fields.char("Field") 
field_2: fields.char("Field")
field_3: fields.char("Field")
field_4: fields.char("Field")
field_5: fields.selection((('Incomplete','Incomplete'),('Completed','Completed')),'Field'),

By default field_5 will always be 'Incomplete':

_defaults = { 
'field_5': 'Incomplete',
}

My query is when all four fields has values, field_5 should automatically change to 'Completed' How to do this?

I had written an on_change function:

def on_change_module_code(self, cr, uid, ids, field_1,field_2,field_3,field_4): 
if field_1 :
return {'value': {'field_5': 'Completed'}}
if field_2 :
return {'value': {'field_5': 'Completed'}}
if field_3 :
return {'value': {'field_5': 'Completed'}}
if field_4 :
return {'value': {'field_5': 'Completed'}}

And in XML:

<field name="field_1" on_change="on_change_module_code(field_1,field_2,field_3,field_4)"/>;

Here when i enter first field, data is turning to 'Completed'. But it should turn to 'Completed' when all the fields has value.

How to do this?

0
Imagine profil
Abandonează
Imagine profil
Rihene
Cel mai bun răspuns

Hello my friend;

here is the answer to your question:

Python:

def on_change_field(self, cr, uid, ids, field_1,field_2,field_3,field_4, context=None):

if field_1 and field_2 and field_3 and field_4:

return {'value': {'field_5': 'Completed'}}

 else:

return {'value': {'field_5': 'Inompleted'}}

XML: Call the onchange function in every field(field1, field2, field3, field4)

<field name="field_1" on_change="on_change_field(field_1,field_2,field_3,field_4)"/>

<field name="field_2" on_change="on_change_field(field_1,field_2,field_3,field_4)"/>

<field name="field_3" on_change="on_change_field(field_1,field_2,field_3,field_4)"/>

<field name="field_4" on_change="on_change_field(field_1,field_2,field_3,field_4)"/>

Best Regards.

4
Imagine profil
Abandonează
Rihene

plz my friend make me know if its Ok :)

Supreeth KV
Autor

@Drees Far. Thank you for the answer. It is working. But i am getting a error message for for all fields when i am trying to enter a message. Error Message is "TypeError: Cannot read property 'value' of null" What is this? I

Rihene

i have understood you because when you call the onchange from the first field the other fields are empty so you have to use the invisible attribute then call the onchange in the last field. if you didnt understand tell me im here for your help but plz vote ;)

Imagine profil
Qutechs, Ahmed M.Elmubarak
Cel mai bun răspuns

Hello,

in the xml:


<field name="field_1" on_change="on_change_module_code(field_1,field_2,field_3,field_4)"/>
<field name="field_2" on_change="on_change_module_code(field_1,field_2,field_3,field_4)"/>
<field name="field_3" on_change="on_change_module_code(field_1,field_2,field_3,field_4)"/>
<field name="field_4" on_change="on_change_module_code(field_1,field_2,field_3,field_4)"/>


in .py:

def on_change_module_code(self, cr, uid, ids, field_1,field_2,field_3,field_4, context=None):
if field_1 and field_2 and field_3 and field_4:
  return {'value': {'field_5': 'Completed'}}
return {'value': {'field_5': Incomplete'}} 


I hope it'll help

Regards,

1
Imagine profil
Abandonează
Supreeth KV
Autor

@Ahmed. Thank you for the answer. It is working. But i am getting a error message for for all fields when i am trying to enter a message. Error Message is "TypeError: Cannot read property 'value' of null" What is this? I

Qutechs, Ahmed M.Elmubarak

I think you wrongly return the dict. kindly can you post your on_change method ...

Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Înscrie-te
Comunitate
  • Tutorials
  • Documentație
  • Forum
Open Source
  • Descărcare
  • Github
  • Runbot
  • Translations
Servicii
  • Hosting Odoo.sh
  • Suport
  • Actualizare
  • Custom Developments
  • Educație
  • Găsiți un contabil
  • Găsește un Partener
  • Devino Partener
Despre Noi
  • Compania noastră
  • Active de marcă
  • Contactați-ne
  • Locuri de muncă
  • Evenimente
  • Podcast
  • Blog
  • Clienți
  • Aspecte juridice • Confidențialitate
  • Securitate
الْعَرَبيّة 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 este o suită de aplicații de afaceri open source care acoperă toate nevoile companiei dvs.: CRM, comerț electronic, contabilitate, inventar, punct de vânzare, management de proiect etc.

Propunerea de valoare unică a Odoo este să fie în același timp foarte ușor de utilizat și complet integrat.

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