~initos.com/openerp-connector-magento/7.0-import_customer_lang

« back to all changes in this revision

Viewing changes to magentoerpconnect/product.py

  • Committer: Guewen Baconnier
  • Author(s): Markus Schneider
  • Date: 2014-05-26 09:33:42 UTC
  • Revision ID: guewen.baconnier@camptocamp.com-20140526093342-1saabnijcfmatni5
Add module to configure active flag for product import

Show diffs side-by-side

added added

removed removed

Lines of Context:
395
395
 
396
396
 
397
397
@magento
 
398
class IsActiveProductImportMapper(ImportMapper):
 
399
    _model_name = 'magento.product.product'
 
400
 
 
401
    @mapping
 
402
    def is_active(self, record):
 
403
        """Check if the product is active in Magento
 
404
        and set active flag in OpenERP
 
405
        status == 1 in Magento means active"""
 
406
        return {'active': (record.get('status') == '1')}
 
407
 
 
408
 
 
409
@magento
398
410
class ProductImportMapper(ImportMapper):
399
411
    _model_name = 'magento.product.product'
400
412
    # TODO :     categ, special_price => minimal_price
411
423
 
412
424
    @mapping
413
425
    def is_active(self, record):
414
 
        """ If the product is not active in Magento, it sets
415
 
        sale_ok and purchase_ok to False.
416
 
 
417
 
        '1' is a constant value in Magento, which means that the product
418
 
        is active
419
 
        """
420
 
        if record.get('status') != '1':
421
 
            return {'sale_ok': False,
422
 
                    'purchase_ok': False}
 
426
        mapper = self.get_connector_unit_for_model(IsActiveProductImportMapper)
 
427
        return mapper.map_record(record).values()
423
428
 
424
429
    @mapping
425
430
    def price(self, record):