~magentoerpconnect-core-editors/magentoerpconnect/trunk_version

« back to all changes in this revision

Viewing changes to magentoerpconnect/sale.py

  • Committer: Guewen Baconnier @ Camptocamp
  • Date: 2012-06-11 07:52:17 UTC
  • mto: This revision was merged to the branch mainline in revision 648.
  • Revision ID: guewen.baconnier@camptocamp.com-20120611075217-yv2nff6xdk3tc2w6
[FIX] Correctly use the product of the delivery carrier for shipping order lines

Show diffs side-by-side

added added

removed removed

Lines of Context:
418
418
        @param data_record: full data dict of the order
419
419
        @param ext_field: name of the field in data_record where the amount of the extra lineis stored
420
420
        @param product_ref: tuple with module and xml_id (module, xml_id) of the product to use for the extra line
 
421
            or id as int/long of the product
421
422
 
422
423
        Optional arguments in context:
423
424
        sign: multiply the amount with the sign to add or substract it from the sale order
430
431
        ext_tax_field = 'ext_tax_field' in context and context['ext_tax_field'] or None
431
432
        ext_code_field = 'ext_code_field' in context and context['ext_code_field'] or None
432
433
 
433
 
        model, product_id = model_data_obj.get_object_reference(cr, uid, *product_ref)
 
434
        if isinstance(product_ref, tuple):
 
435
            dummy, product_id = model_data_obj.get_object_reference(cr, uid, *product_ref)
 
436
        else:
 
437
            product_id = product_ref
434
438
        product = self.pool.get('product.product').browse(cr, uid, product_id, context)
435
439
        is_tax_included = context.get('price_is_tax_included', False)
436
440
        amount = float(data_record[ext_field]) * sign
473
477
            ctx.update({
474
478
                'ext_tax_field': 'shipping_tax_amount',
475
479
            })
476
 
            product_ref = ('base_sale_multichannels', 'product_product_shipping')
477
 
            res = self.add_order_extra_line(cr, uid, res, data_record, 'shipping_amount', product_ref, defaults, ctx)
 
480
            product = False
 
481
            if res.get('carrier_id'):
 
482
                carrier = self.pool.get('delivery.carrier').browse(cr, uid, res['carrier_id'], context=context)
 
483
                product = carrier.product_id.id
 
484
            else:
 
485
                product = ('base_sale_multichannels', 'product_product_shipping')
 
486
            res = self.add_order_extra_line(cr, uid, res, data_record, 'shipping_amount', product, defaults, ctx)
478
487
        return res
479
488
 
480
489
    def add_gift_certificates(self, cr, uid, res, external_referential_id, data_record, defaults, context=None):