~magentoerpconnect-core-editors/magentoerpconnect/oerp6.1-stable

« back to all changes in this revision

Viewing changes to magentoerpconnect/sale.py

  • Committer: Sébastien Beau
  • Date: 2013-06-06 17:53:04 UTC
  • mfrom: (685.1.4 magentoerpconnect)
  • Revision ID: sebastien.beau@akretion.com-20130606175304-r51kf087n169qrvv
[MERGE] merge fix from Stefan Rijnhart (Therp). Thank you for your work

Show diffs side-by-side

added added

removed removed

Lines of Context:
84
84
                res[shop_id] = []
85
85
        return res
86
86
 
 
87
    def _get_exportable_category_ids(
 
88
            self, cr, uid, ids, name, args, context=None):
 
89
        res = super(sale_shop, self)._get_exportable_category_ids(
 
90
            cr, uid, ids, name, args, context=context)
 
91
        for shop_id in res:
 
92
            res[shop_id] = self.pool.get('product.category').search(
 
93
                cr, uid,
 
94
                [
 
95
                    ('magento_exportable', '=', True),
 
96
                    ('id', 'in', res[shop_id]),
 
97
                    ],
 
98
                context=context)
 
99
        return res
 
100
 
87
101
    def _get_default_storeview_id(self, cr, uid, ids, prop, unknow_none, context=None):
88
102
        res = {}
89
103
        for shop in self.browse(cr, uid, ids, context):
114
128
    #In order to use the actual implementation
115
129
 
116
130
    def export_resources(self, cr, uid, ids, resource_name, context=None):
117
 
        if resource_name == 'product.images':
118
 
            return self.export_images(cr, uid, ids, context=context)
119
 
        else:
120
 
            return super(sale_shop, self).export_resources(cr, uid, ids, resource_name, context=context)
 
131
        if context is None:
 
132
            context = {}
 
133
        res = False
 
134
        for shop in self.browse(cr, uid, ids, context=context):
 
135
            context['conn_obj'] = shop.referential_id.external_connection(
 
136
                context=context)
 
137
            if resource_name == 'product.images':
 
138
                res = self.export_images(cr, uid, [shop.id], context=context)
 
139
            else:
 
140
                res = super(sale_shop, self).export_resources(
 
141
                    cr, uid, [shop.id], resource_name, context=context)
 
142
        return res
121
143
 
122
144
    def _get_rootcategory(self, cr, uid, ids, name, value, context=None):
123
145
        res = {}
171
193
        'magento_root_category':fields.function(_get_rootcategory, fnct_inv = _set_rootcategory, type="many2one", relation="product.category", string="Root Category"),
172
194
        'exportable_root_category_ids': fields.function(_get_exportable_root_category_ids, type="many2many", relation="product.category", method=True, string="Root Category"), #fields.function(_get_exportable_root_category_ids, type="many2one", relation="product.category", method=True, 'Exportable Root Categories'),
173
195
        'storeview_ids': fields.one2many('magerp.storeviews', 'shop_id', 'Store Views'),
 
196
        'exportable_category_ids': fields.function(
 
197
            _get_exportable_category_ids, type='many2many', relation="product.category",
 
198
            string='Exportable Categories'),
174
199
        'exportable_product_ids': fields.function(_get_exportable_product_ids, method=True, type='one2many', relation="product.product", string='Exportable Products'),
175
200
        #TODO fix me, it's look like related field on a function fielf doesn't work.
176
201
        #'magento_shop': fields.related('referential_id', 'magento_referential',type="boolean", string='Magento Shop', readonly=True),