Skip ke Konten
Odoo Menu
  • Login
  • Uji coba gratis
  • Aplikasi
    Keuangan
    • Akuntansi
    • Faktur
    • Pengeluaran
    • Spreadsheet (BI)
    • Dokumen
    • Tanda Tangan
    Sales
    • CRM
    • Sales
    • POS Toko
    • POS Restoran
    • Langganan
    • Rental
    Website
    • Website Builder
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Rantai Pasokan
    • Inventaris
    • Manufaktur
    • PLM
    • Purchase
    • Maintenance
    • Kualitas
    Sumber Daya Manusia
    • Karyawan
    • Rekrutmen
    • Cuti
    • Appraisal
    • Referensi
    • Armada
    Marketing
    • Social Marketing
    • Email Marketing
    • SMS Marketing
    • Acara
    • Otomatisasi Marketing
    • Survei
    Layanan
    • Project
    • Timesheet
    • Layanan Lapangan
    • Meja Bantuan
    • Planning
    • Appointment
    Produktivitas
    • Diskusi
    • Approval
    • IoT
    • VoIP
    • Pengetahuan
    • WhatsApp
    Aplikasi pihak ketiga Odoo Studio Platform Odoo Cloud
  • Industri-Industri
    Retail
    • Toko Buku
    • Toko Baju
    • Toko Furnitur
    • Toko Kelontong
    • Toko Hardware
    • Toko Mainan
    Makanan & Hospitality
    • Bar dan Pub
    • Restoran
    • Fast Food
    • Rumah Tamu
    • Distributor Minuman
    • Hotel
    Real Estate
    • Agensi Real Estate
    • Firma Arsitektur
    • Konstruksi
    • Estate Management
    • Perkebunan
    • Asosiasi Pemilik Properti
    Konsultansi
    • Firma Akuntansi
    • Mitra Odoo
    • Agensi Marketing
    • Firma huku
    • Talent Acquisition
    • Audit & Sertifikasi
    Manufaktur
    • Tekstil
    • Logam
    • Perabotan
    • Makanan
    • Brewery
    • Corporate Gift
    Kesehatan & Fitness
    • Sports Club
    • Toko Kacamata
    • Fitness Center
    • Wellness Practitioners
    • Farmasi
    • Salon Rambut
    Perdagangan
    • Handyman
    • IT Hardware & Support
    • Sistem-Sistem Energi Surya
    • Pembuat Sepatu
    • Cleaning Service
    • Layanan HVAC
    Lainnya
    • Organisasi Nirlaba
    • Agen Lingkungan
    • Rental Billboard
    • Fotografi
    • Penyewaan Sepeda
    • Reseller Software
    Browse semua Industri
  • Komunitas
    Belajar
    • Tutorial-tutorial
    • Dokumentasi
    • Sertifikasi
    • Pelatihan
    • Blog
    • Podcast
    Empower Education
    • Program Edukasi
    • Game Bisnis 'Scale Up!'
    • Kunjungi Odoo
    Dapatkan Softwarenya
    • Download
    • Bandingkan Edisi
    • Daftar Rilis
    Kolaborasi
    • Github
    • Forum
    • Acara
    • Terjemahan
    • Menjadi Partner
    • Layanan untuk Partner
    • Daftarkan perusahaan Akuntansi Anda.
    Dapatkan Layanan
    • Temukan Mitra
    • Temukan Akuntan
    • Temui penasihat
    • Layanan Implementasi
    • Referensi Pelanggan
    • Bantuan
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Dapatkan demo
  • Harga
  • Bantuan

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

  • CRM
  • e-Commerce
  • Akuntansi
  • Inventaris
  • PoS
  • Project
  • MRP
All apps
Anda harus terdaftar untuk dapat berinteraksi di komunitas.
Semua Post Orang Lencana-Lencana
Label (Lihat semua)
odoo accounting v14 pos v15
Mengenai forum ini
Anda harus terdaftar untuk dapat berinteraksi di komunitas.
Semua Post Orang Lencana-Lencana
Label (Lihat semua)
odoo accounting v14 pos v15
Mengenai forum ini
Help

Write to Record in Related Field of Many2One Relationship

Langganan

Dapatkan notifikasi saat terdapat aktivitas pada post ini

Pertanyaan ini telah diberikan tanda
many2onerelated_fields
7250 Tampilan
Avatar
Michael Thomas

I have an object that, when it completes it's workflow, needs to update the state for a different class, specifically manufacturing orders. I have tried everything I can think of to try to update that field. Code is thus:

class mrp_partsorder(osv.Model):
...

_columns = {
'sourceorder_id': fields.many2one('mrp.production', string='Manufacturing Order'
'primarystate': fields.selection ( [..states...], related='sourceorder_id.state'
}

def partsorder_complete(self, cr, uid, ids, context=None):
prod_obj = self.pool.get('mrp.production')
prod_ids = [self.sourceorder_id]
prods = prod_obj.search(cr, uid, prod_ids, context=context)
proc_obj.action_fitting(cr, uid, prods, context=context)
res = self.write(cr, uid, ids, {'state': 'complete'}, context=context)

class mrp_production(osv.osv)
def action_fitting(self, cr, uid, ids, context=None):
res = self.write(cr, uid, ids, {'state': 'fitting'}, context=context) return res
 


At the moment I'm getting the following error:

ValueError: "'mrp.partsorder' object has no attribute '_ids'" while evaluating
u'partsorder_complete()

This is not the only error I've seen, as I've tried quite a few different ideas of solving this problem. Basically, i just want to update the value in the related field (primarystate), but if I write to that field it updates the mrp.partsorder table but not the mrp.production table. So, I figured I needed to use self.pool.get to get the singleton instance of mrp.production and then use the the write method for mrp.production or use the action_fitting() method for mrp.production. 

What is the best way to solve this problem?

Edit: After further consideration I realized that I need to use the function on mrp.production to change the state, rather than just writing to it. I want to do this because of all the functionality built into the manufacturing order. All I need now is to figure out how to call the function from my mrp.partsorder.partsorder_complete() function. 

0
Avatar
Buang
Michael Thomas
Penulis

So I have now tried doing something like: mrp_order = self.pool.get('mrp.production') order_ids = self.sourceorder_id for order in mrp_order.browse(cr, uid, order_ids): order.action_fitting() I think that fixes some syntax issues I have, but I'm still getting the same error. The worst part is it is saying mrp.partsorder has no attribute _ids, which is odd since the function I'm calling is from the mrp.production object.

Michael Thomas
Penulis

As a follow up, mrp.partsorder shouldn't be called until the end of the partsorder_complete() function. So, the should be no problem running the action_fitting() function, unless the error is happening when I try to pass the sourceorder_ids (the m2o relationship between mrp.partsorders and mrp.production) to prod_ids.

Menikmati diskusi? Jangan hanya membaca, ikuti!

Buat akun sekarang untuk menikmati fitur eksklufi dan agar terlibat dengan komunitas kami!

Daftar
Post Terkait Replies Tampilan Aktivitas
Send a value from context one2many
many2one related_fields odoo15
Avatar
0
Mei 24
1790
Related field not found while trying to set up a One2many field. Diselesaikan
many2one one2many related_fields
Avatar
Avatar
Avatar
2
Okt 23
3101
Product variant is also product (odoo 14) Diselesaikan
product many2one related_fields
Avatar
Avatar
1
Mar 21
2787
v17: Module upgrade fails due to Many2one-related field Diselesaikan
many2one upgrade related_fields v17
Avatar
Avatar
1
Okt 25
483
value not pass from many2one field to form
many2one
Avatar
Avatar
Avatar
Avatar
3
Sep 25
2301
Komunitas
  • Tutorial-tutorial
  • Dokumentasi
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Terjemahan
Layanan
  • Odoo.sh Hosting
  • Bantuan
  • Peningkatan
  • Custom Development
  • Pendidikan
  • Temukan Akuntan
  • Temukan Mitra
  • Menjadi Partner
Tentang Kami
  • Perusahaan kami
  • Aset Merek
  • Hubungi kami
  • Tugas
  • Acara
  • Podcast
  • Blog
  • Pelanggan
  • Hukum • Privasi
  • Keamanan
الْعَرَبيّة 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 adalah rangkaian aplikasi bisnis open source yang mencakup semua kebutuhan perusahaan Anda: CRM, eCommerce, akuntansi, inventaris, point of sale, manajemen project, dan seterusnya.

Mudah digunakan dan terintegrasi penuh pada saat yang sama adalah value proposition unik Odoo.

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