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
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Beverage distributor
    • Hotel
    Real Estate
    • Real Estate Agency
    • Architecture Firm
    • Construction
    • Estate Managament
    • Gardening
    • Property Owner Association
    Consulting
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Producție
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware and Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Others
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    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

Relating 2 many2one fields

Abonare

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

Această întrebare a fost marcată
many2onestock.move.line
1 Răspunde
2717 Vizualizări
Imagine profil
Mohamad Ali Chamas

I created 2 fields inside the stock.move.line inside transfers : The first one is many2one field and I need to populate it automatically if the second customized boolean field is checked. The field I need to populate with is the product_id which is already found in the lines. Any Ideas? Here is my code: 


@api.onchange('product_id')
def relate_alternatives(self):
for rec in self:
if rec.alternative_delivery_item==True:
rec.product_alternative=rec.product_id


I don't need an onchange function, I need when checking the box, I need the new many2one field to be filled automatically, at the same time I need when changing the product_id again not affect the other many2one field I created. Thanks


0
Imagine profil
Abandonează
Imagine profil
Jainesh Shah(Aktiv Software)
Cel mai bun răspuns

Hello Moe,

If you don't want an onchange you can compute that field keeping the boolean field('alternative_delivery_item') as the dependent field.

Here is the way of doing that.

product_alternative = fields.Many2one(compute="_compute_product_alternative")

@api.depends('alternative_delivery_item')
def _compute_product_alternative(self):
for rec in self:
if not rec.product_alternative and rec.alternative_delivery_item:
rec.product_alternative=rec.product_id

The field 'product_alternative', once filled will not be affected even if product_id is changed.

Note: If you want your M2O field('product_alternative') to be empty when the boolean is unchecked,use the below code.

@api.depends('alternative_delivery_item')
def _compute_product_alternative(self):
for rec in self:
if not rec.product_alternative and rec.alternative_delivery_item:
rec.product_alternative=rec.product_id
elif not rec.alternative_delivery_item:
rec.product_alternative=False

Thanks & Regards,
Email: odoo@aktivsoftware.com
Skype: kalpeshmaheshwari


-1
Imagine profil
Abandonează
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
Related Posts Răspunsuri Vizualizări Activitate
value not pass from many2one field to form
many2one
Imagine profil
Imagine profil
Imagine profil
Imagine profil
3
sept. 25
2264
Display values of dropdown in a many2one field Rezolvat
many2one
Imagine profil
Imagine profil
2
feb. 25
6865
Related two Many2one fields in the same line
many2one compute relation stock.move.line
Imagine profil
Imagine profil
1
feb. 23
3192
Set default value in object of many2one field Rezolvat
many2one
Imagine profil
Imagine profil
1
nov. 22
16731
How to remove Create and Edit in many2one field.? Rezolvat
many2one
Imagine profil
Imagine profil
Imagine profil
Imagine profil
3
aug. 22
14256
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