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

How to update stock module with this error?

By
Pascal Tremblay
on 3/14/15, 6:09 PM 1,341 views

Hello guys,

It's impossible to update neither my stock module nor all module (of course). Always get an error.

I would say that updating sotck module delete my custom locations. But one of them is used two or three times in purchase orders. So stock module can't finish his update...

Why does stock module try to delete locations?

I believe I should create my locations in a custom module with XML...

I really need your comments here... 2 days on this error...

Here is the log.

2015-03-14 22:01:45,674 15536 WARNING 03test openerp.addons.base.ir.ir_translation: module stock_invoice_directly: no translation for language fr_CA
2015-03-14 22:01:45,747 15536 INFO 03test openerp.modules.loading: 122 modules loaded in 40.68s, 0 queries
2015-03-14 22:01:46,676 15536 INFO 03test openerp.addons.base.ir.ir_model: Deleting 40@stock.location
2015-03-14 22:01:46,682 15536 ERROR 03test openerp.sql_db: bad query: delete from stock_location where id IN (40)
Traceback (most recent call last):
  File "/home/odoo-test/odoo-test/openerp/sql_db.py", line 234, in execute
    res = self._obj.execute(query, params)
IntegrityError: null value in column "location_id" violates not-null constraint
DETAIL:  Failing row contains (74, null, 2015-02-11 13:50:17.595482, 1, 5, 2015-01-07 05:00:00, null, null, 8, 43, 4.86, 1, 1112, 2015-02-12 13:50:06, 3, 0.00, done, null, 2, null, 1, null, null, 2015-02-12 13:50:06.545753, null, 2015-02-11, 4.86, 2015-DP000020, null, order, t, 8, 2015-01-08, 40).
CONTEXT:  SQL statement "UPDATE ONLY "public"."purchase_order" SET "location_id" = NULL WHERE $1 OPERATOR(pg_catalog.=) "location_id""

2015-03-14 22:01:46,685 15536 INFO 03test openerp.modules.loading: loading 1 modules...
2015-03-14 22:01:46,797 15536 INFO 03test openerp.modules.loading: 1 modules loaded in 0.11s, 0 queries
2015-03-14 22:01:46,838 15536 INFO 03test openerp.modules.loading: loading 122 modules...
2015-03-14 22:01:48,595 15536 INFO 03test openerp.modules.loading: 122 modules loaded in 1.76s, 0 queries
2015-03-14 22:01:49,098 15536 INFO 03test openerp.modules.loading: Modules loaded.
2015-03-14 22:01:49,100 15536 ERROR 03test openerp.http: Exception during JSON request handling.
Traceback (most recent call last):
  File "/home/odoo-test/odoo-test/openerp/http.py", line 525, in _handle_exception
    return super(JsonRequest, self)._handle_exception(exception)
  File "/home/odoo-test/odoo-test/openerp/http.py", line 562, in dispatch
    result = self._call_function(**self.params)
  File "/home/odoo-test/odoo-test/openerp/http.py", line 302, in _call_function
    return checked_call(self.db, *args, **kwargs)
  File "/home/odoo-test/odoo-test/openerp/service/model.py", line 149, in wrapper
    raise openerp.osv.orm.except_orm(_('Integrity Error'), msg)
except_orm: ('Integrity Error', 'The operation cannot be completed, probably due to the following:\n- deletion: you may be trying to delete a record while other records still reference it\n- creation/update: a mandatory field is not correctly set\n\n[object with reference: Purchase Order - purchase.order]')

2015-03-14 22:01:49,101 15536 INFO 03test werkzeug: 192.168.1.1 - - [14/Mar/2015 22:01:49] "POST /web/dataset/call_button HTTP/1.1" 200 -
2015-03-14 22:01:49,102 15536 INFO 03test werkzeug: 192.168.1.1 - - [14/Mar/2015 22:01:49] "POST /longpolling/poll HTTP/1.1" 200 -
2015-03-14 22:01:49,103 15536 INFO 03test werkzeug: 192.168.1.1 - - [14/Mar/2015 22:01:49] "POST /longpolling/poll HTTP/1.1" 200 -
2015-03-14 22:01:49,118 15536 INFO 03test openerp.addons.base.ir.ir_http: Generating routing map

...

Thanks all!!!!

UPDATE #1

  • I see that stock module import the defaults location with the file /home/odoo-test/odoo-test/addons/stock/stock_data.xml;

UPDATE #2

  • Error is not the same if I use -u stock in terminal.
  • 2015-03-15 00:15:56,172 9152 INFO 03test openerp.modules.loading: 122 modules loaded in 40.14s, 0 queries
    2015-03-15 00:15:57,087 9152 INFO 03test openerp.addons.base.ir.ir_model: Deleting 40@stock.location
    2015-03-15 00:15:57,093 9152 CRITICAL 03test openerp.service.server: Failed to initialize database `03test`.
    Traceback (most recent call last):
      File "/home/odoo-test/odoo-test/openerp/service/server.py", line 909, in preload_registries
        registry = RegistryManager.new(dbname, update_module=update_module)
      File "/home/odoo-test/odoo-test/openerp/modules/registry.py", line 346, in new
        openerp.modules.load_modules(registry._db, force_demo, status, update_module)
      File "/home/odoo-test/odoo-test/openerp/modules/loading.py", line 390, in load_modules
        registry['ir.model.data']._process_end(cr, SUPERUSER_ID, processed_modules)
      File "/home/odoo-test/odoo-test/openerp/api.py", line 241, in wrapper
        return old_api(self, *args, **kwargs)
      File "/home/odoo-test/odoo-test/openerp/addons/base/ir/ir_model.py", line 1244, in _process_end
        self.pool[model].unlink(cr, uid, [res_id])
      File "/home/odoo-test/odoo-test/openerp/api.py", line 241, in wrapper
        return old_api(self, *args, **kwargs)
      File "/home/odoo-test/odoo-test/openerp/models.py", line 3551, in unlink
        'where id IN %s', (sub_ids,))
      File "/home/odoo-test/odoo-test/openerp/sql_db.py", line 158, in wrapper
        return f(self, *args, **kwargs)
      File "/home/odoo-test/odoo-test/openerp/sql_db.py", line 234, in execute
        res = self._obj.execute(query, params)
    IntegrityError: null value in column "location_id" violates not-null constraint
    DETAIL:  Failing row contains (74, null, 2015-02-11 13:50:17.595482, 1, 5, 2015-01-07 05:00:00, null, null, 8, 43, 4.86, 1, 1112, 2015-02-12 13:50:06, 3, 0.00, done, null, 2, null, 1, null, null, 2015-02-12 13:50:06.545753, null, 2015-02-11, 4.86, 2015-DP000020, null, order, t, 8, 2015-01-08, 40).
    CONTEXT:  SQL statement "UPDATE ONLY "public"."purchase_order" SET "location_id" = NULL WHERE $1 OPERATOR(pg_catalog.=) "location_id""

     

0

Have you found a solution since march ? We run in the same error.

Finally we solved our problem.

Here is the whole story:

We added a stock.warehouse and a few stock.location with a yml File see down, but without noupdate in the line starting with "xml_references". The automatically created stock.location while creating a stock.warehouse had then noupdate = False and the update process tried to remove the stock.location. This was not possible due to a not null constraint for the foreign key lot_stock_id and the same error message as Pascal describes was raised.

Solution:

The noupdate Flag in the line (see here) is essential, since the stock.location "lot_stock_id" in stock.warehouse is created automatically and per default with noupdate = False. The !context noupdate:1 in the beginning of the file is not sufficient.

xml_references = [

{'name': 'stock_location_company_wwi', 'module': 'stock', 'model': 'stock.location', 'res_id':warehouse.lot_stock_id.id, 'noupdate': 1},

]

YML File for stock.warehouse and stock.location:

-

Data persistence

-

!context

noupdate: 1

-

Warehouse

-

!record {model: stock.warehouse, id: stock.stock_warehouse_company_wwi}:

name: WWI

partner_id: base.wwi_partner

company_id: base.wwi_company

code: WWI

-

!python {model: ir.model.data}: |

warehouse = self.pool.get('stock.warehouse').browse(cr, uid, ref('stock.stock_warehouse_company_wwi'), context=context)

#create xml ids for demo data that are widely used in tests or in other codes, for more convenience

xml_references = [

{'name': 'stock_location_company_wwi', 'module': 'stock', 'model': 'stock.location', 'res_id':warehouse.lot_stock_id.id, 'noupdate': 1},

]

for xml_record in xml_references:

xml_ids = self.search(cr, uid, [('module', '=', xml_record['module']), ('model', '=', xml_record['model']), ('name', '=', xml_record['name'])], context=context)

if not xml_ids:

self.create(cr, uid, xml_record, context=context)

#avoid the xml id and the associated resource being dropped by the orm by manually making a hit on it

self._update_dummy(cr, uid, xml_record['model'], xml_record['module'], xml_record['name'])

-

!record {model: stock.location, id: stock.stock_location_company_wwi_hall1}:

name: Hall 1

usage: internal

location_id: stock.stock_location_company_wwi

partner_id: base.wwi_partner

company_id: base.wwi_company





cheers

Michael

hum... very long time. I don't really remember. Are you ok finally?

Pascal Tremblay
on 9/30/15, 10:00 PM

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: 3/14/15, 6:09 PM
Seen: 1341 times
Last updated: 10/1/15, 6:54 AM