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
    • Discuss
    • Artificial Intelligence
    • IoT
    • VoIP
    • Pengetahuan
    • WhatsApp
    Aplikasi pihak ketiga Odoo Studio Platform Odoo Cloud
  • 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
    • Manajemen Properti
    • 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
    • Konsultasi
    • Layanan Implementasi
    • Referensi Pelanggan
    • Bantuan
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Dapatkan demo
  • Harga
  • Bantuan
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

Integrity Error on object creation

Langganan

Dapatkan notifikasi saat terdapat aktivitas pada post ini

Pertanyaan ini telah diberikan tanda
3 Replies
6860 Tampilan
Avatar
Yulybaseball

Hi there:

I am developing a new model called implementation.project; it inherits from project.project. This is the class declaration:

class implementation_project(osv.Model):
    _name = 'implementation.project'
    _inherit = 'project.project'

Some fields (columns) are added to this class (model or whatever). Original model (project.project) has a one2many field called 'tasks'. When I try to create new 'implementation.project' record, the enigmatic Odoo raises this error:

IntegrityError: insert or update on table "project_task_type_rel" violates foreign key constraint "project_task_type_rel_project_id_fkey"
DETAIL:  Key (project_id)=(6) is not present in table "project_project".

Obviously!!!! It has to exist project.project record to create anything that inherits from him!!! I guess Odoo (according to some, a good platform to develop) has the ability to know how to proceed in this case... or not????

So, how to create new record from 'implementation.project'????

 

Thanks in advance.

 

1
Avatar
Buang
Avatar
Yulybaseball
Penulis Jawaban Terbai

Note: I am sorry for posting an answer. It should be a Comment, but I can't: surprinsigly, I need 50 karma to do that... even for an answer to my question.

@Bole, first of all, THANK YOU VERY MUCH!!! It works!!!

Second, what you explained is entirely logical... but I assumed Odoo would better understand the inheritance. Why I have to assume I have to "redeclare" parent fields??? Please, it's an inheritance!!! If I have a model, and I have to inherit from it... what is the sense of the inheritance if I have to redeclare all fields??? (Assuming all parent fields are relations to other models).

Third, OK, I understand developers must know how works the platform they are going to develop on... but how to know how Odoo works? Where is the developer documentation?  

Fourth, I am sorry. I went to mark your reply as the Accepted one, but I need more Karma... 

 

 

2
Avatar
Buang
DAJ MI 5, Bole

correction.. you do not REDECLARE... you OVERRIDE inherited field in order to change (correct) the relation ... as for documentation... we (some developers) have a wery good friend ... his name is google.... try asking our mutual firend does he know something about "openerp technical memento" ... also... check http://doc.openerp.com for v7 or https://www.odoo.com/documentation/8.0/ for v8 ... after that.. you affocurse have this forum... and a lot of private blogistes .... so .. resources are all over.. all you need is time to read it and more time to understand it :)

Avatar
DAJ MI 5, Bole
Jawaban Terbai

Well... 
class implementation_project(osv.Model):
    _name = 'implementation.project'
    _inherit = 'project.project'

What you did is, you created a completley new object 'implementation.project' wich inherited all fields from original class...
and then you added some new custom fields...
But, what you did NOT do is.. change some of inherited fields... one of them is :
'type_ids': fields.many2many('project.task.type', 'project_task_type_rel', 'project_id', 'type_id', 'Tasks Stages', states={'close':[('readonly',True)], 'cancelled':[('readonly',True)]}),

SO now you have your new model, with task type related to old model.. 
what you should do is override that field like:
'type_ids': fields.many2many('project.task.type', 'implementation_project_task_type_rel', 'project_id', 'type_id', 'Tasks Stages', states={'close':[('readonly',True)], 'cancelled':[('readonly',True)]}), 
in order to establish a new relatin table between your new created model and old task_type model... 

Now cretaing record should work just fine.. 

hope it helps : )

p.s. 
odoo is nice platform for rapid development of businees apps... but, in order to use it you have to firs know how it works...
in other words RTFM :)

 

1
Avatar
Buang
Avatar
Ivan
Jawaban Terbai

Odoo has a couple of way that you can inherit an object from.  One way is how you did, which is using the _inherit attribute with a string value that matches the name of the model that you want to inherit.  This way Odoo will extend the original model.  The class name bears no "meaning" to the ORM model.  The _name attribute, however may change the _name attribute of the original model (can't say for sure as I haven't really check it out).  When you create a record, you need to specify all the values of the necessary fields.  All values will be written on the same table.

The second way is to use _inherits = {'model.name': 'field_name'}.  This is done, e.g. for product.product in which it inherit product.template (check out the odoo/odoo/addons/product/product.py file).  This is a creation of another class that inherits a different parent class.  The sub class will have 'field_name' but all the fields/columns that belongs to the parent class will be written in the parent's class table.  When you create a record, you need to specify all the values of the necessary fields.  Values belonging to parent class will be written into the parent's table and values beloging to child class will be written in the child's table.

The third way, usually used for mixin is to use _inherit = ['mixin.model'].  You can also checkout product.product as it also inherits 'mail.thread'.  As it is just extension of capability, it adds no additional fields.

 

0
Avatar
Buang
Menikmati diskusi? Jangan hanya membaca, ikuti!

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

Daftar
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
  • Karir
  • 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 Svenska ภาษาไทย 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