Odoo Help


integrity error while creating a new registration

Oussama Ammar
on 5/15/14, 6:06 AM 566 views

after adding two regsitration in my table stock_stock i have this problem

2014-05-15 08:49:07,730 4212 ERROR ? openerp.sql_db: bad query: insert into "stock_stock" (id,"total_tax","total","name","sous_total",create_uid,create_date) values (3,0.0,0.0,3,0.0,1,(now() at time zone 'UTC'))
Traceback (most recent call last):
  File "/home/openerp/openerp-6.1/openerp/sql_db.py", line 212, in execute
    res = self._obj.execute(query, params)
IntegrityError: insert or update on table "stock_stock" violates foreign key constraint "stock_stock_name_fkey"
DETAIL:  Key (name)=(3) is not present in table "res_partner".

 this is the code of the classes

class facturation_br(osv.osv):
    _name = 'facturation_br'
    _columns = {
        "name": fields.char("Numero", size=64,required=True,),
    "date_reglement": fields.date("Date Regelement",required=True,),
        "montant": fields.float("Montant",required=True,),
        "partner_id": fields.many2one("res.partner", 'Fournisseur',
            required=True, ondelete='cascade'),      
    'address_invoice_id': fields.many2one('res.partner.address', 'Addresse de facturation',required=True,),
    'invoice_line': fields.one2many('stock.stock','name', 'Invoice Lines',),
    _defaults = {
    'date_reglement': lambda *a: time.strftime('%Y-%m-%d %H:%M:%S'),
    def onchange_partner_id(self, cr, uid, ids, partner_id):
        res = self.pool.get('res.partner').address_get(cr, uid, [partner_id], ['contact', 'invoice'])
        contact_addr_id = res['contact']
        invoice_addr_id = res['invoice']
        result = {
            'address_contact_id': contact_addr_id,
            'address_invoice_id': invoice_addr_id,
        return {'value': result}


class stock_stock(osv.osv):
    _name = 'stock.stock'
    _columns = {
    'name': fields.many2one('res.partner',required=True,select=True,),    
    "total_tax": fields.float("Total_tax",required=True,),
    "total": fields.float("Total",required=True,),

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 5/15/14, 6:06 AM
Seen: 566 times
Last updated: 3/16/15, 8:10 AM