~credativ/openobject-addons/c2c-extra

« back to all changes in this revision

Viewing changes to esale_osc/esale_oscom.py

  • Committer: ksa (Open ERP)
  • Date: 2010-07-06 05:10:58 UTC
  • Revision ID: ksa@tinyerp.co.in-20100706051058-x96e97ij1pvuu9ey
[IMP]:Remove print statement

Show diffs side-by-side

added added

removed removed

Lines of Context:
160
160
            categories = server.get_categories_parent(osc_langs)
161
161
            for category in categories:
162
162
                # Search in intermediate esale.oscom.category object that maps OScommerce and OpenERP categories
163
 
                #print category
164
163
                cat_oscom_id = esale_category_obj.search(cr, uid, [('web_id','=',website.id), ('esale_oscom_id','=',category[0])])
165
164
                if cat_oscom_id:
166
165
                    cat_oscom = esale_category_obj.browse(cr, uid, cat_oscom_id)[0]
197
196
 
198
197
                # Updates translations
199
198
                for trans, lang in zip(category[2:], oerp_langs):
200
 
                    #print trans, lang.code
201
199
                    category_obj.write(cr, uid, cat_id, {'name': trans}, {'lang': lang.code})
202
200
 
203
201
            cr.commit()
270
268
            mini = server.get_min_products_id()
271
269
            maxi = mini + 30
272
270
            tope = server.get_max_products_id()
273
 
            #print "Product maxi:" , tope
274
271
            while maxi <= tope:
275
 
                #print "Start mini loop", mini
276
 
                #print "Start maxi loop", maxi
277
272
                products_osc = server.get_products(osc_langs, mini, maxi)
278
 
                #print products_osc
279
273
                mini = maxi
280
274
                maxi = maxi + 30
281
275
                for product in products_osc:
282
 
                    #print "================================product from osc=========================================="
283
 
                    #print product
284
276
                    info_prod = product['product']
285
277
                    spec_prod = product['product_special']
286
278
                    name_prod = product['product_description'] and product['product_description'][0]['products_name'] or '-'
287
279
                    url_manuf = product['manufacturers_url']
288
 
                    #print info_prod['products_id'], " Code " , info_prod['products_model']
289
280
 
290
281
                    # Search mapped category. If not found the product is not added/modified
291
282
                    if info_prod['categ_id'] in oerp_categs:
307
298
                            manuf_id = manuf_ids[0]
308
299
                        for url_manuf_el in url_manuf:
309
300
                            if url_manuf_el['languages_id'] in oerp_langs:
310
 
                                #print url_manuf_el['languages_id'], oerp_langs[url_manuf_el['languages_id']].code
311
301
                                manufacturer_obj.write(cr, uid, [manuf_id], {'manufacturer_url': url_manuf_el['manufacturers_url']}, {'lang': oerp_langs[url_manuf_el['languages_id']].code})
312
302
 
313
303
                    value = {
333
323
                        #'standard_price': info_prod['products_price'],
334
324
                    }
335
325
                    value.update(self.product_fields(info_prod)) # Adds additional fields
336
 
                    # print "=======value======"
337
 
                    #print value
338
326
 
339
327
                    # Search in intermediate esale.oscom.product object that maps OScommerce and OpenERP products
340
328
                    esale_product_ids = esale_product_obj.search(cr, uid, [('web_id','=',website.id), ('esale_oscom_id','=',info_prod['products_id'])])
369
357
                            'product_url': trans['products_url'],
370
358
                        }
371
359
                        value_trans.update(self.product_trans_fields(trans)) # Adds additional fields
372
 
                        # print "==========trans========="
373
 
                        #print value_trans
374
360
                        super(osv.osv, product_obj).write(cr, uid, [prod_id], value_trans, {'lang': oerp_langs[trans['language_id']].code})
375
361
 
376
362
                        self.product_extra_info(cr, uid, website, prod_id, product) # Creates additonal information in OpenERP objects related to product
457
443
            saleorders = server.get_saleorders(0)
458
444
        no_of_so = 0
459
445
        for saleorder in saleorders:
460
 
            #print "==========*********NEW**************==========="
461
 
            #print "== Oscommerce Sale Order Number :", saleorder['id']
462
446
            if len(saleorder['partner']) > 0 :
463
447
                oscom_partner = saleorder['partner'][0]
464
 
                #print "== Sale order partner:", saleorder['partner'][0]
465
448
            partner_ids = partner_obj.search(cr, uid, [('esale_oscom_id','=',oscom_partner['esale_oscom_id'])])
466
449
            if len(partner_ids):
467
450
                partner_id = partner_ids[0]
475
458
 
476
459
            # Default address is right on Website so we create the order.
477
460
            if len(saleorder['address']) > 0 :
478
 
                #print "===Sale order address:",saleorder['address'][0]
479
461
                default_address = saleorder['address'][0]
480
462
                del saleorder['address']
481
463
                default_address['type'] = 'default'
482
464
                default_address_id = _add_address(self, cr, uid, default_address.copy(), partner_id, context)
483
465
                shipping_address = []
484
466
                if len(saleorder['delivery']) > 0 :
485
 
                    #print "===Sale order Delivery:",saleorder['delivery'][0]
486
467
                    shipping_address = saleorder['delivery'][0]
487
468
                    del saleorder['delivery']
488
469
                    shipping_address['type'] = 'delivery'
489
470
                    shipping_address_id = _add_address(self, cr, uid, shipping_address.copy(), partner_id, context)
490
471
                billing_address = []
491
472
                if len(saleorder['billing']) > 0 :
492
 
                    #print "===Sale order Billing:",saleorder['billing'][0]
493
 
                    billing_address = saleorder['billing'][0]
494
473
                    del saleorder['billing']
495
474
                    billing_address['type'] = 'invoice'
496
475
                    billing_address_id = _add_address(self, cr, uid, billing_address.copy(),partner_id, context)
589
568
                        ids = saleorder_line_obj.create(cr, uid, linevalue)
590
569
                        if tax_id:
591
570
                            cr.execute('insert into sale_order_tax (order_line_id,tax_id) values (%d,%d)', (ids, tax_id))
592
 
                #print "======== UPDATE:",saleorder['shipping_title']
593
571
                shopping_cost_id = product_obj.search(cr, uid, [('name','=','Shipping Cost')])
594
572
                if shopping_cost_id:
595
573
                    if saleorder['shipping_price'] > 0.0000:
605
583
                        if so_line_shipping.get('weight',False):
606
584
                            del so_line_shipping['weight']
607
585
                        del so_line_shipping['tax_id']
608
 
                        #print "=== Order line:", so_line_shipping
609
586
                        ids = saleorder_line_obj.create(cr, uid, so_line_shipping)
610
 
                #print "=== Cupon line:",saleorder['dcoupon_title']
611
 
                #print "=== Cash order line:",saleorder['cash_title']
612
587
                discount_cost_id = product_obj.search(cr, uid, [('name','=','Discount Coupon')])
613
588
                if discount_cost_id:
614
589
                    if saleorder['dcoupon_price'] != 0.0000:
617
592
                            'product_uom_qty': 1,
618
593
                            'order_id'       : order_id
619
594
                        }
620
 
                        #print "=== Cupon line:",saleorder['dcoupon_title']
621
595
                        so_line_discount.update(saleorder_line_obj.product_id_change(cr, uid, [], value['pricelist_id'], so_line_discount['product_id'], so_line_discount['product_uom_qty'],False, 0, False, '', value['partner_id'])['value'])
622
596
                        so_line_discount.update(saleorder_line_obj.default_get(cr, uid, ['sequence', 'invoiced', 'state', 'product_packaging']))
623
597
                        so_line_discount['price_unit'] = saleorder['dcoupon_price']
625
599
                        if so_line_discount.get('weight',False):
626
600
                            del so_line_discount['weight']
627
601
                        del so_line_discount['tax_id']
628
 
                        #print "=== Cupon line:", so_line_discount
629
602
                        ids = saleorder_line_obj.create(cr, uid, so_line_discount)
630
603
                cash_cost_id = product_obj.search(cr, uid, [('name','=','Cash On Delivery')])
631
604
                if cash_cost_id:
635
608
                            'product_uom_qty': 1,
636
609
                            'order_id'       : order_id
637
610
                        }
638
 
                        #print "=== Cash order line:",saleorder['cash_title']
639
611
                        so_line_cash.update(saleorder_line_obj.product_id_change(cr, uid, [], value['pricelist_id'], so_line_cash['product_id'], so_line_cash['product_uom_qty'],False, 0, False, '', value['partner_id'])['value'])
640
612
                        so_line_cash.update(saleorder_line_obj.default_get(cr, uid, ['sequence', 'invoiced', 'state', 'product_packaging']))
641
613
                        so_line_cash['price_unit'] = saleorder['cash_price']
643
615
                        if so_line_cash.get('weight',False):
644
616
                            del so_line_cash['weight']
645
617
                        del so_line_cash['tax_id']
646
 
                        #print "=== Order line:", so_line_cash
647
618
                        ids = saleorder_line_obj.create(cr, uid, so_line_cash)
648
619
 
649
620
                no_of_so +=1