~arthru/prestashoperpconnect/fix-1199664

« back to all changes in this revision

Viewing changes to prestashoperpconnect/product.py

  • Committer: Sébastien Beau
  • Date: 2013-07-07 09:46:53 UTC
  • Revision ID: sebastien.beau@akretion.com-20130707094653-mnmqw4x6y4gdomvb
[FIX] fix import of product if the category field is empty

Show diffs side-by-side

added added

removed removed

Lines of Context:
198
198
 
199
199
    @mapping
200
200
    def categ_id(self, record):
201
 
        return {'categ_id': self.get_openerp_id(
202
 
            'prestashop.product.category',
203
 
            record['id_category_default']
204
 
        )}
 
201
        if int(record['id_category_default']):
 
202
            return {'categ_id': self.get_openerp_id(
 
203
                'prestashop.product.category',
 
204
                record['id_category_default']
 
205
            )}
205
206
 
206
207
    @mapping
207
208
    def categ_ids(self, record):
208
 
        categories = record['associations']['categories']['category']
 
209
        categories = record['associations'].get('categories', {}).get('category', [])
209
210
        if not isinstance(categories, list):
210
211
            categories = [categories]
211
212
        product_categories = []