Odoo Help

Welcome!

This community 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.

0

integrity error while creating a new registration

By
Oussama Ammar
on 5/15/14, 6:06 AM 410 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}

facturation_br()

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

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

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