Merge lp:~openerp-dev/openobject-server/6.0-opw-50559-vro into lp:openobject-server/6.0

Proposed by Valencia Rodrigues (OpenERP)
Status: Merged
Merge reported by: Olivier Laurent (Open ERP)
Merged at revision: not available
Proposed branch: lp:~openerp-dev/openobject-server/6.0-opw-50559-vro
Merge into: lp:openobject-server/6.0
Diff against target: 12 lines (+1/-1)
1 file modified
bin/osv/orm.py (+1/-1)
To merge this branch: bzr merge lp:~openerp-dev/openobject-server/6.0-opw-50559-vro
Reviewer Review Type Date Requested Status
Vinay Rana (OpenERP) (community) Approve
Olivier Laurent (Open ERP) Pending
nel Pending
Review via email: mp+83287@code.launchpad.net

Description of the change

Hello,

Currently, one cannot update inactive records via import (case ref:50559). To regenerate the issue please follow the steps below:

1. Deactivate a product from Sales > Products > Products.
2. From the list view, apply a filter to search for the inactive product.
3. Export this record to a CSV file with the fields Database ID, Active and Name.
4. Change the Name of the product in the CSV file and attempt to import the changes.

The following traceback is encountered:

Environment Information :
System : Linux-2.6.32-35-generic-i686-with-Ubuntu-10.04-lucid
OS Name : posix
LSB Version: core-2.0-ia32:core-2.0-noarch:core-3.0-ia32:core-3.0-noarch:core-3.1-ia32:core-3.1-noarch:core-3.2-ia32:core-3.2-noarch:core-4.0-ia32:core-4.0-noarch
Distributor ID: Ubuntu
Description: Ubuntu 10.04.3 LTS
Release: 10.04
Codename: lucid
Operating System Release : 2.6.32-35-generic
Operating System Version : #78-Ubuntu SMP Tue Oct 11 15:27:15 UTC 2011
Operating System Architecture : 32bit
Operating System Locale : en_IN.ISO8859-1
Python Version : 2.6.5
OpenERP-Client Version : 6.0.3
Last revision No. & ID :1914 launchpad_translations_on_behalf_of_openerp-20111119054707-8r5h65cf6eef789o
Traceback (most recent call last):
  File "/home/tiny/workspace/6.0/openobject-server/bin/netsvc.py", line 489, in dispatch
    result = ExportService.getService(service_name).dispatch(method, auth, params)
  File "/home/tiny/workspace/6.0/openobject-server/bin/service/web_services.py", line 599, in dispatch
    res = fn(db, uid, *params)
  File "/home/tiny/workspace/6.0/openobject-server/bin/osv/osv.py", line 122, in wrapper
    return f(self, dbname, *args, **kwargs)
  File "/home/tiny/workspace/6.0/openobject-server/bin/osv/osv.py", line 176, in execute
    res = self.execute_cr(cr, uid, obj, method, *args, **kw)
  File "/home/tiny/workspace/6.0/openobject-server/bin/osv/osv.py", line 167, in execute_cr
    return getattr(object, method)(cr, uid, *args, **kw)
  File "/home/tiny/workspace/6.0/openobject-server/bin/osv/orm.py", line 871, in import_data
    process_liness(self, datas, [], current_module, self._name, fields_def, position=position)
  File "/home/tiny/workspace/6.0/openobject-server/bin/osv/orm.py", line 790, in process_liness
    data_res_id = _get_id(model_name, line[i], current_module, '.id')
  File "/home/tiny/workspace/6.0/openobject-server/bin/osv/orm.py", line 729, in _get_id
    raise Exception(_("Database ID doesn't exist: %s : %s") %(model_name, id))
Exception: Database ID doesn't exist: product.product : 45

The import_datas method uses _get_id(), which in turn employs search(). By default, search() fetches only active records.

This fix permits the search for inactive records in _get_id to fix the issue.

Thanks

To post a comment you must log in.
Revision history for this message
Vinay Rana (OpenERP) (vra-openerp) wrote :

Hello ,

As per my test cases the propose merge proposal is working good and active false should be include.

Thanks.

review: Approve
Revision history for this message
Olivier Laurent (Open ERP) (olt) wrote :

Merged in stable revision 3547

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bin/osv/orm.py'
2--- bin/osv/orm.py 2011-09-30 12:22:46 +0000
3+++ bin/osv/orm.py 2011-11-24 13:19:52 +0000
4@@ -723,7 +723,7 @@
5 if mode=='.id':
6 id = int(id)
7 obj_model = self.pool.get(model_name)
8- ids = obj_model.search(cr, uid, [('id', '=', int(id))], context=context)
9+ ids = obj_model.search(cr, uid, [('id', '=', int(id)),('active','in',['True','False'])], context=context)
10 if not len(ids):
11 raise Exception(_("Database ID doesn't exist: %s : %s") %(model_name, id))
12 elif mode=='id':