Issue when categories are ordered

Bug #495381 reported by Salvador Sierra
20
This bug affects 4 people
Affects Status Importance Assigned to Milestone
Magento OpenERP Connector
Fix Released
Undecided
Sharoon Thomas http://openlabs.co.in

Bug Description

Hi,

We have detected the flowing issue. If a category is sorted in Magento it gives the following error in OpenERP

ValidateError

The value "['name']" for the field "available_sort_by" is not in the selection

Revision history for this message
Sharoon Thomas http://openlabs.co.in (sharoonthomas) wrote :

Looks like i missed the API backend codes and the selection field values for something.
Can you paste the stack trace?

Changed in magentoerpconnect:
assignee: nobody → Sharoon Thomas (sharoonthomas)
status: New → Confirmed
Revision history for this message
Salvador Sierra (salvador-sierra) wrote :

Hi,

I updated the module and now I do not get the same error, but this is what I get:

Environment Information :
System : Darwin-9.8.0-i386-32bit
OS Name : posix
Your System is not lsb compliant
Operating System Release : 9.8.0
Operating System Version : Darwin Kernel Version 9.8.0: Wed Jul 15 16:55:01 PDT 2009; root:xnu-1228.15.4~1/RELEASE_I386
Operating System Architecture : 32bit
Operating System Locale : NOT SET
Python Version : 2.5.1
OpenERP-Client Version : 5.0.6
Last revision No. & ID :Bazaar Package not Found !Traceback (most recent call last):
  File "/usr/lib/python2.5/site-packages/openerp-server/netsvc.py", line 244, in dispatch
    result = LocalService(service_name)(method, *params)
  File "/usr/lib/python2.5/site-packages/openerp-server/netsvc.py", line 73, in __call__
    return getattr(self, method)(*params)
  File "/usr/lib/python2.5/site-packages/openerp-server/service/web_services.py", line 583, in execute
    res = service.execute(db, uid, object, method, *args)
  File "/usr/lib/python2.5/site-packages/openerp-server/osv/osv.py", line 61, in wrapper
    return f(self, dbname, *args, **kwargs)
  File "/usr/lib/python2.5/site-packages/openerp-server/osv/osv.py", line 120, in execute
    res = pool.execute_cr(cr, uid, obj, method, *args, **kw)
  File "/usr/lib/python2.5/site-packages/openerp-server/osv/osv.py", line 112, in execute_cr
    return getattr(object, method)(cr, uid, *args, **kw)
  File "/usr/lib/python2.5/site-packages/openerp-server/addons/magentoerpconnect/magerp_core.py", line 70, in sync_categs
    self.pool.get('product.category').record_entire_tree(cr, uid, inst.id, pro_cat_conn, categ_tree, DEBUG)
  File "/usr/lib/python2.5/site-packages/openerp-server/addons/magentoerpconnect/product.py", line 107, in record_entire_tree
    def record_entire_tree(self, cr, uid, id, conn, categ_tree, DEBUG=False):
  File "/usr/lib/python2.5/site-packages/openerp-server/addons/magentoerpconnect/product.py", line 116, in record_category
    imp_vals = conn.call('category.info', [category_id])
  File "/usr/lib/python2.5/site-packages/openerp-server/addons/base_external_referentials/external_osv.py", line 162, in ext_import
    if self.write(cr, uid, existing_rec_id, vals, context):
  File "/usr/lib/python2.5/site-packages/openerp-server/addons/magentoerpconnect/product.py", line 104, in write
    vals['magerp_stamp'] = time.strftime('%Y-%m-%d %H:%M:%S')
  File "/usr/lib/python2.5/site-packages/openerp-server/osv/orm.py", line 2427, in write
    fobj = self._inherit_fields[field][2]
KeyError: 'magento_exportable'

Also after the update I can't access the products, so I guess this could be another issue with the last revision.

This is the error message I get when I try to access to products:

Can't find field 'magento_exportable' in the following view parts composing the view of object model 'product.product':
 * product.normal.form_magerp

Either you wrongly customised this view, or some modules bringing those views are not compatible with your current data model

Revision history for this message
Raphaël Valyi - http://www.akretion.com (rvalyi) wrote : Re: [Bug 495381] Re: Issue when categories are ordered
Download full text (4.2 KiB)

Hello Salvador,

I think we fixed the previous bug you mentioned indeed.
For that one, you have to reload the mapping (button in Magento instance
management) before importing again. As you can read in the commit messages,
we indeed changed the name of the field 'exportable' to 'magento_exportable'
to prevent possible future incompatibilities when other ecommerce connectors
might be installed on the same OpenERP instance.

Basically it will update the mapping of the field "name" in
product.category.

Please tell us how it goes.

Raphaël Valyi

On Fri, Dec 11, 2009 at 11:22 AM, ssierra <email address hidden> wrote:

> Hi,
>
> I updated the module and now I do not get the same error, but this is
> what I get:
>
>
> Environment Information :
> System : Darwin-9.8.0-i386-32bit
> OS Name : posix
> Your System is not lsb compliant
> Operating System Release : 9.8.0
> Operating System Version : Darwin Kernel Version 9.8.0: Wed Jul 15 16:55:01
> PDT 2009; root:xnu-1228.15.4~1/RELEASE_I386
> Operating System Architecture : 32bit
> Operating System Locale : NOT SET
> Python Version : 2.5.1
> OpenERP-Client Version : 5.0.6
> Last revision No. & ID :Bazaar Package not Found !Traceback (most recent
> call last):
> File "/usr/lib/python2.5/site-packages/openerp-server/netsvc.py", line
> 244, in dispatch
> result = LocalService(service_name)(method, *params)
> File "/usr/lib/python2.5/site-packages/openerp-server/netsvc.py", line 73,
> in __call__
> return getattr(self, method)(*params)
> File
> "/usr/lib/python2.5/site-packages/openerp-server/service/web_services.py",
> line 583, in execute
> res = service.execute(db, uid, object, method, *args)
> File "/usr/lib/python2.5/site-packages/openerp-server/osv/osv.py", line
> 61, in wrapper
> return f(self, dbname, *args, **kwargs)
> File "/usr/lib/python2.5/site-packages/openerp-server/osv/osv.py", line
> 120, in execute
> res = pool.execute_cr(cr, uid, obj, method, *args, **kw)
> File "/usr/lib/python2.5/site-packages/openerp-server/osv/osv.py", line
> 112, in execute_cr
> return getattr(object, method)(cr, uid, *args, **kw)
> File
> "/usr/lib/python2.5/site-packages/openerp-server/addons/magentoerpconnect/magerp_core.py",
> line 70, in sync_categs
> self.pool.get('product.category').record_entire_tree(cr, uid, inst.id,
> pro_cat_conn, categ_tree, DEBUG)
> File
> "/usr/lib/python2.5/site-packages/openerp-server/addons/magentoerpconnect/product.py",
> line 107, in record_entire_tree
> def record_entire_tree(self, cr, uid, id, conn, categ_tree,
> DEBUG=False):
> File
> "/usr/lib/python2.5/site-packages/openerp-server/addons/magentoerpconnect/product.py",
> line 116, in record_category
> imp_vals = conn.call('category.info', [category_id])
> File
> "/usr/lib/python2.5/site-packages/openerp-server/addons/base_external_referentials/external_osv.py",
> line 162, in ext_import
> if self.write(cr, uid, existing_rec_id, vals, context):
> File
> "/usr/lib/python2.5/site-packages/openerp-server/addons/magentoerpconnect/product.py",
> line 104, in write
> vals['magerp_stamp'] = time.strftime('%Y-%m-%d %H:%M:%S')
> File "/usr/lib/python2.5/site-packages/openerp-server/osv/...

Read more...

Revision history for this message
Raphaël Valyi - http://www.akretion.com (rvalyi) wrote :
Download full text (4.7 KiB)

BTW, you should update your magentoerpconnect module database params before
refreshing the mappings, you do that by restarting with
--update=magentoerpconect --database=your_base.
However, because of an OpenERP bug, you would also have to do what is told
here: https://bugs.launchpad.net/magentoerpconnect/+bug/484843

Hope this helps

Raphaël Valyi
http://www.akretion.com

2009/12/11 Raphaël Valyi <email address hidden>

> Hello Salvador,
>
> I think we fixed the previous bug you mentioned indeed.
> For that one, you have to reload the mapping (button in Magento instance
> management) before importing again. As you can read in the commit messages,
> we indeed changed the name of the field 'exportable' to 'magento_exportable'
> to prevent possible future incompatibilities when other ecommerce connectors
> might be installed on the same OpenERP instance.
>
> Basically it will update the mapping of the field "name" in
> product.category.
>
> Please tell us how it goes.
>
> Raphaël Valyi
>
>
>
> On Fri, Dec 11, 2009 at 11:22 AM, ssierra <email address hidden>wrote:
>
>> Hi,
>>
>> I updated the module and now I do not get the same error, but this is
>> what I get:
>>
>>
>> Environment Information :
>> System : Darwin-9.8.0-i386-32bit
>> OS Name : posix
>> Your System is not lsb compliant
>> Operating System Release : 9.8.0
>> Operating System Version : Darwin Kernel Version 9.8.0: Wed Jul 15
>> 16:55:01 PDT 2009; root:xnu-1228.15.4~1/RELEASE_I386
>> Operating System Architecture : 32bit
>> Operating System Locale : NOT SET
>> Python Version : 2.5.1
>> OpenERP-Client Version : 5.0.6
>> Last revision No. & ID :Bazaar Package not Found !Traceback (most recent
>> call last):
>> File "/usr/lib/python2.5/site-packages/openerp-server/netsvc.py", line
>> 244, in dispatch
>> result = LocalService(service_name)(method, *params)
>> File "/usr/lib/python2.5/site-packages/openerp-server/netsvc.py", line
>> 73, in __call__
>> return getattr(self, method)(*params)
>> File
>> "/usr/lib/python2.5/site-packages/openerp-server/service/web_services.py",
>> line 583, in execute
>> res = service.execute(db, uid, object, method, *args)
>> File "/usr/lib/python2.5/site-packages/openerp-server/osv/osv.py", line
>> 61, in wrapper
>> return f(self, dbname, *args, **kwargs)
>> File "/usr/lib/python2.5/site-packages/openerp-server/osv/osv.py", line
>> 120, in execute
>> res = pool.execute_cr(cr, uid, obj, method, *args, **kw)
>> File "/usr/lib/python2.5/site-packages/openerp-server/osv/osv.py", line
>> 112, in execute_cr
>> return getattr(object, method)(cr, uid, *args, **kw)
>> File
>> "/usr/lib/python2.5/site-packages/openerp-server/addons/magentoerpconnect/magerp_core.py",
>> line 70, in sync_categs
>> self.pool.get('product.category').record_entire_tree(cr, uid, inst.id,
>> pro_cat_conn, categ_tree, DEBUG)
>> File
>> "/usr/lib/python2.5/site-packages/openerp-server/addons/magentoerpconnect/product.py",
>> line 107, in record_entire_tree
>> def record_entire_tree(self, cr, uid, id, conn, categ_tree,
>> DEBUG=False):
>> File
>> "/usr/lib/python2.5/site-packages/openerp-server/addons/magentoerpconnect/product.py",
>> line 116, in record_cate...

Read more...

Revision history for this message
Raphaël Valyi - http://www.akretion.com (rvalyi) wrote :

From ssierra:

"Hi,

thanks for you prompt reply. We installed from scratch and updated the connector to the latest version (revision 266).

We are still getting the original error when we try to import the categories.

Best regards"

Hello Salvador, please let's keep that bug thread here.
Ok, I confirm what you say, for some unknown reason, refresh the mapping doesn't refresh the name field mapping. Please delete it first from the product category mapping fields, then reload the mappings and make sure it's mapped properly.

We will investigate why the mapping has not been reloaded.

Revision history for this message
Kyle Waid (midwest) wrote :

Hi, We had this same problem. What we did was remove those fields from the database and we were able to import our categories no problem.

Revision history for this message
Kyle Waid (midwest) wrote :

Update, if there is any entry at all in the available_sort_by column in the database it will fail. Downloading categories requires that the entire column be empty.

Revision history for this message
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote :

Hello,

I'm not an Magento expert, but it seems to me that these codes may vary depending on configuration and modules installed on Magento. Someone can confirm / infirm that ?

You have to ensure that your configuration of Magento uses the same codes that the ones defined in the available_sort_by and default_sort_by fields of product.category.

To know them, you can display the source of the web page in the magento's administration where the fields are displayed (edit categories). In the source, check the value attribute of each option.

In our case, we have specific customizations on Magento so we anyway had to modify these codes.
You can put them in a configuration module just by overriding the columns, something like that :

class ProductCategory(magerp_osv.magerp_osv):
    """Modify the available magento sorting options."""
    _inherit = "product.category"

    SORT_BY_OPTIONS = (
        ('None', 'Use Config Settings'),
        ('position', 'Position'),
        ('price', 'Price'),
        ('custom_default_manufacturer', 'Manufacturer'),
        ('custom_rdc_availability', 'Availability'),
    )

    _columns = {
        'available_sort_by': fields.selection(
                            SORT_BY_OPTIONS,
                            'Available Product Listing (Sort By)',
                            size=32),
        'default_sort_by': fields.selection(
                            SORT_BY_OPTIONS,
                            'Default Product Listing Sort (Sort By)',
                            size=32),
    }

ProductCategory()

Regards
Guewen

Revision history for this message
Raphaël Valyi - http://www.akretion.com (rvalyi) wrote :

Guewen,

I confirm we have to use those kind of hacks. So far I've seen no better way
than what you say. We also sometimes patch magentoerpconnect instead to
match these new options that indeed depend on the exact modules that are
installed on your Magento.

On Thu, Jan 6, 2011 at 1:08 PM, Guewen Baconnier @ Camptocamp <
<email address hidden>> wrote:

> Hello,
>
> I'm not an Magento expert, but it seems to me that these codes may vary
> depending on configuration and modules installed on Magento. Someone
> can confirm / infirm that ?
>
> You have to ensure that your configuration of Magento uses the same
> codes that the ones defined in the available_sort_by and default_sort_by
> fields of product.category.
>
> To know them, you can display the source of the web page in the
> magento's administration where the fields are displayed (edit
> categories). In the source, check the value attribute of each option.
>
> In our case, we have specific customizations on Magento so we anyway had to
> modify these codes.
> You can put them in a configuration module just by overriding the columns,
> something like that :
>
> class ProductCategory(magerp_osv.magerp_osv):
> """Modify the available magento sorting options."""
> _inherit = "product.category"
>
> SORT_BY_OPTIONS = (
> ('None', 'Use Config Settings'),
> ('position', 'Position'),
> ('price', 'Price'),
> ('custom_default_manufacturer', 'Manufacturer'),
> ('custom_rdc_availability', 'Availability'),
> )
>
> _columns = {
> 'available_sort_by': fields.selection(
> SORT_BY_OPTIONS,
> 'Available Product Listing (Sort By)',
> size=32),
> 'default_sort_by': fields.selection(
> SORT_BY_OPTIONS,
> 'Default Product Listing Sort (Sort By)',
> size=32),
> }
>
> ProductCategory()
>
> Regards
> Guewen
>
> --
> You received this bug notification because you are subscribed to Magento
> Open ERP Connector.
> https://bugs.launchpad.net/bugs/495381
>
> Title:
> Issue when categories are ordered
>
> Status in Magento Open ERP Connector:
> Confirmed
>
> Bug description:
> Hi,
>
> We have detected the flowing issue. If a category is sorted in Magento it
> gives the following error in OpenERP
>
> ValidateError
>
> The value "['name']" for the field "available_sort_by" is not in the
> selection
>
>
>

Revision history for this message
Kirill Shnurov (k-zx0) wrote :

Here's a little bit dirty but helpful workaround. You need to change mappings for categories. Patch included.

available_sort_by - result=[('available_sort_by',ifield.replace('[','').replace(']','').split(',')[0].replace('\'',''))]
default_sort_by - result=[('default_sort_by',ifield.replace('[','').replace(']','').split(',')[0].replace('\'',''))]

Revision history for this message
Randy (first-domain) wrote :

Hi all,
Regarding previous solutions:
I'm using magento 1.5.1.0 and openerp 6.0.2 (both on ubuntu linux, different machines on internal network)
I've gotten the connector to work and I'm also not able to import categories with the first bug notification above (ending with... value..not in the selection). I'm not a python programmer but struggeling to get this fixed.
Can somebody please explain the steps how to exactly apply above mentioned workarounds?

Regarding answer no 8 above: should this be applied to the code (replacing the code) before the module is imported into openerp or after in the path /opt/openerp/server/bin/addons/magentoerpconnect? Can you also just remove "('name', 'Name')," from the code? Magento install is standard.

Should answer no 10 then also be applied or do you use the one or the other.

Is there an updated connector without these errors available?
Using: bzr branch lp:magentoerpconnect/openerp6-module right now.

If this is the wrong place for these questions, apologies and please direct me to the right place.

Rgds,

Randy

Revision history for this message
Sébastien BEAU - http://www.akretion.com (sebastien.beau) wrote :

Hi all refactor the code for trunk version (rev 469 470). Now available_sort_by and default_sort_by are imported correctly in openerp as many2many and many2one. There is still one bug when we export the category from OpenERP to Magento. You can easily by-pass it by using the default value for this two fields.
https://code.launchpad.net/~magentoerpconnect-core-editors/magentoerpconnect/trunk_version

I close this bug, and I open a new bug regarding the bug is the magento API
https://bugs.launchpad.net/magentoerpconnect/+bug/87631

Best Regards

Changed in magentoerpconnect:
status: Confirmed → Fix Released
Revision history for this message
Sébastien BEAU - http://www.akretion.com (sebastien.beau) wrote :

sorry the start of my message was :
Hi all
I refactor...

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.