SQL change for revision 4315 base_external_referentials

Asked by Nautica

Revision 4315 of base_exterenal_referentials needs an SQL command to migrate existing data. The text in this revision is: [REF] base_external_referentials WARNING!!! This a a change that need an SQL command to migrate your existing data!! We are now making the external_referential_id key of ir_model_data be a computed field based on the the module name: it should now be "extref.ref_name". In that case the matching external referential is searched with name=ref_name. So you must update your ir_model_data to module name to that new pattern for all synch'ed entities having an external_referential_id!! This change was meant to avoid issues with similar ext_ref in different referentials (existing ir_model_data unicity contraint) and also to be more compatible with the way OpenERP import/export data with their ir_model_data.

I do not get this exactly. Can someone post an example or the SQL command to execute?

In the table ir_model_data where external_referential_id has a value (those value is 1 everywhere) and module has the value
base_external_referentials_keep. the model field field has values like sale.oder, res.partner, res.partner.address, product.product etc..

Question information

Language:
English Edit question
Status:
Solved
For:
Magento OpenERP Connector Edit question
Assignee:
No assignee Edit question
Solved by:
Nautica
Solved:
Last query:
Last reply:
Revision history for this message
Raphaël Valyi - http://www.akretion.com (rvalyi) said :
#1

Hello, we explained the purpose of the ir_model_data change here:
https://lists.launchpad.net/magentoerpconnect-community/msg00004.html

Before everything please backup your database.

All right, now let's see how to upgrade. Before updating the python code with bzr, do the following in an SQL console:
select id, name from external_referential;
For each id, this will give you the names of your external referentials (you probably have just one).

Now, for each different referential id, construct the string module_key with:
module_key = 'extref.REFNAME' where REFNAME is the related referential name found with the first query, for instance: extref.mag1

Then, perform the following update:
update ir_model_data set module = module_key where module = 'base_external_referentials_keep' and external_referential_id = ref_id;

All right, ensure that records have been updated.

Now, you can update all your magentoerpconnect and stable extra addons 5.0 python code and restart your server to enjoy an updated Magentoerpconnect connector!

Revision history for this message
Nautica (nautica1959) said :
#2

I tried the upgrade but still got errors. This is what I did:

1) i ran the query: select id, name from external_referential; This gave as a result my storename and the external_referential_id = 1
2) i constructed this update: update ir_model_data set module = 'mystorename' where module = 'base_external_referentials_keep' and external_referential_id = 1;
3) The query was succesfull and updated many rows.
4) upgraded the base_external_referentials, base_sale_mutichannels and magentoerpconnect python code
5) restarted the server.
6) to be shure i ran an update for the modules from administration.

After this i have to change the "default language" setting in Magento-Connection >> Core Settings >> Magento Instances for my connection which in my case is Dutch.

when i try to open my website from Magento Websites and double click my shopname I get this error:

Environment Information :
System : Windows-32bit
OS Name : nt
Operating System Release :
Operating System Version : 32bit
Operating System Architecture : 32bit
Operating System Locale : nl_NL.cp1252
Python Version : 2.5.2
OpenERP-Client Version : 5.0.6
Last revision No. & ID :Bazaar Package not Found !Traceback (most recent call last):
  File "netsvc.pyo", line 244, in dispatch
  File "netsvc.pyo", line 73, in __call__
  File "service\web_services.pyo", line 583, in execute
  File "osv\osv.pyo", line 59, in wrapper
  File "osv\osv.pyo", line 118, in execute
  File "osv\osv.pyo", line 110, in execute_cr
  File "osv\orm.pyo", line 2084, in read
  File "osv\orm.pyo", line 2195, in _read_flat
  File "osv\fields.pyo", line 646, in get
  File "C:\Users\Proline\OpenERP AllInOne\Server\addons\magentoerpconnect\sale.py", line 43, in _get_exportable_product_ids
  File "osv\orm.pyo", line 2827, in search
  File "osv\orm.pyo", line 2808, in _where_calc
  File "osv\expression.pyo", line 186, in parse
TypeError: 'bool' object is not iterable

Then i tried to reload referential mapping templates which was succesfulle and then Synchronise Referential Settings which fails in the next error;

Environment Information :
System : Windows-32bit
OS Name : nt
Operating System Release :
Operating System Version : 32bit
Operating System Architecture : 32bit
Operating System Locale : nl_NL.cp1252
Python Version : 2.5.2
OpenERP-Client Version : 5.0.6
Last revision No. & ID :Bazaar Package not Found !Traceback (most recent call last):
  File "netsvc.pyo", line 244, in dispatch
  File "netsvc.pyo", line 73, in __call__
  File "service\web_services.pyo", line 583, in execute
  File "osv\osv.pyo", line 59, in wrapper
  File "osv\osv.pyo", line 118, in execute
  File "osv\osv.pyo", line 110, in execute_cr
  File "C:\Users\Proline\OpenERP AllInOne\Server\addons\magentoerpconnect\magerp_core.py", line 59, in core_sync
  File "C:\Users\Proline\OpenERP AllInOne\Server\addons\magentoerpconnect\magerp_osv.py", line 259, in mage_import_base
  File "C:\Users\Proline\OpenERP AllInOne\Server\addons\base_external_referentials\external_osv.py", line 174, in ext_import
  File "C:\Users\Proline\OpenERP AllInOne\Server\addons\base_external_referentials\external_osv.py", line 197, in oe_update
  File "osv\orm.pyo", line 2353, in write
KeyError: 'magento_store_id'

Did I do something wrong or is there a bug?

Revision history for this message
Raimon Esteve (www.zikzakmedia.com) (resteve) said :
#3

> KeyError: 'magento_store_id'

add field column
        'magento_store_id':fields.integer('Store ID'),
in class
       magerp_storeviews

Revision history for this message
Nautica (nautica1959) said :
#4

I repeated all steps mentioned in my posting above.
changed the magerp_storeviews class in magerp_core.py from:

class magerp_storeviews(magerp_osv.magerp_osv):
    _name = "magerp.storeviews"
    _description = "The magento store views information"

    _columns = {
        'name':fields.char('Store View Name', size=100),
        'code':fields.char('Code', size=100),
        'website_id':fields.many2one('external.shop.group', 'Website', select=True, ondelete='cascade'),
        'is_active':fields.boolean('Default ?'),
        'sort_order':fields.integer('Sort Order'),
        'shop_id':fields.many2one('sale.shop', 'Shop', select=True, ondelete='cascade'),
        'lang_id':fields.many2one('res.lang', 'Language'),
    }

Changed to:

class magerp_storeviews(magerp_osv.magerp_osv):
    _name = "magerp.storeviews"
    _description = "The magento store views information"

    _columns = {
        'name':fields.char('Store View Name', size=100),
        'code':fields.char('Code', size=100),
        'website_id':fields.many2one('external.shop.group', 'Website', select=True, ondelete='cascade'),
        'is_active':fields.boolean('Default ?'),
        'sort_order':fields.integer('Sort Order'),
        'shop_id':fields.many2one('sale.shop', 'Shop', select=True, ondelete='cascade'),
        'lang_id':fields.many2one('res.lang', 'Language'),
 'magento_store_id':fields.integer('Store ID'),
    }

I changed the query to: update ir_model_data set module = 'mystorename' where module = 'base_external_referentials_keep' with no condition upon the external_referential_id as suggested by Raphaël in this post: https://bugs.launchpad.net/openobject-addons/+bug/570318

Now when i try to reload referential mapping templates and then Synchronise Referential Settings the previous error has been gone but now i see two websites both with the same store name but with different sale shops. one has sale shop (0) and the other sale shop (1)
When i double click the sale shop (0) there opens a window where the sale shop has NO data
When i double click the sale shop (1) there opens a window that has my shop name. Double click on the shop name i get this error:

Environment Information :
System : Windows-32bit
OS Name : nt
Operating System Release :
Operating System Version : 32bit
Operating System Architecture : 32bit
Operating System Locale : nl_NL.cp1252
Python Version : 2.5.2
OpenERP-Client Version : 5.0.6
Last revision No. & ID :Bazaar Package not Found !Traceback (most recent call last):
  File "netsvc.pyo", line 244, in dispatch
  File "netsvc.pyo", line 73, in __call__
  File "service\web_services.pyo", line 583, in execute
  File "osv\osv.pyo", line 59, in wrapper
  File "osv\osv.pyo", line 118, in execute
  File "osv\osv.pyo", line 110, in execute_cr
  File "osv\orm.pyo", line 2084, in read
  File "osv\orm.pyo", line 2195, in _read_flat
  File "osv\fields.pyo", line 646, in get
  File "C:\Users\Proline\OpenERP AllInOne\Server\addons\magentoerpconnect\sale.py", line 43, in _get_exportable_product_ids
  File "osv\orm.pyo", line 2827, in search
  File "osv\orm.pyo", line 2808, in _where_calc
  File "osv\expression.pyo", line 186, in parse
TypeError: 'bool' object is not iterable

So still not possible for me to upgrade to the latest revision :-(

Revision history for this message
Nautica (nautica1959) said :
#5

Ah My problem is solved.
Problem occurs in OpenErp AllInOne 5.06
I upgraded to 5.0.10 and now all works OK.