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

IntegrityError: null value in column "name" violates not-null constraint [Closed]

By
Anabela Damas
on 2/18/13, 12:31 PM 6,488 views

The Question has been closed

by
Anabela Damas
on 04/19/2013 15:00:25

Hi, I'm newbie in OpenErp. I've done a simple module where I add some fields to res.partner like this: (.../openerp/addon/my_module/mymodule.py)

from openerp.osv import fields, osv

class res_partner(osv.osv):
    _inherit = 'res.partner'
    _name = 'res.partner'
    _columns = {
        'by_fax': fields.boolean('Fax', help="This box will apear if it is a supplier."),
        'by_email': fields.boolean('Email', help="This box will apear if it is a supplier."),
        'by_phone': fields.boolean('Phone', help="This box will apear if it is a supplier."),
        'campoextra': fields.char('Extra Field', size=128),
        'currency_id': fields.many2one('res.currency', 'Currency'),
    }
res_partner()

After I went to Management of Database and I tried to create a new DB with the demo data, I get the following error. But if I try to create the DB without the demo data the DB is created sucessfully. Do I have an error in my res.partner or is some error with the demo data?

( Sorry my english =) )

    2013-02-18 16:07:12,066 5934 ERROR openerp6 openerp.sql_db: bad query: insert into "res_partner" (id,"lang","customer","tz","color","image","company_id","use_parent_address","supplier","employee","active","type","is_company",create_uid,create_date,write_uid,write_date) values (65,'en_US','True',NULL,0,'\x6954........93d'::bytea,1,'True','False','False','True','default','False',1,(now() at time zone 'UTC'),1,(now() at time zone 'UTC'))
    Traceback (most recent call last):
      File "/opt/openerp-7.0/openerp/sql_db.py", line 227, in execute
        res = self._obj.execute(query, params)
    IntegrityError: null value in column "name" violates not-null constraint
2013-02-18 16:07:12,093 5934 ERROR openerp6 openerp.tools.convert: Parse error in /opt/openerp-7.0/openerp/addons/base/res/res_partner_image_demo.xml:77: 
    <record id="base.res_partner_address_32" model="res.partner">
                <field name="image">iVBORw0K..........GgoRK5CYII=</field>
            </record>
    Traceback (most recent call last):
      File "/opt/openerp-7.0/openerp/tools/convert.py", line 847, in parse
        self._tags[rec.tag](self.cr, rec, n)
      File "/opt/openerp-7.0/openerp/tools/convert.py", line 814, in _tag_record
        id = self.pool.get('ir.model.data')._update(cr, self.uid, rec_model, self.module, res, rec_id or False, not self.isnoupdate(data_node), noupdate=self.isnoupdate(data_node), mode=self.mode, context=rec_context )
      File "/opt/openerp-7.0/openerp/addons/base/ir/ir_model.py", line 956, in _update
        res_id = model_obj.create(cr, uid, values, context=context)
      File "/opt/openerp-7.0/openerp/addons/base/res/res_partner.py", line 390, in create
        return super(res_partner,self).create(cr, uid, vals, context=context)
      File "/opt/openerp-7.0/openerp/osv/orm.py", line 4436, in create
        cr.execute('insert into "'+self._table+'" (id'+upd0+") values ("+str(id_new)+upd1+')', tuple(upd2))
      File "/opt/openerp-7.0/openerp/sql_db.py", line 162, in wrapper
        return f(self, *args, **kwargs)
      File "/opt/openerp-7.0/openerp/sql_db.py", line 227, in execute
        res = self._obj.execute(query, params)
    IntegrityError: null value in column "name" violates not-null constraint

    2013-02-18 16:07:12,142 5934 ERROR openerp6 openerp.service.web_services: CREATE DATABASE failed:
    Traceback (most recent call last):
      File "/opt/openerp-7.0/openerp/service/web_services.py", line 76, in _initialize_db
        update_module=True)[1]
      File "/opt/openerp-7.0/openerp/pooler.py", line 39, in restart_pool
        registry = RegistryManager.new(db_name, force_demo, status, update_module)
      File "/opt/openerp-7.0/openerp/modules/registry.py", line 214, in new
        openerp.modules.load_modules(registry.db, force_demo, status, update_module)
      File "/opt/openerp-7.0/openerp/modules/loading.py", line 303, in load_modules
        loaded_modules, processed_modules = load_module_graph(cr, graph, status, perform_checks=update_module, report=report)
      File "/opt/openerp-7.0/openerp/modules/loading.py", line 194, in load_module_graph
        load_demo(module_name, idref, mode)
      File "/opt/openerp-7.0/openerp/modules/loading.py", line 76, in <lambda>
        load_demo = lambda *args: _load_data(cr, *args, kind='demo')
      File "/opt/openerp-7.0/openerp/modules/loading.py", line 126, in _load_data
        tools.convert_xml_import(cr, module_name, fp, idref, mode, noupdate, report)
      File "/opt/openerp-7.0/openerp/tools/convert.py", line 954, in convert_xml_import
        obj.parse(doc.getroot())
      File "/opt/openerp-7.0/openerp/tools/convert.py", line 847, in parse
        self._tags[rec.tag](self.cr, rec, n)
      File "/opt/openerp-7.0/openerp/tools/convert.py", line 814, in _tag_record
        id = self.pool.get('ir.model.data')._update(cr, self.uid, rec_model, self.module, res, rec_id or False, not self.isnoupdate(data_node), noupdate=self.isnoupdate(data_node), mode=self.mode, context=rec_context )
      File "/opt/openerp-7.0/openerp/addons/base/ir/ir_model.py", line 956, in _update
        res_id = model_obj.create(cr, uid, values, context=context)
      File "/opt/openerp-7.0/openerp/addons/base/res/res_partner.py", line 390, in create
        return super(res_partner,self).create(cr, uid, vals, context=context)
      File "/opt/openerp-7.0/openerp/osv/orm.py", line 4436, in create
        cr.execute('insert into "'+self._table+'" (id'+upd0+") values ("+str(id_new)+upd1+')', tuple(upd2))
      File "/opt/openerp-7.0/openerp/sql_db.py", line 162, in wrapper
        return f(self, *args, **kwargs)
      File "/opt/openerp-7.0/openerp/sql_db.py", line 227, in execute
        res = self._obj.execute(query, params)
    IntegrityError: null value in column "name" violates not-null constraint

    2013-02-18 16:07:12,146 5934 ERROR openerp6 openerp.netsvc: Unable to use a closed cursor.
    Traceback (most recent call last):
      File "/opt/openerp-7.0/openerp/netsvc.py", line 289, in dispatch_rpc
        result = ExportService.getService(service_name).dispatch(method, params)
      File "/opt/openerp-7.0/openerp/service/web_services.py", line 122, in dispatch
        return fn(*params)
      File "/opt/openerp-7.0/openerp/service/web_services.py", line 168, in exp_create_database
        _initialize_db(self, id, db_name, demo, lang, user_password)
      File "/opt/openerp-7.0/openerp/service/web_services.py", line 98, in _initialize_db
        cr.close()
      File "/opt/openerp-7.0/openerp/sql_db.py", line 161, in wrapper
        raise psycopg2.OperationalError(msg)
    OperationalError: Unable to use a closed cursor.
0

Bole

--Bole--
2385
| 5 4 6
Zagreb | Karlovac, Croatia
--Bole--

there is only 10 kind of people the ones that understand binary ... and others

Bole
On 2/20/13, 6:29 AM

How are you suppliyng demo data? using XML file , csv or sql insert ?

check if all needed fields are provided in dataset, hope it helps:)

I'm using the Management of Database and I'm just checking the check box in the form, where they ask the new name for database, the password and if we want to fill database with demo data... Probably is because de demo data doesn't have information for the fields that I've added in res_partner...

Versão Integral, Anabela Damas
on 2/20/13, 7:54 AM

could you try editing file /opt/openerp-7.0/openerp/addons/base/res/res_partner_image_demo.xml:77: and remove what is between<image>tags ( or remove complete <image> field? then retry with import?

Bole
on 2/20/13, 8:23 AM

Thanks a lot I've commented this : <!-- record id="base.res_partner_address_32" model="res.partner"> <field name="image">iVBO.....R</record --> And now it's ok!

Versão Integral, Anabela Damas
on 2/20/13, 10:30 AM

About This Community

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

Question tools

0 follower(s)

Stats

Asked: 2/18/13, 12:31 PM
Seen: 6488 times
Last updated: 3/16/15, 8:10 AM