~openerp-chinese-team/magentoerpconnect/guest-order-bug-fix

« back to all changes in this revision

Viewing changes to magentoerpconnect/product.py

  • Committer: Guewen Baconnier @ CampToCamp
  • Date: 2011-06-08 07:35:43 UTC
  • Revision ID: guewen.baconnier@camptocamp.com-20110608073543-o0rzb13qgqbszrc6
[ADD] Wizard to modify the SKU of a product on all magento shops. SKU is now read-only when the product is exported to at least one shop.

Show diffs side-by-side

added added

removed removed

Lines of Context:
838
838
        product_types = self.pool.get('magerp.product_product_type').read(cr, uid, ids, ['product_type','name'], context=context)
839
839
        return [(pt['product_type'], pt['name']) for pt in product_types]
840
840
 
 
841
    def _is_magento_exported(self, cr, uid, ids, field_name, arg, context):
 
842
        """Return True if the product is already exported to at least one magento shop
 
843
        """
 
844
        res = {}
 
845
        # get all magento external_referentials
 
846
        referentials = self.pool.get('external.referential').search(cr, uid, [('magento_referential', '=', True)])
 
847
        for product in self.browse(cr, uid, ids, context):
 
848
            for referential in referentials:
 
849
                res[product.id] = False
 
850
                if self.oeid_to_extid(cr, uid, product.id, referential, context):
 
851
                    res[product.id] = True
 
852
                    break
 
853
        return res
 
854
 
841
855
    _columns = {
842
856
        'magento_sku':fields.char('Magento SKU', size=64),
843
857
        'magento_exportable':fields.boolean('Exported to Magento?'),
846
860
        'tier_price':fields.one2many('product.tierprice', 'product', 'Tier Price'),
847
861
        'product_type': fields.selection(_product_type_get, 'Product Type'),
848
862
        'websites_ids': fields.many2many('external.shop.group', 'magerp_product_shop_group_rel', 'product_id', 'shop_group_id', 'Websites', help='By defaut product will be exported on every website, if you want to exporte it only on some website select them here'),
 
863
        'magento_exported': fields.function(_is_magento_exported, type="boolean", method=True, string="Exists on Magento"),  # used to set the sku readonly when already exported
849
864
        }
850
865
 
851
866
    _defaults = {